Permalink
Browse files

Closure related changes to support BrowserChannel Startup optimization.

R=dennygursky,mpd
DELTA=36 (35 added, 0 deleted, 1 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=6191


git-svn-id: http://closure-library.googlecode.com/svn/trunk@2461 0b95b8e8-c90f-11de-9d4f-f947ee5921c8
  • Loading branch information...
1 parent 999e56a commit 17aa0615f1d84bd1654968b5b854231e7b7422f1 arunabhaghosh@google.com committed Jan 24, 2013
Showing with 36 additions and 1 deletion.
  1. +20 −1 closure/goog/net/browserchannel.js
  2. +16 −0 closure/goog/net/browsertestchannel.js
View
21 closure/goog/net/browserchannel.js
@@ -73,9 +73,11 @@ goog.require('goog.userAgent');
*
* @param {string=} opt_clientVersion An application-specific version number
* that is sent to the server when connected.
+ * @param {Array.<string>=} opt_firstTestResults Previously determined results
+ * of the first browser channel test.
* @constructor
*/
-goog.net.BrowserChannel = function(opt_clientVersion) {
+ goog.net.BrowserChannel = function(opt_clientVersion, opt_firstTestResults) {
/**
* The application specific version that is passed to the server.
* @type {?string}
@@ -121,6 +123,13 @@ goog.net.BrowserChannel = function(opt_clientVersion) {
* @private
*/
this.parser_ = new goog.json.EvalJsonProcessor(null, true);
+
+ /**
+ * An array of results for the first browser channel test call.
+ * @type {Array.<string>}
+ * @private
+ */
+ this.firstTestResults_ = opt_firstTestResults || null;
};
@@ -2277,6 +2286,16 @@ goog.net.BrowserChannel.prototype.getForwardChannelUri =
/**
+ * Gets the results for the first browser channel test
+ * @return {Array.<string>} The results.
+ */
+goog.net.BrowserChannel.prototype.getFirstTestResults =
+ function() {
+ return this.firstTestResults_;
+};
+
+
+/**
* Gets the Uri used for the connection that receives data from the server.
* @param {?string} hostPrefix The host prefix.
* @param {string} path The path on the host.
View
16 closure/goog/net/browsertestchannel.js
@@ -23,6 +23,7 @@
*/
+
goog.provide('goog.net.BrowserTestChannel');
goog.require('goog.json.EvalJsonProcessor');
@@ -260,6 +261,21 @@ goog.net.BrowserTestChannel.prototype.connect = function(path) {
goog.net.BrowserChannel.notifyStatEvent(
goog.net.BrowserChannel.Stat.TEST_STAGE_ONE_START);
+ // If the channel already has the result of the first test, then skip it.
+ var firstTestResults = this.channel_.getFirstTestResults();
+ if (goog.isDefAndNotNull(firstTestResults)) {
+ this.hostPrefix_ = firstTestResults[0];
+ this.blockedPrefix_ = firstTestResults[1];
+ if (this.blockedPrefix_) {
+ this.state_ = goog.net.BrowserTestChannel.State_.CHECKING_BLOCKED;
+ this.checkBlocked_();
+ } else {
+ this.state_ = goog.net.BrowserTestChannel.State_.CONNECTION_TESTING;
+ this.connectStage2_();
+ }
+ return;
+ }
+
// the first request returns server specific parameters
sendDataUri.setParameterValues('MODE', 'init');
this.request_ = goog.net.BrowserChannel.createChannelRequest(

0 comments on commit 17aa061

Please sign in to comment.