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

Side by Side Diff: chrome/browser/devtools/devtools_ui_bindings.cc

Issue 1056073003: DevTools: introduce RecordEnumeratedHistogram method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix styling Created 5 years, 8 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 | « chrome/browser/devtools/devtools_ui_bindings.h ('k') | content/browser/bad_message.h » ('j') | 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 "chrome/browser/devtools/devtools_ui_bindings.h" 5 #include "chrome/browser/devtools/devtools_ui_bindings.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 } else { 735 } else {
736 remote_targets_handler_.reset(); 736 remote_targets_handler_.reset();
737 } 737 }
738 } 738 }
739 739
740 void DevToolsUIBindings::SendMessageToBrowser(const std::string& message) { 740 void DevToolsUIBindings::SendMessageToBrowser(const std::string& message) {
741 if (agent_host_.get()) 741 if (agent_host_.get())
742 agent_host_->DispatchProtocolMessage(message); 742 agent_host_->DispatchProtocolMessage(message);
743 } 743 }
744 744
745 void DevToolsUIBindings::RecordActionUMA(const std::string& name, int action) { 745 void DevToolsUIBindings::RecordActionUMA(const std::string& name, int action) {
Ilya Sherman 2015/04/06 23:31:21 What is the backward compatibility reason that mak
lushnikov 2015/04/07 13:51:03 I updated issue description; they will be removed
746 if (name == kDevToolsActionTakenHistogram) 746 if (name == kDevToolsActionTakenHistogram)
747 UMA_HISTOGRAM_ENUMERATION(name, action, kDevToolsActionTakenBoundary); 747 UMA_HISTOGRAM_ENUMERATION(name, action, kDevToolsActionTakenBoundary);
748 else if (name == kDevToolsPanelShownHistogram) 748 else if (name == kDevToolsPanelShownHistogram)
749 UMA_HISTOGRAM_ENUMERATION(name, action, kDevToolsPanelShownBoundary); 749 UMA_HISTOGRAM_ENUMERATION(name, action, kDevToolsPanelShownBoundary);
750 } 750 }
751 751
752 void DevToolsUIBindings::RecordUMA(const std::string& name,
Ilya Sherman 2015/04/06 23:31:21 nit: I would name this method "RecordEnumeratedHis
lushnikov 2015/04/07 13:51:03 Done.
753 int action,
754 int bucket_size) {
Ilya Sherman 2015/04/06 23:31:22 nit: I would name these parameters |sample| and |b
lushnikov 2015/04/07 13:51:03 Done.
755 bool valid_name = name == kDevToolsActionTakenHistogram ||
756 name == kDevToolsPanelShownHistogram;
757 if (bucket_size >= 0 && bucket_size < 100 &&
758 action >= 0 && action < bucket_size && valid_name) {
759 UMA_HISTOGRAM_ENUMERATION(name, action, bucket_size);
Ilya Sherman 2015/04/06 23:31:22 Optional: It might be cleaner to write this method
Ilya Sherman 2015/04/06 23:31:22 This will not work. If you use the macros, you mu
lushnikov 2015/04/07 13:51:03 Every early return will have a body of two lines (
lushnikov 2015/04/07 13:51:03 The name is guaranteed to be one of the constants
Ilya Sherman 2015/04/07 21:45:08 RecordActionUMA has an if/else, which guarantees t
lushnikov 2015/04/07 23:03:07 Done.
760 } else {
761 frontend_host_->BadMessageRecieved();
762 }
763 }
764
752 void DevToolsUIBindings::SendJsonRequest(const DispatchCallback& callback, 765 void DevToolsUIBindings::SendJsonRequest(const DispatchCallback& callback,
753 const std::string& browser_id, 766 const std::string& browser_id,
754 const std::string& url) { 767 const std::string& url) {
755 if (!android_bridge_) { 768 if (!android_bridge_) {
756 callback.Run(nullptr); 769 callback.Run(nullptr);
757 return; 770 return;
758 } 771 }
759 android_bridge_->SendJsonRequest(browser_id, url, 772 android_bridge_->SendJsonRequest(browser_id, url,
760 base::Bind(&DevToolsUIBindings::JsonReceived, 773 base::Bind(&DevToolsUIBindings::JsonReceived,
761 weak_factory_.GetWeakPtr(), 774 weak_factory_.GetWeakPtr(),
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 if (frontend_loaded_) 1023 if (frontend_loaded_)
1011 return; 1024 return;
1012 frontend_loaded_ = true; 1025 frontend_loaded_ = true;
1013 1026
1014 // Call delegate first - it seeds importants bit of information. 1027 // Call delegate first - it seeds importants bit of information.
1015 delegate_->OnLoadCompleted(); 1028 delegate_->OnLoadCompleted();
1016 1029
1017 UpdateTheme(); 1030 UpdateTheme();
1018 AddDevToolsExtensionsToClient(); 1031 AddDevToolsExtensionsToClient();
1019 } 1032 }
OLDNEW
« no previous file with comments | « chrome/browser/devtools/devtools_ui_bindings.h ('k') | content/browser/bad_message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698