Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_METRICS_PRIVATE_METRICS_PRIVATE_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_METRICS_PRIVATE_METRICS_PRIVATE_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_METRICS_PRIVATE_METRICS_PRIVATE_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_METRICS_PRIVATE_METRICS_PRIVATE_API_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "extensions/browser/browser_context_keyed_api_factory.h" | |
| 13 #include "extensions/browser/extension_function.h" | 14 #include "extensions/browser/extension_function.h" |
| 14 | 15 |
| 16 namespace content { | |
| 17 class BrowserContext; | |
| 18 } // namespace content | |
| 19 | |
| 15 namespace extensions { | 20 namespace extensions { |
| 16 | 21 |
| 22 class MetricsPrivateDelegate; | |
| 23 | |
| 17 class MetricsPrivateGetIsCrashReportingEnabledFunction | 24 class MetricsPrivateGetIsCrashReportingEnabledFunction |
| 18 : public UIThreadExtensionFunction { | 25 : public UIThreadExtensionFunction { |
| 19 public: | 26 public: |
| 20 DECLARE_EXTENSION_FUNCTION("metricsPrivate.getIsCrashReportingEnabled", | 27 DECLARE_EXTENSION_FUNCTION("metricsPrivate.getIsCrashReportingEnabled", |
| 21 METRICSPRIVATE_GETISCRASHRECORDINGENABLED) | 28 METRICSPRIVATE_GETISCRASHRECORDINGENABLED) |
| 22 | 29 |
| 23 protected: | 30 protected: |
| 24 ~MetricsPrivateGetIsCrashReportingEnabledFunction() override {} | 31 ~MetricsPrivateGetIsCrashReportingEnabledFunction() override {} |
| 25 | 32 |
| 26 // ExtensionFunction: | 33 // ExtensionFunction: |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 DECLARE_EXTENSION_FUNCTION("metricsPrivate.recordLongTime", | 192 DECLARE_EXTENSION_FUNCTION("metricsPrivate.recordLongTime", |
| 186 METRICSPRIVATE_RECORDLONGTIME) | 193 METRICSPRIVATE_RECORDLONGTIME) |
| 187 | 194 |
| 188 protected: | 195 protected: |
| 189 ~MetricsPrivateRecordLongTimeFunction() override {} | 196 ~MetricsPrivateRecordLongTimeFunction() override {} |
| 190 | 197 |
| 191 // ExtensionFunction: | 198 // ExtensionFunction: |
| 192 ResponseAction Run() override; | 199 ResponseAction Run() override; |
| 193 }; | 200 }; |
| 194 | 201 |
| 202 class MetricsPrivateAPI : public BrowserContextKeyedAPI { | |
|
Rahul Chaturvedi
2016/09/16 23:11:04
Is this needed? Our delegate isn't context specifi
michaelpg
2016/09/16 23:51:56
Good point. We could make the ExtensionAPIClient i
Rahul Chaturvedi
2016/09/19 18:11:09
ExtensionsAPIClient::Get() returns the the correct
michaelpg
2016/09/19 18:36:32
We do this a lot for platform-specific functionali
Rahul Chaturvedi
2016/09/19 19:13:17
So in 'this' particular situation, a few reasons t
| |
| 203 public: | |
| 204 explicit MetricsPrivateAPI(content::BrowserContext* context); | |
| 205 ~MetricsPrivateAPI() override; | |
| 206 | |
| 207 // BrowserContextKeyedAPI: | |
| 208 static BrowserContextKeyedAPIFactory<MetricsPrivateAPI>* GetFactoryInstance(); | |
| 209 | |
| 210 MetricsPrivateDelegate* delegate() { return delegate_.get(); } | |
| 211 | |
| 212 private: | |
| 213 friend class BrowserContextKeyedAPIFactory<MetricsPrivateAPI>; | |
| 214 | |
| 215 // BrowserContextKeyedAPI: | |
| 216 static const char* service_name() { return "MetricsPrivateAPI"; } | |
| 217 | |
| 218 std::unique_ptr<MetricsPrivateDelegate> delegate_; | |
| 219 }; | |
| 220 | |
| 195 } // namespace extensions | 221 } // namespace extensions |
| 196 | 222 |
| 197 #endif // CHROME_BROWSER_EXTENSIONS_API_METRICS_PRIVATE_METRICS_PRIVATE_API_H_ | 223 #endif // CHROME_BROWSER_EXTENSIONS_API_METRICS_PRIVATE_METRICS_PRIVATE_API_H_ |
| OLD | NEW |