Chapter 5 — How Gmail Works 73
img.src = ONE_PX;
}
function GetRoundtripTimeFunction(start) {
return function() {
var end = (new Date()).getTime();
SetGmailCookie(“GMAIL_RTT2”, (end - start));
}
}
function OnLoad() {
var form = document.getElementById(“gaia_loginform”);
form.onsubmit = lg;
CheckBrowser();
LogRoundtripTime();
}
This JavaScript sets two cookies. The first,GMAIL_LOGIN2, is set with a value of
Tstart_time/start_time/nowwhere both start_timeand noware the date-
time exactly then. As you can see from the comments in the code, Google intends
to replace this in the future.
The second cookie is called GMAIL_RTT2and contains the time it takes to retrieve
a 1-pixel image file from the Gmail servers.RTT, presumably, stands for Round
Trip Time.
You won’t look at it in this book, but the rest of the JavaScript code on that page
presents a very nice listing of a browser check that removes the login window if
the browser isn’t capable of using Gmail.
If you watch the Gmail login sequence from your own browser, you will see that it
goes through more redirects before it settles into HTTP again, and you can see
what is going on from the Tcpflow trace file.
Hitting stop on the browser at just the right time (and that is, to quote the fine
words of my editor, a total crapshoot), gives you this URL:
https://www.google.com/accounts/CheckCookie?continue=http%3A%2F
%2Fgmail.google.com%2Fgmail%3F_sgh%3D8a6d8ffbb159f1c7c9246bd4f4
9e78a1&service=mail&chtml=LoginDoneHtml
Viewing source on that page gives you Listing 5-8.