Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / devtools / front_end / sdk / TimelineManager.js
index 73f767c..0891ce4 100644 (file)
 
 /**
  * @constructor
- * @extends {WebInspector.TargetAwareObject}
+ * @extends {WebInspector.SDKModel}
  * @param {!WebInspector.Target} target
  */
 WebInspector.TimelineManager = function(target)
 {
-    WebInspector.TargetAwareObject.call(this, target);
+    WebInspector.SDKModel.call(this, WebInspector.TimelineManager, target);
     this._dispatcher = new WebInspector.TimelineDispatcher(this);
     this._enablementCount = 0;
     this._jsProfilerStarted = false;
-    TimelineAgent.enable();
+    target.timelineAgent().enable();
 }
 
 WebInspector.TimelineManager.EventTypes = {
@@ -60,23 +60,22 @@ WebInspector.TimelineManager.prototype = {
 
     /**
      * @param {number=} maxCallStackDepth
-     * @param {boolean=} bufferEvents
      * @param {string=} liveEvents
      * @param {boolean=} includeCounters
      * @param {boolean=} includeGPUEvents
      * @param {function(?Protocol.Error)=} callback
      */
-    start: function(maxCallStackDepth, bufferEvents, liveEvents, includeCounters, includeGPUEvents, callback)
+    start: function(maxCallStackDepth, liveEvents, includeCounters, includeGPUEvents, callback)
     {
         this._enablementCount++;
-        this.target().profilingLock.acquire();
+        WebInspector.profilingLock().acquire();
         if (WebInspector.experimentsSettings.timelineJSCPUProfile.isEnabled() && maxCallStackDepth) {
             this._configureCpuProfilerSamplingInterval();
             this._jsProfilerStarted = true;
-            ProfilerAgent.start();
+            this.target().profilerAgent().start();
         }
         if (this._enablementCount === 1)
-            TimelineAgent.start(maxCallStackDepth, bufferEvents, liveEvents, includeCounters, includeGPUEvents, callback);
+            this.target().timelineAgent().start(maxCallStackDepth, true, liveEvents, includeCounters, includeGPUEvents, callback);
         else if (callback)
             callback(null);
     },
@@ -97,13 +96,13 @@ WebInspector.TimelineManager.prototype = {
         var callbackBarrier = new CallbackBarrier();
 
         if (this._jsProfilerStarted) {
-            ProfilerAgent.stop(callbackBarrier.createCallback(profilerCallback));
+            this.target().profilerAgent().stop(callbackBarrier.createCallback(profilerCallback));
             this._jsProfilerStarted = false;
         }
         if (!this._enablementCount)
-            TimelineAgent.stop(callbackBarrier.createCallback(this._processBufferedEvents.bind(this, timelineCallback)));
+            this.target().timelineAgent().stop(callbackBarrier.createCallback(timelineCallback));
 
-        callbackBarrier.callWhenDone(allDoneCallback.bind(this));
+        callbackBarrier.callWhenDone(allDoneCallback);
 
         /**
          * @param {?Protocol.Error} error
@@ -123,47 +122,39 @@ WebInspector.TimelineManager.prototype = {
             masterProfile = profile;
         }
 
-        /**
-         * @this {WebInspector.TimelineManager}
-         */
         function allDoneCallback()
         {
-            this.target().profilingLock.release();
+            WebInspector.profilingLock().release();
             callback(masterError, masterProfile);
         }
     },
 
     /**
-     * @param {function(?Protocol.Error)|undefined} callback
-     * @param {?Protocol.Error} error
+     * @param {boolean=} consoleTimeline
      * @param {!Array.<!TimelineAgent.TimelineEvent>=} events
      */
-    _processBufferedEvents: function(callback, error, events)
+    _stopped: function(consoleTimeline, events)
     {
-        if (events) {
-            for (var i = 0; i < events.length; ++i)
-                this._dispatcher.eventRecorded(events[i]);
-        }
-        if (callback)
-            callback(error);
+        var data = {
+            consoleTimeline: consoleTimeline,
+            events: events || []
+        };
+        this.dispatchEventToListeners(WebInspector.TimelineManager.EventTypes.TimelineStopped, data);
     },
 
     _configureCpuProfilerSamplingInterval: function()
     {
         var intervalUs = WebInspector.settings.highResolutionCpuProfiling.get() ? 100 : 1000;
-        ProfilerAgent.setSamplingInterval(intervalUs, didChangeInterval.bind(this));
+        this.target().profilerAgent().setSamplingInterval(intervalUs, didChangeInterval);
 
-        /**
-         * @this {WebInspector.TimelineManager}
-         */
         function didChangeInterval(error)
         {
             if (error)
-                this.target().consoleModel.showErrorMessage(error);
+                WebInspector.console.error(error);
         }
     },
 
-    __proto__: WebInspector.TargetAwareObject.prototype
+    __proto__: WebInspector.SDKModel.prototype
 }
 
 /**
@@ -173,7 +164,7 @@ WebInspector.TimelineManager.prototype = {
 WebInspector.TimelineDispatcher = function(manager)
 {
     this._manager = manager;
-    InspectorBackend.registerTimelineDispatcher(this);
+    this._manager.target().registerTimelineDispatcher(this);
 }
 
 WebInspector.TimelineDispatcher.prototype = {
@@ -200,7 +191,7 @@ WebInspector.TimelineDispatcher.prototype = {
     {
         if (consoleTimeline) {
             // Wake up timeline panel module.
-            WebInspector.moduleManager.loadModule("timeline");
+            self.runtime.loadModule("timeline");
         }
         this._started = true;
         this._manager.dispatchEventToListeners(WebInspector.TimelineManager.EventTypes.TimelineStarted, consoleTimeline);
@@ -208,11 +199,12 @@ WebInspector.TimelineDispatcher.prototype = {
 
     /**
      * @param {boolean=} consoleTimeline
+     * @param {!Array.<!TimelineAgent.TimelineEvent>=} events
      */
-    stopped: function(consoleTimeline)
+    stopped: function(consoleTimeline, events)
     {
         this._started = false;
-        this._manager.dispatchEventToListeners(WebInspector.TimelineManager.EventTypes.TimelineStopped, consoleTimeline);
+        this._manager._stopped(consoleTimeline, events);
     },
 
     /**
@@ -223,8 +215,3 @@ WebInspector.TimelineDispatcher.prototype = {
         this._manager.dispatchEventToListeners(WebInspector.TimelineManager.EventTypes.TimelineProgress, count);
     }
 }
-
-/**
- * @type {!WebInspector.TimelineManager}
- */
-WebInspector.timelineManager;