Home | History | Annotate | Download | only in trace_model
      1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 'use strict';
      6 
      7 base.require('tracing.trace_model.slice');
      8 
      9 /**
     10  * @fileoverview Provides the AsyncSlice class.
     11  */
     12 base.exportTo('tracing.trace_model', function() {
     13   /**
     14    * A AsyncSlice represents an interval of time during which an
     15    * asynchronous operation is in progress. An AsyncSlice consumes no CPU time
     16    * itself and so is only associated with Threads at its start and end point.
     17    *
     18    * @constructor
     19    */
     20   function AsyncSlice(category, title, colorId, start, args) {
     21     tracing.trace_model.Slice.apply(this, arguments);
     22   };
     23 
     24   AsyncSlice.prototype = {
     25     __proto__: tracing.trace_model.Slice.prototype,
     26 
     27     toJSON: function() {
     28       var obj = new Object();
     29       var keys = Object.keys(this);
     30       for (var i = 0; i < keys.length; i++) {
     31         var key = keys[i];
     32         if (typeof this[key] == 'function')
     33           continue;
     34         if (key == 'startThread' || key == 'endThread') {
     35           obj[key] = this[key].guid;
     36           continue;
     37         }
     38         obj[key] = this[key];
     39       }
     40       return obj;
     41     },
     42 
     43     id: undefined,
     44 
     45     startThread: undefined,
     46 
     47     endThread: undefined,
     48 
     49     subSlices: undefined
     50   };
     51 
     52   return {
     53     AsyncSlice: AsyncSlice
     54   };
     55 });
     56