Path: blob/trunk/third_party/closure/goog/net/xpc/transport.js
1865 views
// Copyright 2007 The Closure Library Authors. All Rights Reserved.1//2// Licensed under the Apache License, Version 2.0 (the "License");3// you may not use this file except in compliance with the License.4// You may obtain a copy of the License at5//6// http://www.apache.org/licenses/LICENSE-2.07//8// Unless required by applicable law or agreed to in writing, software9// distributed under the License is distributed on an "AS-IS" BASIS,10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11// See the License for the specific language governing permissions and12// limitations under the License.1314/**15* @fileoverview Contains the base class for transports.16*17*/181920goog.provide('goog.net.xpc.Transport');2122goog.require('goog.Disposable');23goog.require('goog.dom');24goog.require('goog.net.xpc.TransportNames');25262728/**29* The base class for transports.30* @param {goog.dom.DomHelper=} opt_domHelper The dom helper to use for31* finding the window objects.32* @constructor33* @extends {goog.Disposable};34*/35goog.net.xpc.Transport = function(opt_domHelper) {36goog.Disposable.call(this);3738/**39* The dom helper to use for finding the window objects to reference.40* @type {goog.dom.DomHelper}41* @private42*/43this.domHelper_ = opt_domHelper || goog.dom.getDomHelper();44};45goog.inherits(goog.net.xpc.Transport, goog.Disposable);464748/**49* The transport type.50* @type {number}51* @protected52*/53goog.net.xpc.Transport.prototype.transportType = 0;545556/**57* @return {number} The transport type identifier.58*/59goog.net.xpc.Transport.prototype.getType = function() {60return this.transportType;61};626364/**65* Returns the window associated with this transport instance.66* @return {!Window} The window to use.67*/68goog.net.xpc.Transport.prototype.getWindow = function() {69return this.domHelper_.getWindow();70};717273/**74* Return the transport name.75* @return {string} the transport name.76*/77goog.net.xpc.Transport.prototype.getName = function() {78return goog.net.xpc.TransportNames[String(this.transportType)] || '';79};808182/**83* Handles transport service messages (internal signalling).84* @param {string} payload The message content.85*/86goog.net.xpc.Transport.prototype.transportServiceHandler = goog.abstractMethod;878889/**90* Connects this transport.91* The transport implementation is expected to call92* CrossPageChannel.prototype.notifyConnected when the channel is ready93* to be used.94*/95goog.net.xpc.Transport.prototype.connect = goog.abstractMethod;969798/**99* Sends a message.100* @param {string} service The name off the service the message is to be101* delivered to.102* @param {string} payload The message content.103*/104goog.net.xpc.Transport.prototype.send = goog.abstractMethod;105106107