OLD | NEW |
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 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) { |
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::RecordEnumeratedHistogram(const std::string& name, |
| 753 int sample, |
| 754 int boundary_value) { |
| 755 if (!(boundary_value >= 0 && boundary_value < 100 && sample >= 0 && |
| 756 sample < boundary_value)) { |
| 757 frontend_host_->BadMessageRecieved(); |
| 758 return; |
| 759 } |
| 760 // Each histogram name must follow a different code path in |
| 761 // order to UMA_HISTOGRAM_ENUMERATION work correctly. |
| 762 if (name == kDevToolsActionTakenHistogram) |
| 763 UMA_HISTOGRAM_ENUMERATION(name, sample, boundary_value); |
| 764 else if (name == kDevToolsPanelShownHistogram) |
| 765 UMA_HISTOGRAM_ENUMERATION(name, sample, boundary_value); |
| 766 else |
| 767 frontend_host_->BadMessageRecieved(); |
| 768 } |
| 769 |
752 void DevToolsUIBindings::SendJsonRequest(const DispatchCallback& callback, | 770 void DevToolsUIBindings::SendJsonRequest(const DispatchCallback& callback, |
753 const std::string& browser_id, | 771 const std::string& browser_id, |
754 const std::string& url) { | 772 const std::string& url) { |
755 if (!android_bridge_) { | 773 if (!android_bridge_) { |
756 callback.Run(nullptr); | 774 callback.Run(nullptr); |
757 return; | 775 return; |
758 } | 776 } |
759 android_bridge_->SendJsonRequest(browser_id, url, | 777 android_bridge_->SendJsonRequest(browser_id, url, |
760 base::Bind(&DevToolsUIBindings::JsonReceived, | 778 base::Bind(&DevToolsUIBindings::JsonReceived, |
761 weak_factory_.GetWeakPtr(), | 779 weak_factory_.GetWeakPtr(), |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 if (frontend_loaded_) | 1028 if (frontend_loaded_) |
1011 return; | 1029 return; |
1012 frontend_loaded_ = true; | 1030 frontend_loaded_ = true; |
1013 | 1031 |
1014 // Call delegate first - it seeds importants bit of information. | 1032 // Call delegate first - it seeds importants bit of information. |
1015 delegate_->OnLoadCompleted(); | 1033 delegate_->OnLoadCompleted(); |
1016 | 1034 |
1017 UpdateTheme(); | 1035 UpdateTheme(); |
1018 AddDevToolsExtensionsToClient(); | 1036 AddDevToolsExtensionsToClient(); |
1019 } | 1037 } |
OLD | NEW |