Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/third_party/closure/goog/net/wrapperxmlhttpfactory.js
2868 views
1
// Copyright 2010 The Closure Library Authors. All Rights Reserved.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS-IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
/**
16
* @fileoverview Implementation of XmlHttpFactory which allows construction from
17
* simple factory methods.
18
* @author [email protected] (David Barrett-Kahn)
19
*/
20
21
goog.provide('goog.net.WrapperXmlHttpFactory');
22
23
/** @suppress {extraRequire} Typedef. */
24
goog.require('goog.net.XhrLike');
25
goog.require('goog.net.XmlHttpFactory');
26
27
28
29
/**
30
* An xhr factory subclass which can be constructed using two factory methods.
31
* This exists partly to allow the preservation of goog.net.XmlHttp.setFactory()
32
* with an unchanged signature.
33
* @param {function():!goog.net.XhrLike.OrNative} xhrFactory
34
* A function which returns a new XHR object.
35
* @param {function():!Object} optionsFactory A function which returns the
36
* options associated with xhr objects from this factory.
37
* @extends {goog.net.XmlHttpFactory}
38
* @constructor
39
* @final
40
*/
41
goog.net.WrapperXmlHttpFactory = function(xhrFactory, optionsFactory) {
42
goog.net.XmlHttpFactory.call(this);
43
44
/**
45
* XHR factory method.
46
* @type {function() : !goog.net.XhrLike.OrNative}
47
* @private
48
*/
49
this.xhrFactory_ = xhrFactory;
50
51
/**
52
* Options factory method.
53
* @type {function() : !Object}
54
* @private
55
*/
56
this.optionsFactory_ = optionsFactory;
57
};
58
goog.inherits(goog.net.WrapperXmlHttpFactory, goog.net.XmlHttpFactory);
59
60
61
/** @override */
62
goog.net.WrapperXmlHttpFactory.prototype.createInstance = function() {
63
return this.xhrFactory_();
64
};
65
66
67
/** @override */
68
goog.net.WrapperXmlHttpFactory.prototype.getOptions = function() {
69
return this.optionsFactory_();
70
};
71
72