goog.net.BrowserChannel
Classgoog.net.BrowserChannel(opt_clientVersion)
Encapsulates the logic for a single BrowserChannel.
opt_clientVersion
{string
=}
.BACK_CHANNEL_MAX_RETRIES
{number
}Maximum number of attempts to connect to the server for back channel requests.
goog.net.BrowserChannel.Error
EnumEnum type for identifying a BrowserChannel error. … more
goog.net.BrowserChannel.Event
Namespace {Object
}Events fired by BrowserChannel and associated objects … more
.FORWARD_CHANNEL_RETRY_TIMEOUT
{number
}The timeout in milliseconds for a forward channel request.
goog.net.BrowserChannel.Handler
ClassInterface for the browser channel handler … more
.INACTIVE_CHANNEL_RETRY_FACTOR
{number
}When retrying for an inactive channel, we will multiply the total delay by this number.
.LATEST_CHANNEL_VERSION
{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.
goog.net.BrowserChannel.LogSaver
NamespaceA LogSaver that can be used to accumulate all the debug logs for BrowserChannels so they can be sent to the server when a problem is detected. … more
.MAGIC_RESPONSE_COOKIE
{string
}The normal response for forward channel requests. Used only before version 8 of the protocol.
.OUTSTANDING_DATA_BACKCHANNEL_RETRY_CUTOFF
{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
goog.net.BrowserChannel.QueuedMap
ClassSimple container class for a (mapId, map) pair. … more
.RTT_ESTIMATE
{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.
goog.net.BrowserChannel.ServerReachability
EnumTypes of events which reveal information about the reachability of the server. … more
goog.net.BrowserChannel.ServerReachabilityEvent
ClassEvent class for goog.net.BrowserChannel.Event.SERVER_REACHABILITY_EVENT. … more
goog.net.BrowserChannel.Stat
EnumEnum that identifies events for statistics that are interesting to track. TODO(user) - Change name not to use Event or use EventTarget … more
goog.net.BrowserChannel.StatEvent
ClassEvent class for goog.net.BrowserChannel.Event.STAT_EVENT … more
goog.net.BrowserChannel.State
EnumEnum type for the browser channel state machine. … more
goog.net.BrowserChannel.TimingEvent
ClassEvent class for goog.net.BrowserChannel.Event.TIMING_EVENT … more
.connect(testPath, channelPath, opt_extraParams, opt_oldSessionId,
opt_oldArrayId)
Starts the channel. This initiates connections to the server.
testPath
{string
}
channelPath
{string
}
opt_extraParams
{Object
=}
opt_oldSessionId
{string
=}
opt_oldArrayId
{number
=}
.correctHostPrefix(serverHostPrefix)
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.
serverHostPrefix
{?string
}
string
}
.createChannelRequest(channel, channelDebug, opt_sessionId, opt_requestId, opt_retryId)
Instantiates a ChannelRequest with the given parameters. Overidden in tests.
channel
{goog.net.BrowserChannel
|goog.net.BrowserTestChannel
}
channelDebug
{goog.net.ChannelDebug
}
opt_sessionId
{string
=}
opt_requestId
{string
|number
=}
opt_retryId
{number
=}
goog.net.ChannelRequest
}
.createDataUri(hostPrefix, path, opt_overridePort)
Creates a data Uri applying logic for secondary hostprefix, port overrides, and versioning.
hostPrefix
{?string
}
path
{string
}
opt_overridePort
{number
=}
goog.Uri
}
.createXhrIo(hostPrefix)
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.
hostPrefix
{?string
}
goog.net.XhrIo
}
.disconnect()
Disconnects and closes the channel.
.getAllowChunkedMode()
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.
boolean
}
.getAllowHostPrefix()
Returns whether the channel allows the use of a subdomain. There may be cases where this isn't allowed.
boolean
}
.getBackChannelMaxRetries()
number
}
.getBackChannelUri(hostPrefix, path)
Gets the Uri used for the connection that receives data from the server.
hostPrefix
{?string
}
path
{string
}
goog.Uri
}
.getChannelDebug()
Returns the browserchannel logger.
goog.net.ChannelDebug
}
.getExtraHeaders()
Returns the extra HTTP headers to add to all the requests sent to the server.
Object
}
.getForwardChannelMaxRetries()
number
}
.getForwardChannelUri(path)
Gets the Uri used for the connection that sends data to the server.
path
{string
}
goog.Uri
}
.getHandler()
Returns the handler used for channel callback events.
goog.net.BrowserChannel.Handler
}
.getLastArrayId()
number
}
.getLastStatusCode()
Return the last status code received for a request.
number
}
.getSessionId()
Returns the session id of the channel. Only available after the channel has been opened.
string
}
.getStatEventTarget()
Returns the singleton event target for stat events.
goog.events.EventTarget
}
.getState()
Returns the browser channel state.
goog.net.BrowserChannel.State
}
.hasOutstandingRequests()
Returns whether there are outstanding requests servicing the channel.
boolean
}
.isActive()
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.
boolean
}
.isBuffered()
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.
boolean
}
.isClosed()
Returns whether the channel is closed
boolean
}
.notifyServerReachabilityEvent(reachabilityType)
Notify the channel that a particular fine grained network event has occurred. Should be considered package-private.
reachabilityType
{goog.net.BrowserChannel.ServerReachability
}
.notifyStatEvent(stat)
Helper function to call the stat event callback.
stat
{goog.net.BrowserChannel.Stat
}
.notifyTimingEvent(size, rtt, retries)
Helper function to notify listeners about POST request performance.
size
{number
}
rtt
{number
}
retries
{number
}
.onEndExecution()
Helper function to call the end hook
.onRequestComplete(request)
Callback from ChannelRequest that indicates a request has completed.
request
{goog.net.ChannelRequest
}
.onRequestData(request, responseText)
Callback from ChannelRequest for when new data is received
request
{goog.net.ChannelRequest
}
responseText
{string
}
.onStartExecution()
Helper function to call the start hook
.sendMap(map, opt_context)
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.
map
{Object
|goog.structs.Map
}
opt_context
{?Object
=}
.setAllowChunkedMode(allowChunkedMode)
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.
allowChunkedMode
{boolean
}
.setAllowHostPrefix(allowHostPrefix)
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.
allowHostPrefix
{boolean
}
.setChannelDebug(channelDebug)
Set the browserchannel logger. TODO(user): Add interface for channel loggers or remove this function.
channelDebug
{goog.net.ChannelDebug
}
.setEndThreadExecutionHook(endHook)
Allows the application to set an execution hooks for when BrowserChannel stops processing requests. This is useful to track timing or logging special information. The function takes no parameters and return void.
endHook
{Function
}
.setExtraHeaders(extraHeaders)
Sets extra HTTP headers to add to all the requests sent to the server.
extraHeaders
{Object
}
.setFailFast(failFast)
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.
failFast
{boolean
}
.setForwardChannelMaxRetries(retries)
Sets the maximum number of attempts to connect to the server for forward channel requests.
retries
{number
}
.setForwardChannelRequestTimeout(timeoutMs)
Sets the timeout for a forward channel request.
timeoutMs
{number
}
.setHandler(handler)
Sets the handler used for channel callback events.
handler
{goog.net.BrowserChannel.Handler
}
.setParser(parser)
Sets a new parser for the response payload. A custom parser may be set to avoid using eval(), for example. By default, the parser uses {@code goog.json.unsafeParse}.
parser
{!goog.string.Parser
}
.setRetryDelay(baseDelayMs, delaySeedMs)
baseDelayMs
{number
}
delaySeedMs
{number
}
.setStartThreadExecutionHook(startHook)
Allows the application to set an execution hooks for when BrowserChannel starts processing requests. This is useful to track timing or logging special information. The function takes no parameters and return void.
startHook
{Function
}
.setTimeout(fn, ms)
Wrapper around SafeTimeout which calls the start and end execution hooks with a try...finally block.
fn
{Function
}
ms
{number
}
number
}
.shouldUseSecondaryDomains()
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 only use secondary domains when using Trident's ActiveXObject, because it supports cross-domain requests out of the box. Even if we wanted to use secondary domains on Gecko/Webkit, they wouldn't work due to security restrictions on cross-origin XHRs. 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, you'll need to override this method in a subclass, and make sure that those browsers use some messaging mechanism that works cross-domain.
boolean
}
.testConnectionBlocked(testChannel)
Callback from BrowserTestChannel for when the channel is blocked.
testChannel
{goog.net.BrowserTestChannel
}
.testConnectionFailure(testChannel, errorCode)
Callback from BrowserTestChannel for when the channel has an error.
testChannel
{goog.net.BrowserTestChannel
}
errorCode
{goog.net.ChannelRequest.Error
}
.testConnectionFinished(testChannel, useChunked)
Callback from BrowserTestChannel for when the channel is finished.
testChannel
{goog.net.BrowserTestChannel
}
useChunked
{boolean
}