Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/NetworkManager.js

Issue 2440953003: DevTools: use semicolons after each statement. (Closed)
Patch Set: rebaseline Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 this._networkAgent.enable(10000000, 5000000); 50 this._networkAgent.enable(10000000, 5000000);
51 else 51 else
52 this._networkAgent.enable(); 52 this._networkAgent.enable();
53 53
54 this._bypassServiceWorkerSetting = WebInspector.settings.createSetting("bypa ssServiceWorker", false); 54 this._bypassServiceWorkerSetting = WebInspector.settings.createSetting("bypa ssServiceWorker", false);
55 if (this._bypassServiceWorkerSetting.get()) 55 if (this._bypassServiceWorkerSetting.get())
56 this._bypassServiceWorkerChanged(); 56 this._bypassServiceWorkerChanged();
57 this._bypassServiceWorkerSetting.addChangeListener(this._bypassServiceWorker Changed, this); 57 this._bypassServiceWorkerSetting.addChangeListener(this._bypassServiceWorker Changed, this);
58 58
59 WebInspector.moduleSetting("cacheDisabled").addChangeListener(this._cacheDis abledSettingChanged, this); 59 WebInspector.moduleSetting("cacheDisabled").addChangeListener(this._cacheDis abledSettingChanged, this);
60 } 60 };
61 61
62 /** @enum {symbol} */ 62 /** @enum {symbol} */
63 WebInspector.NetworkManager.Events = { 63 WebInspector.NetworkManager.Events = {
64 RequestStarted: Symbol("RequestStarted"), 64 RequestStarted: Symbol("RequestStarted"),
65 RequestUpdated: Symbol("RequestUpdated"), 65 RequestUpdated: Symbol("RequestUpdated"),
66 RequestFinished: Symbol("RequestFinished"), 66 RequestFinished: Symbol("RequestFinished"),
67 RequestUpdateDropped: Symbol("RequestUpdateDropped"), 67 RequestUpdateDropped: Symbol("RequestUpdateDropped"),
68 ResponseReceived: Symbol("ResponseReceived") 68 ResponseReceived: Symbol("ResponseReceived")
69 } 69 };
70 70
71 WebInspector.NetworkManager._MIMETypes = { 71 WebInspector.NetworkManager._MIMETypes = {
72 "text/html": {"document": true}, 72 "text/html": {"document": true},
73 "text/xml": {"document": true}, 73 "text/xml": {"document": true},
74 "text/plain": {"document": true}, 74 "text/plain": {"document": true},
75 "application/xhtml+xml": {"document": true}, 75 "application/xhtml+xml": {"document": true},
76 "image/svg+xml": {"document": true}, 76 "image/svg+xml": {"document": true},
77 "text/css": {"stylesheet": true}, 77 "text/css": {"stylesheet": true},
78 "text/xsl": {"stylesheet": true}, 78 "text/xsl": {"stylesheet": true},
79 "text/vtt": {"texttrack": true}, 79 "text/vtt": {"texttrack": true},
80 } 80 };
81 81
82 /** 82 /**
83 * @param {!WebInspector.Target} target 83 * @param {!WebInspector.Target} target
84 * @return {?WebInspector.NetworkManager} 84 * @return {?WebInspector.NetworkManager}
85 */ 85 */
86 WebInspector.NetworkManager.fromTarget = function(target) 86 WebInspector.NetworkManager.fromTarget = function(target)
87 { 87 {
88 return /** @type {?WebInspector.NetworkManager} */ (target.model(WebInspecto r.NetworkManager)); 88 return /** @type {?WebInspector.NetworkManager} */ (target.model(WebInspecto r.NetworkManager));
89 } 89 };
90 90
91 /** @typedef {{download: number, upload: number, latency: number, title: string} } */ 91 /** @typedef {{download: number, upload: number, latency: number, title: string} } */
92 WebInspector.NetworkManager.Conditions; 92 WebInspector.NetworkManager.Conditions;
93 /** @type {!WebInspector.NetworkManager.Conditions} */ 93 /** @type {!WebInspector.NetworkManager.Conditions} */
94 WebInspector.NetworkManager.NoThrottlingConditions = {title: WebInspector.UIStri ng("No throttling"), download: -1, upload: -1, latency: 0}; 94 WebInspector.NetworkManager.NoThrottlingConditions = {title: WebInspector.UIStri ng("No throttling"), download: -1, upload: -1, latency: 0};
95 /** @type {!WebInspector.NetworkManager.Conditions} */ 95 /** @type {!WebInspector.NetworkManager.Conditions} */
96 WebInspector.NetworkManager.OfflineConditions = {title: WebInspector.UIString("O ffline"), download: 0, upload: 0, latency: 0}; 96 WebInspector.NetworkManager.OfflineConditions = {title: WebInspector.UIString("O ffline"), download: 0, upload: 0, latency: 0};
97 97
98 /** 98 /**
99 * @param {!WebInspector.NetworkManager.Conditions} conditions 99 * @param {!WebInspector.NetworkManager.Conditions} conditions
(...skipping 13 matching lines...) Expand all
113 types.push(["4g", NetworkAgent.ConnectionType.Cellular4g]); 113 types.push(["4g", NetworkAgent.ConnectionType.Cellular4g]);
114 types.push(["bluetooth", NetworkAgent.ConnectionType.Bluetooth]); 114 types.push(["bluetooth", NetworkAgent.ConnectionType.Bluetooth]);
115 types.push(["wifi", NetworkAgent.ConnectionType.Wifi]); 115 types.push(["wifi", NetworkAgent.ConnectionType.Wifi]);
116 types.push(["wimax", NetworkAgent.ConnectionType.Wimax]); 116 types.push(["wimax", NetworkAgent.ConnectionType.Wimax]);
117 } 117 }
118 for (var type of types) { 118 for (var type of types) {
119 if (conditions.title.toLowerCase().indexOf(type[0]) !== -1) 119 if (conditions.title.toLowerCase().indexOf(type[0]) !== -1)
120 return type[1]; 120 return type[1];
121 } 121 }
122 return NetworkAgent.ConnectionType.Other; 122 return NetworkAgent.ConnectionType.Other;
123 } 123 };
124 124
125 WebInspector.NetworkManager.prototype = { 125 WebInspector.NetworkManager.prototype = {
126 /** 126 /**
127 * @param {string} url 127 * @param {string} url
128 * @return {!WebInspector.NetworkRequest} 128 * @return {!WebInspector.NetworkRequest}
129 */ 129 */
130 inflightRequestForURL: function(url) 130 inflightRequestForURL: function(url)
131 { 131 {
132 return this._dispatcher._inflightRequestsByURL[url]; 132 return this._dispatcher._inflightRequestsByURL[url];
133 }, 133 },
(...skipping 11 matching lines...) Expand all
145 { 145 {
146 WebInspector.moduleSetting("cacheDisabled").removeChangeListener(this._c acheDisabledSettingChanged, this); 146 WebInspector.moduleSetting("cacheDisabled").removeChangeListener(this._c acheDisabledSettingChanged, this);
147 }, 147 },
148 148
149 _bypassServiceWorkerChanged: function() 149 _bypassServiceWorkerChanged: function()
150 { 150 {
151 this._networkAgent.setBypassServiceWorker(this._bypassServiceWorkerSetti ng.get()); 151 this._networkAgent.setBypassServiceWorker(this._bypassServiceWorkerSetti ng.get());
152 }, 152 },
153 153
154 __proto__: WebInspector.SDKModel.prototype 154 __proto__: WebInspector.SDKModel.prototype
155 } 155 };
156 156
157 /** 157 /**
158 * @constructor 158 * @constructor
159 * @implements {NetworkAgent.Dispatcher} 159 * @implements {NetworkAgent.Dispatcher}
160 */ 160 */
161 WebInspector.NetworkDispatcher = function(manager) 161 WebInspector.NetworkDispatcher = function(manager)
162 { 162 {
163 this._manager = manager; 163 this._manager = manager;
164 this._inflightRequestsById = {}; 164 this._inflightRequestsById = {};
165 this._inflightRequestsByURL = {}; 165 this._inflightRequestsByURL = {};
166 } 166 };
167 167
168 WebInspector.NetworkDispatcher.prototype = { 168 WebInspector.NetworkDispatcher.prototype = {
169 /** 169 /**
170 * @param {!NetworkAgent.Headers} headersMap 170 * @param {!NetworkAgent.Headers} headersMap
171 * @return {!Array.<!WebInspector.NetworkRequest.NameValue>} 171 * @return {!Array.<!WebInspector.NetworkRequest.NameValue>}
172 */ 172 */
173 _headersMapToHeadersArray: function(headersMap) 173 _headersMapToHeadersArray: function(headersMap)
174 { 174 {
175 var result = []; 175 var result = [];
176 for (var name in headersMap) { 176 for (var name in headersMap) {
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 * @param {string} frameId 653 * @param {string} frameId
654 * @param {!NetworkAgent.LoaderId} loaderId 654 * @param {!NetworkAgent.LoaderId} loaderId
655 * @param {string} url 655 * @param {string} url
656 * @param {string} documentURL 656 * @param {string} documentURL
657 * @param {?NetworkAgent.Initiator} initiator 657 * @param {?NetworkAgent.Initiator} initiator
658 */ 658 */
659 _createNetworkRequest: function(requestId, frameId, loaderId, url, documentU RL, initiator) 659 _createNetworkRequest: function(requestId, frameId, loaderId, url, documentU RL, initiator)
660 { 660 {
661 return new WebInspector.NetworkRequest(this._manager._target, requestId, url, documentURL, frameId, loaderId, initiator); 661 return new WebInspector.NetworkRequest(this._manager._target, requestId, url, documentURL, frameId, loaderId, initiator);
662 } 662 }
663 } 663 };
664 664
665 665
666 /** 666 /**
667 * @constructor 667 * @constructor
668 * @extends {WebInspector.Object} 668 * @extends {WebInspector.Object}
669 * @implements {WebInspector.TargetManager.Observer} 669 * @implements {WebInspector.TargetManager.Observer}
670 */ 670 */
671 WebInspector.MultitargetNetworkManager = function() 671 WebInspector.MultitargetNetworkManager = function()
672 { 672 {
673 WebInspector.Object.call(this); 673 WebInspector.Object.call(this);
674 WebInspector.targetManager.observeTargets(this); 674 WebInspector.targetManager.observeTargets(this);
675 675
676 /** @type {!Set<string>} */ 676 /** @type {!Set<string>} */
677 this._blockedURLs = new Set(); 677 this._blockedURLs = new Set();
678 this._blockedSetting = WebInspector.moduleSetting("blockedURLs"); 678 this._blockedSetting = WebInspector.moduleSetting("blockedURLs");
679 this._blockedSetting.addChangeListener(this._updateBlockedURLs, this); 679 this._blockedSetting.addChangeListener(this._updateBlockedURLs, this);
680 this._blockedSetting.set([]); 680 this._blockedSetting.set([]);
681 this._updateBlockedURLs(); 681 this._updateBlockedURLs();
682 682
683 this._userAgentOverride = ""; 683 this._userAgentOverride = "";
684 /** @type {!Set<!Protocol.NetworkAgent>} */ 684 /** @type {!Set<!Protocol.NetworkAgent>} */
685 this._agents = new Set(); 685 this._agents = new Set();
686 /** @type {!WebInspector.NetworkManager.Conditions} */ 686 /** @type {!WebInspector.NetworkManager.Conditions} */
687 this._networkConditions = WebInspector.NetworkManager.NoThrottlingConditions ; 687 this._networkConditions = WebInspector.NetworkManager.NoThrottlingConditions ;
688 } 688 };
689 689
690 /** @enum {symbol} */ 690 /** @enum {symbol} */
691 WebInspector.MultitargetNetworkManager.Events = { 691 WebInspector.MultitargetNetworkManager.Events = {
692 ConditionsChanged: Symbol("ConditionsChanged"), 692 ConditionsChanged: Symbol("ConditionsChanged"),
693 UserAgentChanged: Symbol("UserAgentChanged") 693 UserAgentChanged: Symbol("UserAgentChanged")
694 } 694 };
695 695
696 /** 696 /**
697 * @param {string} uaString 697 * @param {string} uaString
698 * @return {string} 698 * @return {string}
699 */ 699 */
700 WebInspector.MultitargetNetworkManager.patchUserAgentWithChromeVersion = functio n(uaString) 700 WebInspector.MultitargetNetworkManager.patchUserAgentWithChromeVersion = functio n(uaString)
701 { 701 {
702 // Patches Chrome/CriOS version from user agent ("1.2.3.4" when user agent i s: "Chrome/1.2.3.4"). 702 // Patches Chrome/CriOS version from user agent ("1.2.3.4" when user agent i s: "Chrome/1.2.3.4").
703 var chromeRegex = new RegExp("(?:^|\\W)Chrome/(\\S+)"); 703 var chromeRegex = new RegExp("(?:^|\\W)Chrome/(\\S+)");
704 var chromeMatch = navigator.userAgent.match(chromeRegex); 704 var chromeMatch = navigator.userAgent.match(chromeRegex);
705 if (chromeMatch && chromeMatch.length > 1) 705 if (chromeMatch && chromeMatch.length > 1)
706 return String.sprintf(uaString, chromeMatch[1]); 706 return String.sprintf(uaString, chromeMatch[1]);
707 return uaString; 707 return uaString;
708 } 708 };
709 709
710 WebInspector.MultitargetNetworkManager.prototype = { 710 WebInspector.MultitargetNetworkManager.prototype = {
711 /** 711 /**
712 * @override 712 * @override
713 * @param {!WebInspector.Target} target 713 * @param {!WebInspector.Target} target
714 */ 714 */
715 targetAdded: function(target) 715 targetAdded: function(target)
716 { 716 {
717 var networkAgent = target.networkAgent(); 717 var networkAgent = target.networkAgent();
718 if (this._extraHeaders) 718 if (this._extraHeaders)
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 if (currentUserAgent) 915 if (currentUserAgent)
916 headers["User-Agent"] = currentUserAgent; 916 headers["User-Agent"] = currentUserAgent;
917 917
918 if (WebInspector.moduleSetting("cacheDisabled").get()) 918 if (WebInspector.moduleSetting("cacheDisabled").get())
919 headers["Cache-Control"] = "no-cache"; 919 headers["Cache-Control"] = "no-cache";
920 920
921 WebInspector.ResourceLoader.load(url, headers, callback); 921 WebInspector.ResourceLoader.load(url, headers, callback);
922 }, 922 },
923 923
924 __proto__: WebInspector.Object.prototype 924 __proto__: WebInspector.Object.prototype
925 } 925 };
926 926
927 /** 927 /**
928 * @type {!WebInspector.MultitargetNetworkManager} 928 * @type {!WebInspector.MultitargetNetworkManager}
929 */ 929 */
930 WebInspector.multitargetNetworkManager; 930 WebInspector.multitargetNetworkManager;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698