goog.net.BrowserChannel
Provided By |
---|
Encapsulates the logic for a single BrowserChannel.
new BrowserChannel( opt_clientVersion, opt_firstTestResults, opt_secondTestResults, opt_asyncTest )
Parameters |
|
---|
Instance Methods
this.connect( testPath, channelPath, opt_extraParams, opt_oldSessionId, opt_oldArrayId ) → void
void
Starts the channel. This initiates connections to the server.
Parameters |
|
---|
this.correctHostPrefix( serverHostPrefix ) → (string|null)
(string|null)
Decides which host prefix should be used, if any. If there is a handler, allows the handler to validate a host prefix provided by the server, and optionally override it.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.createDataUri( hostPrefix, path, opt_overridePort ) → goog.Uri
goog.Uri
this.createXhrIo( hostPrefix ) → goog.net.XhrIo
goog.net.XhrIo
Called when BC needs to create an XhrIo object. Override in a subclass if you need to customize the behavior, for example to enable the creation of XHR's capable of calling a secondary domain. Will also allow calling a secondary domain if withCredentials (CORS) is enabled.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.disconnect() → void
void
Disconnects and closes the channel.
this.getAllowChunkedMode() → boolean
boolean
Returns whether chunked mode is allowed. In certain debugging situations, it's useful for the application to have a way to disable chunked mode for a user.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getAllowHostPrefix() → boolean
boolean
Returns whether the channel allows the use of a subdomain. There may be cases where this isn't allowed.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getBackChannelMaxRetries() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getBackChannelUri( hostPrefix, path ) → goog.Uri
goog.Uri
this.getChannelDebug() → goog.net.ChannelDebug
goog.net.ChannelDebug
Returns the browserchannel logger.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getExtraHeaders() → (Object|null)
(Object|null)
Returns the extra HTTP headers to add to all the requests sent to the server.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getForwardChannelMaxRetries() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getForwardChannelUri( path ) → goog.Uri
goog.Uri
this.getHandler() → (goog.net.BrowserChannel.Handler|null)
(goog.net.BrowserChannel.Handler|null)
Returns the handler used for channel callback events.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getLastArrayId() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getLastStatusCode() → number
number
Return the last status code received for a request.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getSecondTestResults() → (boolean|null)
(boolean|null)
Gets the results for the second browser channel test
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getSessionId() → string
string
Returns the session id of the channel. Only available after the channel has been opened.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getState() → goog.net.BrowserChannel.State
goog.net.BrowserChannel.State
Returns the browser channel state.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.hasOutstandingRequests() → boolean
boolean
Returns whether there are outstanding requests servicing the channel.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.isActive() → boolean
boolean
Gets whether this channel is currently active. This is used to determine the length of time to wait before retrying. This call delegates to the handler.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.isBuffered() → boolean
boolean
Returns whether the channel is buffered or not. This state is valid for querying only after the test connection has completed. This may be queried in the goog.net.BrowserChannel.okToMakeRequest() callback. A channel may be buffered if the test connection determines that a chunked response could not be sent down within a suitable time.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.isClosed() → boolean
boolean
Returns whether the channel is closed
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.notifyServerReachabilityEvent( reachabilityType ) → void
void
Notify the channel that a particular fine grained network event has occurred. Should be considered package-private.
Parameters |
|
---|
this.onRequestComplete( request ) → void
void
Callback from ChannelRequest that indicates a request has completed.
Parameters |
|
---|
this.onRequestData( request, responseText ) → void
void
Callback from ChannelRequest for when new data is received
Parameters |
|
---|
this.sendMap( map, opt_context ) → void
void
Sends a request to the server. The format of the request is a Map data structure of key/value pairs. These maps are then encoded in a format suitable for the wire and then reconstituted as a Map data structure that the server can process.
Parameters |
|
---|
this.setAllowChunkedMode( allowChunkedMode ) → void
void
Sets whether chunked mode is allowed. In certain debugging situations, it's useful for the application to have a way to disable chunked mode for a user.
Parameters |
|
---|
this.setAllowHostPrefix( allowHostPrefix ) → void
void
Sets whether the channel allows the use of a subdomain. There may be cases where this isn't allowed, for example, logging in with troutboard where using a subdomain causes Apache to force the user to authenticate twice.
Parameters |
|
---|
this.setChannelDebug( channelDebug ) → void
void
Set the browserchannel logger. TODO(user): Add interface for channel loggers or remove this function.
Parameters |
|
---|
this.setExtraHeaders( extraHeaders ) → void
void
Sets extra HTTP headers to add to all the requests sent to the server.
Parameters |
|
---|
this.setFailFast( failFast ) → void
void
When set to true, this changes the behavior of the forward channel so it will not retry requests; it will fail after one network failure, and if there was already one network failure, the request will fail immediately.
Parameters |
|
---|
this.setForwardChannelMaxRetries( retries ) → void
void
Sets the maximum number of attempts to connect to the server for forward channel requests.
Parameters |
|
---|
this.setForwardChannelRequestTimeout( timeoutMs ) → void
void
Sets the timeout for a forward channel request.
Parameters |
|
---|
this.setHandler( handler ) → void
void
Sets the handler used for channel callback events.
Parameters |
|
---|
this.setIsBuffered( isBuffered ) → void
void
Sets whether the channel is buffered or not. This state is usually updated in goog.net.BrowserChannel.testConnectionFinished, but can be set manually here. This updated status will be reflected in subsequent connections and requests to the channel. NOTE: This should ONLY be used by clients that are certain of their connection status, i.e. that have performed additional test channels. Setting the wrong buffered status on a client can result in undeliverable responses from the server.
Parameters |
|
---|
this.setParser( parser ) → void
void
this.setReadyStateChangeThrottle( throttle ) → void
void
Sets the throttle for handling onreadystatechange events for the request.
Parameters |
|
---|
this.setRetryDelay( baseDelayMs, delaySeedMs ) → void
void
this.setSupportsCrossDomainXhrs( supportCrossDomain ) → void
void
Sets whether cross origin requests are supported for the browser channel.
Setting this allows the creation of requests to secondary domains and sends XHRs with the CORS withCredentials bit set to true.
In order for cross-origin requests to work, the server will also need to set CORS response headers as per: https://developer.mozilla.org/en-US/docs/HTTP_access_control
See goog.net.XhrIo#setWithCredentials
.
Parameters |
|
---|
this.shouldUseSecondaryDomains() → boolean
boolean
Determines whether to use a secondary domain when the server gives us a host prefix. This allows us to work around browser per-domain connection limits.
Currently, we use secondary domains when using Trident's ActiveXObject, because it supports cross-domain requests out of the box. Note that in IE10 we no longer use ActiveX since it's not supported in Metro mode and IE10 supports XHR streaming.
If you need to use secondary domains on other browsers and IE10,
you have two choices:
1) If you only care about browsers that support CORS
(https://developer.mozilla.org/en-US/docs/HTTP_access_control), you
can use #setSupportsCrossDomainXhrs
and set the appropriate
CORS response headers on the server.
2) Or, override this method in a subclass, and make sure that those
browsers use some messaging mechanism that works cross-domain (e.g
iframes and window.postMessage).
Parameters | None. | ||
---|---|---|---|
Returns |
| ||
See Also | http://code.google.com/p/closure-library/issues/detail?id=339 |
this.testConnectionBlocked( testChannel ) → void
void
Callback from BrowserTestChannel for when the channel is blocked.
Parameters |
|
---|
this.testConnectionFailure( testChannel, errorCode ) → void
void
Callback from BrowserTestChannel for when the channel has an error.
Parameters |
|
---|
this.testConnectionFinished( testChannel, useChunked ) → void
void
Callback from BrowserTestChannel for when the channel is finished.
Parameters |
|
---|
Instance Properties
this.allowChunkedMode_ → boolean
boolean
No information.
this.allowHostPrefix_ → boolean
boolean
No information.
Static Functions
BrowserChannel.createChannelRequest( arg0, arg1, arg2, arg3, arg4 ) → goog.net.ChannelRequest
goog.net.ChannelRequest
Alias createChannelRequest from the internal Hooks module, as it was previously available as a top-level export here.
Parameters |
| ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
BrowserChannel.getStatEventTarget() → goog.events.EventTarget
goog.events.EventTarget
Alias getStatEventTarget as it used to be provided from the main BrowserChannel module.
Parameters | None. | |
---|---|---|
Returns |
|
BrowserChannel.notifyTimingEvent( size, rtt, retries ) → void
void
BrowserChannel.setEndThreadExecutionHook( arg0 ) → void
void
Alias setEndThreadExecutionHook from the internal Hooks module, as it was previously available as a top-level export here.
Parameters |
|
---|
BrowserChannel.setStartThreadExecutionHook( arg0 ) → void
void
Alias setStartThreadExecutionHook from the internal Hooks module, as it was previously available as a top-level export here.
Parameters |
|
---|
Static Properties
BrowserChannel.BACK_CHANNEL_MAX_RETRIES → number
number
Maximum number of attempts to connect to the server for back channel requests.
BrowserChannel.FORWARD_CHANNEL_RETRY_TIMEOUT → number
number
The timeout in milliseconds for a forward channel request.
BrowserChannel.INACTIVE_CHANNEL_RETRY_FACTOR → number
number
When retrying for an inactive channel, we will multiply the total delay by this number.
BrowserChannel.LATEST_CHANNEL_VERSION → number
number
The latest protocol version that this class supports. We request this version from the server when opening the connection. Should match com.google.net.browserchannel.BrowserChannel.LATEST_CHANNEL_VERSION.
BrowserChannel.OUTSTANDING_DATA_BACKCHANNEL_RETRY_CUTOFF → number
number
A guess at a cutoff at which to no longer assume the backchannel is dead when we are slow to receive data. Number in bytes.
Assumption: The worst bandwidth we work on is 50 kilobits/sec 50kbits/sec * (1 byte / 8 bits) * 6 sec dead backchannel timeout
BrowserChannel.RTT_ESTIMATE → number
number
A number in MS of how long we guess the maxmium amount of time a round trip to the server should take. In the future this could be substituted with a real measurement of the RTT.