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

Side by Side Diff: components/app_modal/javascript_dialog_manager.cc

Issue 1732563002: Include suppressed dialogs in the FineTiming histogram (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2623
Patch Set: Created 4 years, 10 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
« no previous file with comments | « components/app_modal/javascript_app_modal_dialog.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "components/app_modal/javascript_dialog_manager.h" 5 #include "components/app_modal/javascript_dialog_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 const base::string16& message_text, 87 const base::string16& message_text,
88 const base::string16& default_prompt_text, 88 const base::string16& default_prompt_text,
89 const DialogClosedCallback& callback, 89 const DialogClosedCallback& callback,
90 bool* did_suppress_message) { 90 bool* did_suppress_message) {
91 *did_suppress_message = false; 91 *did_suppress_message = false;
92 92
93 ChromeJavaScriptDialogExtraData* extra_data = 93 ChromeJavaScriptDialogExtraData* extra_data =
94 &javascript_dialog_extra_data_[web_contents]; 94 &javascript_dialog_extra_data_[web_contents];
95 95
96 if (extra_data->suppress_javascript_messages_) { 96 if (extra_data->suppress_javascript_messages_) {
97 // If a page tries to open dialogs in a tight loop, the number of
98 // suppressions logged can grow out of control. Arbitrarily cap the number
99 // logged at 100. That many suppressed dialogs is enough to indicate the
100 // page is doing something very hinky.
101 if (extra_data->suppressed_dialog_count_ < 100) {
102 // Log a suppressed dialog as one that opens and then closes immediately.
103 UMA_HISTOGRAM_MEDIUM_TIMES(
104 "JSDialogs.FineTiming.TimeBetweenDialogCreatedAndSameDialogClosed",
105 base::TimeDelta());
106
107 // Only increment the count if it's not already at the limit, to prevent
108 // overflow.
109 extra_data->suppressed_dialog_count_++;
110 }
111
97 *did_suppress_message = true; 112 *did_suppress_message = true;
98 return; 113 return;
99 } 114 }
100 115
101 base::TimeTicks now = base::TimeTicks::Now(); 116 base::TimeTicks now = base::TimeTicks::Now();
102 if (!last_creation_time_.is_null()) { 117 if (!last_creation_time_.is_null()) {
103 // A new dialog has been created: log the time since the last one was 118 // A new dialog has been created: log the time since the last one was
104 // created. 119 // created.
105 UMA_HISTOGRAM_MEDIUM_TIMES( 120 UMA_HISTOGRAM_MEDIUM_TIMES(
106 "JSDialogs.FineTiming.TimeBetweenDialogCreatedAndNextDialogCreated", 121 "JSDialogs.FineTiming.TimeBetweenDialogCreatedAndNextDialogCreated",
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // lazy background page after the dialog closes. (Dialogs are closed before 276 // lazy background page after the dialog closes. (Dialogs are closed before
262 // their WebContents is destroyed so |web_contents| is still valid here.) 277 // their WebContents is destroyed so |web_contents| is still valid here.)
263 extensions_client_->OnDialogClosed(web_contents); 278 extensions_client_->OnDialogClosed(web_contents);
264 279
265 last_close_time_ = base::TimeTicks::Now(); 280 last_close_time_ = base::TimeTicks::Now();
266 281
267 callback.Run(success, user_input); 282 callback.Run(success, user_input);
268 } 283 }
269 284
270 } // namespace app_modal 285 } // namespace app_modal
OLDNEW
« no previous file with comments | « components/app_modal/javascript_app_modal_dialog.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698