| 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 #ifndef CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ |
| 6 #define CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ | 6 #define CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 15 #include "chrome/browser/metrics/network_stats_uploader.h" | 15 #include "chrome/browser/metrics/network_stats_uploader.h" |
| 16 #include "components/metrics/metrics_service_client.h" | 16 #include "components/metrics/metrics_service_client.h" |
| 17 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
| 18 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 19 | 19 |
| 20 class ChromeOSMetricsProvider; |
| 20 class MetricsService; | 21 class MetricsService; |
| 21 | 22 |
| 22 namespace metrics { | 23 namespace metrics { |
| 23 class MetricsStateManager; | 24 class MetricsStateManager; |
| 24 } | 25 } |
| 25 | 26 |
| 26 // ChromeMetricsServiceClient provides an implementation of MetricsServiceClient | 27 // ChromeMetricsServiceClient provides an implementation of MetricsServiceClient |
| 27 // that depends on chrome/. | 28 // that depends on chrome/. |
| 28 class ChromeMetricsServiceClient : public metrics::MetricsServiceClient, | 29 class ChromeMetricsServiceClient : public metrics::MetricsServiceClient, |
| 29 public content::NotificationObserver { | 30 public content::NotificationObserver { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 46 const base::Closure& done_callback) OVERRIDE; | 47 const base::Closure& done_callback) OVERRIDE; |
| 47 virtual void CollectFinalMetrics(const base::Closure& done_callback) | 48 virtual void CollectFinalMetrics(const base::Closure& done_callback) |
| 48 OVERRIDE; | 49 OVERRIDE; |
| 49 | 50 |
| 50 MetricsService* metrics_service() { return metrics_service_.get(); } | 51 MetricsService* metrics_service() { return metrics_service_.get(); } |
| 51 | 52 |
| 52 private: | 53 private: |
| 53 explicit ChromeMetricsServiceClient( | 54 explicit ChromeMetricsServiceClient( |
| 54 metrics::MetricsStateManager* state_manager); | 55 metrics::MetricsStateManager* state_manager); |
| 55 | 56 |
| 57 // First part of the init task. Called on the FILE thread to load hardware |
| 58 // class information. When this task is complete, |done_callback| is run on |
| 59 // |target_loop|. |
| 60 void InitTaskGetHardwareClass(base::MessageLoopProxy* target_loop, |
| 61 const base::Closure& done_callback); |
| 62 |
| 56 // Callbacks for various stages of final log info collection. Do not call | 63 // Callbacks for various stages of final log info collection. Do not call |
| 57 // these directly. | 64 // these directly. |
| 58 void OnMemoryDetailCollectionDone(); | 65 void OnMemoryDetailCollectionDone(); |
| 59 void OnHistogramSynchronizationDone(); | 66 void OnHistogramSynchronizationDone(); |
| 60 | 67 |
| 61 // Records metrics about the switches present on the command line. | 68 // Records metrics about the switches present on the command line. |
| 62 void RecordCommandLineMetrics(); | 69 void RecordCommandLineMetrics(); |
| 63 | 70 |
| 64 // Registers |this| as an observer for notifications which indicate that a | 71 // Registers |this| as an observer for notifications which indicate that a |
| 65 // user is performing work. This is useful to allow some features to sleep, | 72 // user is performing work. This is useful to allow some features to sleep, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 78 void CountBrowserCrashDumpAttempts(); | 85 void CountBrowserCrashDumpAttempts(); |
| 79 #endif // OS_WIN | 86 #endif // OS_WIN |
| 80 | 87 |
| 81 base::ThreadChecker thread_checker_; | 88 base::ThreadChecker thread_checker_; |
| 82 | 89 |
| 83 // The MetricsService that |this| is a client of. | 90 // The MetricsService that |this| is a client of. |
| 84 scoped_ptr<MetricsService> metrics_service_; | 91 scoped_ptr<MetricsService> metrics_service_; |
| 85 | 92 |
| 86 content::NotificationRegistrar registrar_; | 93 content::NotificationRegistrar registrar_; |
| 87 | 94 |
| 95 // On ChromeOS, holds a weak pointer to the ChromeOSMetricsProvider instance |
| 96 // that has been registered with MetricsService. On other platforms, is NULL. |
| 97 ChromeOSMetricsProvider* chromeos_metrics_provider_; |
| 98 |
| 88 NetworkStatsUploader network_stats_uploader_; | 99 NetworkStatsUploader network_stats_uploader_; |
| 89 | 100 |
| 90 // Saved callback received from CollectFinalMetrics(). | 101 // Saved callback received from CollectFinalMetrics(). |
| 91 base::Closure collect_final_metrics_done_callback_; | 102 base::Closure collect_final_metrics_done_callback_; |
| 92 | 103 |
| 93 // Indicates that collect final metrics step is running. | 104 // Indicates that collect final metrics step is running. |
| 94 bool waiting_for_collect_final_metrics_step_; | 105 bool waiting_for_collect_final_metrics_step_; |
| 95 | 106 |
| 96 // Number of async histogram fetch requests in progress. | 107 // Number of async histogram fetch requests in progress. |
| 97 int num_async_histogram_fetches_in_progress_; | 108 int num_async_histogram_fetches_in_progress_; |
| 98 | 109 |
| 99 base::WeakPtrFactory<ChromeMetricsServiceClient> weak_ptr_factory_; | 110 base::WeakPtrFactory<ChromeMetricsServiceClient> weak_ptr_factory_; |
| 100 | 111 |
| 101 DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServiceClient); | 112 DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServiceClient); |
| 102 }; | 113 }; |
| 103 | 114 |
| 104 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ | 115 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ |
| OLD | NEW |