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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/emulation/EmulatedDevices.js

Issue 1959783002: DevTools: Introduce device dependent CPU throttling rates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 */ 7 */
8 WebInspector.EmulatedDevice = function() 8 WebInspector.EmulatedDevice = function()
9 { 9 {
10 /** @type {string} */ 10 /** @type {string} */
11 this.title = ""; 11 this.title = "";
12 /** @type {string} */ 12 /** @type {string} */
13 this.type = WebInspector.EmulatedDevice.Type.Unknown; 13 this.type = WebInspector.EmulatedDevice.Type.Unknown;
14 /** @type {!WebInspector.EmulatedDevice.Orientation} */ 14 /** @type {!WebInspector.EmulatedDevice.Orientation} */
15 this.vertical = {width: 0, height: 0, outlineInsets: null, outlineImage: nul l}; 15 this.vertical = {width: 0, height: 0, outlineInsets: null, outlineImage: nul l};
16 /** @type {!WebInspector.EmulatedDevice.Orientation} */ 16 /** @type {!WebInspector.EmulatedDevice.Orientation} */
17 this.horizontal = {width: 0, height: 0, outlineInsets: null, outlineImage: n ull}; 17 this.horizontal = {width: 0, height: 0, outlineInsets: null, outlineImage: n ull};
18 /** @type {number} */ 18 /** @type {number} */
19 this.deviceScaleFactor = 1; 19 this.deviceScaleFactor = 1;
20 /** @type {!Array.<string>} */ 20 /** @type {!Array.<string>} */
21 this.capabilities = [WebInspector.EmulatedDevice.Capability.Touch, WebInspec tor.EmulatedDevice.Capability.Mobile]; 21 this.capabilities = [WebInspector.EmulatedDevice.Capability.Touch, WebInspec tor.EmulatedDevice.Capability.Mobile];
22 /** @type {string} */ 22 /** @type {string} */
23 this.userAgent = ""; 23 this.userAgent = "";
24 /** @type {number} */
25 this.octaneScore = 0;
24 /** @type {!Array.<!WebInspector.EmulatedDevice.Mode>} */ 26 /** @type {!Array.<!WebInspector.EmulatedDevice.Mode>} */
25 this.modes = []; 27 this.modes = [];
26 28
27 /** @type {string} */ 29 /** @type {string} */
28 this._show = WebInspector.EmulatedDevice._Show.Default; 30 this._show = WebInspector.EmulatedDevice._Show.Default;
29 /** @type {boolean} */ 31 /** @type {boolean} */
30 this._showByDefault = true; 32 this._showByDefault = true;
31 33
32 /** @type {?Runtime.Extension} */ 34 /** @type {?Runtime.Extension} */
33 this._extension = null; 35 this._extension = null;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 throw new Error("Emulated device has wrong outline insets"); 135 throw new Error("Emulated device has wrong outline insets");
134 result.outlineImage = /** @type {string} */ (parseValue(json["ou tline"], "image", "string")); 136 result.outlineImage = /** @type {string} */ (parseValue(json["ou tline"], "image", "string"));
135 } 137 }
136 return /** @type {!WebInspector.EmulatedDevice.Orientation} */ (resu lt); 138 return /** @type {!WebInspector.EmulatedDevice.Orientation} */ (resu lt);
137 } 139 }
138 140
139 var result = new WebInspector.EmulatedDevice(); 141 var result = new WebInspector.EmulatedDevice();
140 result.title = /** @type {string} */ (parseValue(json, "title", "string" )); 142 result.title = /** @type {string} */ (parseValue(json, "title", "string" ));
141 result.type = /** @type {string} */ (parseValue(json, "type", "string")) ; 143 result.type = /** @type {string} */ (parseValue(json, "type", "string")) ;
142 result.userAgent = /** @type {string} */ (parseValue(json, "user-agent", "string")); 144 result.userAgent = /** @type {string} */ (parseValue(json, "user-agent", "string"));
145 result.octaneScore = /** @type {number} */ (parseValue(json, "octane-sco re", "number", 0));
143 146
144 var capabilities = parseValue(json, "capabilities", "object", []); 147 var capabilities = parseValue(json, "capabilities", "object", []);
145 if (!Array.isArray(capabilities)) 148 if (!Array.isArray(capabilities))
146 throw new Error("Emulated device capabilities must be an array"); 149 throw new Error("Emulated device capabilities must be an array");
147 result.capabilities = []; 150 result.capabilities = [];
148 for (var i = 0; i < capabilities.length; ++i) { 151 for (var i = 0; i < capabilities.length; ++i) {
149 if (typeof capabilities[i] !== "string") 152 if (typeof capabilities[i] !== "string")
150 throw new Error("Emulated device capability must be a string"); 153 throw new Error("Emulated device capability must be a string");
151 result.capabilities.push(capabilities[i]); 154 result.capabilities.push(capabilities[i]);
152 } 155 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 json["title"] = this.title; 246 json["title"] = this.title;
244 json["type"] = this.type; 247 json["type"] = this.type;
245 json["user-agent"] = this.userAgent; 248 json["user-agent"] = this.userAgent;
246 json["capabilities"] = this.capabilities; 249 json["capabilities"] = this.capabilities;
247 250
248 json["screen"] = {}; 251 json["screen"] = {};
249 json["screen"]["device-pixel-ratio"] = this.deviceScaleFactor; 252 json["screen"]["device-pixel-ratio"] = this.deviceScaleFactor;
250 json["screen"]["vertical"] = this._orientationToJSON(this.vertical); 253 json["screen"]["vertical"] = this._orientationToJSON(this.vertical);
251 json["screen"]["horizontal"] = this._orientationToJSON(this.horizontal); 254 json["screen"]["horizontal"] = this._orientationToJSON(this.horizontal);
252 255
256 json["octane-score"] = this.octaneScore;
257
253 json["modes"] = []; 258 json["modes"] = [];
254 for (var i = 0; i < this.modes.length; ++i) { 259 for (var i = 0; i < this.modes.length; ++i) {
255 var mode = {}; 260 var mode = {};
256 mode["title"] = this.modes[i].title; 261 mode["title"] = this.modes[i].title;
257 mode["orientation"] = this.modes[i].orientation; 262 mode["orientation"] = this.modes[i].orientation;
258 mode["insets"] = {}; 263 mode["insets"] = {};
259 mode["insets"]["left"] = this.modes[i].insets.left; 264 mode["insets"]["left"] = this.modes[i].insets.left;
260 mode["insets"]["top"] = this.modes[i].insets.top; 265 mode["insets"]["top"] = this.modes[i].insets.top;
261 mode["insets"]["right"] = this.modes[i].insets.right; 266 mode["insets"]["right"] = this.modes[i].insets.right;
262 mode["insets"]["bottom"] = this.modes[i].insets.bottom; 267 mode["insets"]["bottom"] = this.modes[i].insets.bottom;
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 523
519 /** 524 /**
520 * @return {!WebInspector.EmulatedDevicesList} 525 * @return {!WebInspector.EmulatedDevicesList}
521 */ 526 */
522 WebInspector.EmulatedDevicesList.instance = function() 527 WebInspector.EmulatedDevicesList.instance = function()
523 { 528 {
524 if (!WebInspector.EmulatedDevicesList._instance) 529 if (!WebInspector.EmulatedDevicesList._instance)
525 WebInspector.EmulatedDevicesList._instance = new WebInspector.EmulatedDe vicesList(); 530 WebInspector.EmulatedDevicesList._instance = new WebInspector.EmulatedDe vicesList();
526 return /** @type {!WebInspector.EmulatedDevicesList} */ (WebInspector.Emulat edDevicesList._instance); 531 return /** @type {!WebInspector.EmulatedDevicesList} */ (WebInspector.Emulat edDevicesList._instance);
527 } 532 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698