| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 The Chromium Authors. All rights reserved. | 2 * Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * @constructor | 8 * @constructor |
| 9 * @param {!WebInspector.TracingModel} tracingModel | 9 * @param {!WebInspector.TracingModel} tracingModel |
| 10 */ | 10 */ |
| 11 WebInspector.FilmStripModel = function(tracingModel) | 11 WebInspector.FilmStripModel = function(tracingModel) |
| 12 { | 12 { |
| 13 this._tracingModel = tracingModel; | 13 this._tracingModel = tracingModel; |
| 14 | 14 |
| 15 /** @type {!Array<!WebInspector.FilmStripModel.Frame>} */ | 15 /** @type {!Array<!WebInspector.FilmStripModel.Frame>} */ |
| 16 this._frames = []; | 16 this._frames = []; |
| 17 | 17 |
| 18 var browserProcess = tracingModel.processByName("Browser"); | 18 var browserProcess = tracingModel.processByName("Browser"); |
| 19 if (!browserProcess) | 19 if (!browserProcess) |
| 20 return; | 20 return; |
| 21 var mainThread = browserProcess.threadByName("CrBrowserMain"); | 21 var mainThread = browserProcess.threadByName("CrBrowserMain"); |
| 22 if (!mainThread) | 22 if (!mainThread) |
| 23 return; | 23 return; |
| 24 | 24 |
| 25 var events = mainThread.events(); | 25 var events = mainThread.events(); |
| 26 for (var i = 0; i < events.length; ++i) { | 26 for (var i = 0; i < events.length; ++i) { |
| 27 if (events[i].category !== "disabled-by-default-devtools.screenshot") | 27 if (!events[i].hasCategory(WebInspector.FilmStripModel._category)) |
| 28 continue; | 28 continue; |
| 29 | 29 |
| 30 if (events[i].name === WebInspector.FilmStripModel.TraceEvents.CaptureFr
ame) { | 30 if (events[i].name === WebInspector.FilmStripModel.TraceEvents.CaptureFr
ame) { |
| 31 var data = events[i].args["data"]; | 31 var data = events[i].args["data"]; |
| 32 if (data) | 32 if (data) |
| 33 this._frames.push(WebInspector.FilmStripModel.Frame._fromEvent(t
his, events[i], this._frames.length)); | 33 this._frames.push(WebInspector.FilmStripModel.Frame._fromEvent(t
his, events[i], this._frames.length)); |
| 34 } else if (events[i].name === WebInspector.FilmStripModel.TraceEvents.Sc
reenshot) { | 34 } else if (events[i].name === WebInspector.FilmStripModel.TraceEvents.Sc
reenshot) { |
| 35 this._frames.push(WebInspector.FilmStripModel.Frame._fromSnapshot(th
is, /** @type {!WebInspector.TracingModel.ObjectSnapshot} */ (events[i]), this._
frames.length)); | 35 this._frames.push(WebInspector.FilmStripModel.Frame._fromSnapshot(th
is, /** @type {!WebInspector.TracingModel.ObjectSnapshot} */ (events[i]), this._
frames.length)); |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 WebInspector.FilmStripModel._category = "disabled-by-default-devtools.screenshot
"; |
| 41 |
| 40 WebInspector.FilmStripModel.TraceEvents = { | 42 WebInspector.FilmStripModel.TraceEvents = { |
| 41 CaptureFrame: "CaptureFrame", | 43 CaptureFrame: "CaptureFrame", |
| 42 Screenshot: "Screenshot" | 44 Screenshot: "Screenshot" |
| 43 } | 45 } |
| 44 | 46 |
| 45 WebInspector.FilmStripModel.prototype = { | 47 WebInspector.FilmStripModel.prototype = { |
| 46 /** | 48 /** |
| 47 * @return {!Array<!WebInspector.FilmStripModel.Frame>} | 49 * @return {!Array<!WebInspector.FilmStripModel.Frame>} |
| 48 */ | 50 */ |
| 49 frames: function() | 51 frames: function() |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 * @return {!Promise<?string>} | 137 * @return {!Promise<?string>} |
| 136 */ | 138 */ |
| 137 imageDataPromise: function() | 139 imageDataPromise: function() |
| 138 { | 140 { |
| 139 if (this._imageData || !this._snapshot) | 141 if (this._imageData || !this._snapshot) |
| 140 return Promise.resolve(this._imageData); | 142 return Promise.resolve(this._imageData); |
| 141 | 143 |
| 142 return /** @type {!Promise<?string>} */ (this._snapshot.objectPromise())
; | 144 return /** @type {!Promise<?string>} */ (this._snapshot.objectPromise())
; |
| 143 } | 145 } |
| 144 } | 146 } |
| OLD | NEW |