summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/resources/net_internals/http_pipeline_view.js
blob: 14c35a642f1d2dad3e009566062e21331376d2ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/**
 * This view displays a summary of the state of each HTTP pipelined connection,
 * and has links to display them in the events tab.
 */
var HttpPipelineView = (function() {
  'use strict';

  // We inherit from DivView.
  var superClass = DivView;

  /**
   * @constructor
   */
  function HttpPipelineView() {
    assertFirstConstructorCall(HttpPipelineView);

    // Call superclass's constructor.
    superClass.call(this, HttpPipelineView.MAIN_BOX_ID);

    g_browser.addHttpPipeliningStatusObserver(this, true);
  }

  HttpPipelineView.TAB_ID = 'tab-handle-http-pipeline';
  HttpPipelineView.TAB_NAME = 'Pipelining';
  HttpPipelineView.TAB_HASH = '#httpPipeline';

  // IDs for special HTML elements in http_pipeline_view.html
  HttpPipelineView.MAIN_BOX_ID = 'http-pipeline-view-tab-content';
  HttpPipelineView.ENABLED_SPAN_ID = 'http-pipeline-view-enabled-span';
  HttpPipelineView.KNOWN_HOSTS_TABLE_ID =
      'http-pipeline-view-known-hosts-table';

  cr.addSingletonGetter(HttpPipelineView);

  HttpPipelineView.prototype = {
    // Inherit the superclass's methods.
    __proto__: superClass.prototype,

    onLoadLogFinish: function(data) {
      return this.onHttpPipeliningStatusChanged(data.httpPipeliningStatus);
    },

    /**
     * Displays information on the global HTTP pipelining status.
     */
    onHttpPipeliningStatusChanged: function(httpPipeliningStatus) {
      if (!httpPipeliningStatus)
        return false;
      var input = new JsEvalContext(httpPipeliningStatus);
      jstProcess(input, $(HttpPipelineView.MAIN_BOX_ID));
      // Hide view in loaded logs if pipelining isn't enabled.
      return httpPipeliningStatus.pipelining_enabled;
    },
  };

  return HttpPipelineView;
})();