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

Side by Side Diff: chrome/browser/resources/net_internals/capture_view.js

Issue 9585027: Limit the number of captured events held by about:net-internals. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address mmenke comments Created 8 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 * This view displays controls for capturing network events. 6 * This view displays controls for capturing network events.
7 */ 7 */
8 var CaptureView = (function() { 8 var CaptureView = (function() {
9 'use strict'; 9 'use strict';
10 10
11 // We inherit from DivView. 11 // We inherit from DivView.
12 var superClass = DivView; 12 var superClass = DivView;
13 13
14 /** 14 /**
15 * @constructor 15 * @constructor
16 */ 16 */
17 function CaptureView() { 17 function CaptureView() {
18 assertFirstConstructorCall(CaptureView); 18 assertFirstConstructorCall(CaptureView);
19 19
20 // Call superclass's constructor. 20 // Call superclass's constructor.
21 superClass.call(this, CaptureView.MAIN_BOX_ID); 21 superClass.call(this, CaptureView.MAIN_BOX_ID);
22 22
23 var byteLoggingCheckbox = $(CaptureView.BYTE_LOGGING_CHECKBOX_ID); 23 var byteLoggingCheckbox = $(CaptureView.BYTE_LOGGING_CHECKBOX_ID);
24 byteLoggingCheckbox.onclick = 24 byteLoggingCheckbox.onclick = this.onSetByteLogging_.bind(this);
25 this.onSetByteLogging_.bind(this, byteLoggingCheckbox); 25
26 $(CaptureView.LIMIT_CHECKBOX_ID).onclick = this.onChangeLimit_.bind(this);
26 27
27 $(CaptureView.TIP_ANCHOR_ID).onclick = 28 $(CaptureView.TIP_ANCHOR_ID).onclick =
28 this.toggleCommandLineTip_.bind(this, CaptureView.TIP_DIV_ID); 29 this.toggleCommandLineTip_.bind(this, CaptureView.TIP_DIV_ID);
29 30
30 if (byteLoggingCheckbox.checked) { 31 if (byteLoggingCheckbox.checked) {
31 // The code to display a warning on ExportView relies on bytelogging 32 // The code to display a warning on ExportView relies on bytelogging
32 // being off by default. If this ever changes, the code will need to 33 // being off by default. If this ever changes, the code will need to
33 // be updated. 34 // be updated.
34 throw 'Not expecting byte logging to be enabled!'; 35 throw 'Not expecting byte logging to be enabled!';
35 } 36 }
37
38 this.onChangeLimit_();
36 } 39 }
37 40
38 // ID for special HTML element in category_tabs.html 41 // ID for special HTML element in category_tabs.html
39 CaptureView.TAB_HANDLE_ID = 'tab-handle-capture'; 42 CaptureView.TAB_HANDLE_ID = 'tab-handle-capture';
40 43
41 // IDs for special HTML elements in capture_view.html 44 // IDs for special HTML elements in capture_view.html
42 CaptureView.MAIN_BOX_ID = 'capture-view-tab-content'; 45 CaptureView.MAIN_BOX_ID = 'capture-view-tab-content';
43 CaptureView.BYTE_LOGGING_CHECKBOX_ID = 'capture-view-byte-logging-checkbox'; 46 CaptureView.BYTE_LOGGING_CHECKBOX_ID = 'capture-view-byte-logging-checkbox';
47 CaptureView.LIMIT_CHECKBOX_ID = 'capture-view-limit-checkbox';
44 CaptureView.TIP_ANCHOR_ID = 'capture-view-tip-anchor'; 48 CaptureView.TIP_ANCHOR_ID = 'capture-view-tip-anchor';
45 CaptureView.TIP_DIV_ID = 'capture-view-tip-div'; 49 CaptureView.TIP_DIV_ID = 'capture-view-tip-div';
46 50
47 cr.addSingletonGetter(CaptureView); 51 cr.addSingletonGetter(CaptureView);
48 52
49 CaptureView.prototype = { 53 CaptureView.prototype = {
50 // Inherit the superclass's methods. 54 // Inherit the superclass's methods.
51 __proto__: superClass.prototype, 55 __proto__: superClass.prototype,
52 56
53 /** 57 /**
(...skipping 12 matching lines...) Expand all
66 * be hidden. 70 * be hidden.
67 */ 71 */
68 onLoadLogFinish: function(data) { 72 onLoadLogFinish: function(data) {
69 return false; 73 return false;
70 }, 74 },
71 75
72 /** 76 /**
73 * Depending on the value of the checkbox, enables or disables logging of 77 * Depending on the value of the checkbox, enables or disables logging of
74 * actual bytes transferred. 78 * actual bytes transferred.
75 */ 79 */
76 onSetByteLogging_: function(byteLoggingCheckbox) { 80 onSetByteLogging_: function() {
81 var byteLoggingCheckbox = $(CaptureView.BYTE_LOGGING_CHECKBOX_ID);
82
77 if (byteLoggingCheckbox.checked) { 83 if (byteLoggingCheckbox.checked) {
78 g_browser.setLogLevel(LogLevelType.LOG_ALL); 84 g_browser.setLogLevel(LogLevelType.LOG_ALL);
79 85
80 // Once we enable byte logging, all bets are off on what gets captured. 86 // Once we enable byte logging, all bets are off on what gets captured.
81 // Have the export view warn that the "strip cookies" option is 87 // Have the export view warn that the "strip cookies" option is
82 // ineffective from this point on. 88 // ineffective from this point on.
83 // 89 //
84 // In theory we could clear this warning after unchecking the box and 90 // In theory we could clear this warning after unchecking the box and
85 // then deleting all the events which had been captured. We don't 91 // then deleting all the events which had been captured. We don't
86 // currently do that; if you want the warning to go away, will need to 92 // currently do that; if you want the warning to go away, will need to
87 // reload. 93 // reload.
88 ExportView.getInstance().showPrivacyWarning(); 94 ExportView.getInstance().showPrivacyWarning();
89 } else { 95 } else {
90 g_browser.setLogLevel(LogLevelType.LOG_ALL_BUT_BYTES); 96 g_browser.setLogLevel(LogLevelType.LOG_ALL_BUT_BYTES);
91 } 97 }
92 } 98 },
99
100 onChangeLimit_: function() {
101 var limitCheckbox = $(CaptureView.LIMIT_CHECKBOX_ID);
102
103 // Default to unlimited.
104 var softLimit = Infinity;
105 var hardLimit = Infinity;
106
107 if (limitCheckbox.checked) {
108 // The chosen limits are kind of arbitrary. I based it off the
109 // following observation:
110 // A user-submitted log file which spanned a 7 hour time period
111 // comprised 778,235 events and required 128MB of JSON.
112 //
113 // That feels too big. Assuming it was representative, then scaling
114 // by a factor of 4 should translate into a 32MB log file and cover
115 // close to 2 hours of events, which feels better.
116 //
117 // A large gap is left between the hardLimit and softLimit to avoid
118 // resetting the events often.
119 hardLimit = 300000;
120 softLimit = 150000;
121 }
122
123 EventsTracker.getInstance().setLimits(softLimit, hardLimit);
124 },
93 }; 125 };
94 126
95 return CaptureView; 127 return CaptureView;
96 })(); 128 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/net_internals/capture_view.html ('k') | chrome/browser/resources/net_internals/events_tracker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698