Path: blob/trunk/third_party/closure/goog/net/wrapperxmlhttpfactory.js
2868 views
// Copyright 2010 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 Implementation of XmlHttpFactory which allows construction from16* simple factory methods.17* @author [email protected] (David Barrett-Kahn)18*/1920goog.provide('goog.net.WrapperXmlHttpFactory');2122/** @suppress {extraRequire} Typedef. */23goog.require('goog.net.XhrLike');24goog.require('goog.net.XmlHttpFactory');25262728/**29* An xhr factory subclass which can be constructed using two factory methods.30* This exists partly to allow the preservation of goog.net.XmlHttp.setFactory()31* with an unchanged signature.32* @param {function():!goog.net.XhrLike.OrNative} xhrFactory33* A function which returns a new XHR object.34* @param {function():!Object} optionsFactory A function which returns the35* options associated with xhr objects from this factory.36* @extends {goog.net.XmlHttpFactory}37* @constructor38* @final39*/40goog.net.WrapperXmlHttpFactory = function(xhrFactory, optionsFactory) {41goog.net.XmlHttpFactory.call(this);4243/**44* XHR factory method.45* @type {function() : !goog.net.XhrLike.OrNative}46* @private47*/48this.xhrFactory_ = xhrFactory;4950/**51* Options factory method.52* @type {function() : !Object}53* @private54*/55this.optionsFactory_ = optionsFactory;56};57goog.inherits(goog.net.WrapperXmlHttpFactory, goog.net.XmlHttpFactory);585960/** @override */61goog.net.WrapperXmlHttpFactory.prototype.createInstance = function() {62return this.xhrFactory_();63};646566/** @override */67goog.net.WrapperXmlHttpFactory.prototype.getOptions = function() {68return this.optionsFactory_();69};707172