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

Side by Side Diff: chrome/browser/metrics/chrome_metrics_service_client.h

Issue 293393010: Move initial metrics gathering tasks out of MetricsService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes Created 6 years, 7 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
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 #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 "chrome/browser/metrics/tracking_synchronizer_observer.h"
16 #include "components/metrics/metrics_service_client.h" 17 #include "components/metrics/metrics_service_client.h"
17 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
19 20
20 class ChromeOSMetricsProvider; 21 class ChromeOSMetricsProvider;
22 class GoogleUpdateMetricsProviderWin;
21 class MetricsService; 23 class MetricsService;
24 class PluginMetricsProvider;
22 25
23 namespace metrics { 26 namespace metrics {
24 class MetricsStateManager; 27 class MetricsStateManager;
25 } 28 }
26 29
27 // ChromeMetricsServiceClient provides an implementation of MetricsServiceClient 30 // ChromeMetricsServiceClient provides an implementation of MetricsServiceClient
28 // that depends on chrome/. 31 // that depends on chrome/.
29 class ChromeMetricsServiceClient : public metrics::MetricsServiceClient, 32 class ChromeMetricsServiceClient
30 public content::NotificationObserver { 33 : public metrics::MetricsServiceClient,
34 public chrome_browser_metrics::TrackingSynchronizerObserver,
35 public content::NotificationObserver {
31 public: 36 public:
32 virtual ~ChromeMetricsServiceClient(); 37 virtual ~ChromeMetricsServiceClient();
33 38
34 // Factory function. 39 // Factory function.
35 static scoped_ptr<ChromeMetricsServiceClient> Create( 40 static scoped_ptr<ChromeMetricsServiceClient> Create(
36 metrics::MetricsStateManager* state_manager); 41 metrics::MetricsStateManager* state_manager);
37 42
38 // metrics::MetricsServiceClient: 43 // metrics::MetricsServiceClient:
39 virtual void SetClientID(const std::string& client_id) OVERRIDE; 44 virtual void SetClientID(const std::string& client_id) OVERRIDE;
40 virtual bool IsOffTheRecordSessionActive() OVERRIDE; 45 virtual bool IsOffTheRecordSessionActive() OVERRIDE;
41 virtual std::string GetApplicationLocale() OVERRIDE; 46 virtual std::string GetApplicationLocale() OVERRIDE;
42 virtual bool GetBrand(std::string* brand_code) OVERRIDE; 47 virtual bool GetBrand(std::string* brand_code) OVERRIDE;
43 virtual metrics::SystemProfileProto::Channel GetChannel() OVERRIDE; 48 virtual metrics::SystemProfileProto::Channel GetChannel() OVERRIDE;
44 virtual std::string GetVersionString() OVERRIDE; 49 virtual std::string GetVersionString() OVERRIDE;
45 virtual void OnLogUploadComplete() OVERRIDE; 50 virtual void OnLogUploadComplete() OVERRIDE;
46 virtual void StartGatheringMetrics( 51 virtual void StartGatheringMetrics(
47 const base::Closure& done_callback) OVERRIDE; 52 const base::Closure& done_callback) OVERRIDE;
48 virtual void CollectFinalMetrics(const base::Closure& done_callback) 53 virtual void CollectFinalMetrics(const base::Closure& done_callback)
49 OVERRIDE; 54 OVERRIDE;
50 55
51 MetricsService* metrics_service() { return metrics_service_.get(); } 56 MetricsService* metrics_service() { return metrics_service_.get(); }
52 57
58 PluginMetricsProvider* plugin_metrics_provider() {
59 return plugin_metrics_provider_;
60 }
61
53 private: 62 private:
54 explicit ChromeMetricsServiceClient( 63 explicit ChromeMetricsServiceClient(
55 metrics::MetricsStateManager* state_manager); 64 metrics::MetricsStateManager* state_manager);
56 65
66 // TrackingSynchronizerObserver:
67 virtual void ReceivedProfilerData(
68 const tracked_objects::ProcessDataSnapshot& process_data,
69 int process_type) OVERRIDE;
70 virtual void FinishedReceivingProfilerData() OVERRIDE;
71
57 // First part of the init task. Called on the FILE thread to load hardware 72 // 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 73 // class information. When this task is complete,
59 // |target_loop|. 74 // |OnInitTaskGotHardwareClass()| is run on |target_loop|.
60 void InitTaskGetHardwareClass(base::MessageLoopProxy* target_loop, 75 void InitTaskGetHardwareClass(base::MessageLoopProxy* target_loop);
61 const base::Closure& done_callback); 76
77 // Callback that continues the init task by loading plugin information.
78 void OnInitTaskGotHardwareClass();
79
80 // Called after the Plugin init task has been completed that continues the
81 // init task by launching a task to gather Google Update statistics.
82 void OnInitTaskGotPluginInfo();
83
84 // Called after GoogleUpdate init task has been completed that continues the
85 // init task by loading profiler data.
86 void OnInitTaskGotGoogleUpdateData();
62 87
63 // Callbacks for various stages of final log info collection. Do not call 88 // Callbacks for various stages of final log info collection. Do not call
64 // these directly. 89 // these directly.
65 void OnMemoryDetailCollectionDone(); 90 void OnMemoryDetailCollectionDone();
66 void OnHistogramSynchronizationDone(); 91 void OnHistogramSynchronizationDone();
67 92
68 // Records metrics about the switches present on the command line. 93 // Records metrics about the switches present on the command line.
69 void RecordCommandLineMetrics(); 94 void RecordCommandLineMetrics();
70 95
71 // Registers |this| as an observer for notifications which indicate that a 96 // Registers |this| as an observer for notifications which indicate that a
(...skipping 28 matching lines...) Expand all
100 125
101 // Saved callback received from CollectFinalMetrics(). 126 // Saved callback received from CollectFinalMetrics().
102 base::Closure collect_final_metrics_done_callback_; 127 base::Closure collect_final_metrics_done_callback_;
103 128
104 // Indicates that collect final metrics step is running. 129 // Indicates that collect final metrics step is running.
105 bool waiting_for_collect_final_metrics_step_; 130 bool waiting_for_collect_final_metrics_step_;
106 131
107 // Number of async histogram fetch requests in progress. 132 // Number of async histogram fetch requests in progress.
108 int num_async_histogram_fetches_in_progress_; 133 int num_async_histogram_fetches_in_progress_;
109 134
135 PluginMetricsProvider* plugin_metrics_provider_;
136
137 #if defined(OS_WIN)
138 GoogleUpdateMetricsProviderWin* google_update_metrics_provider_;
139 #endif
140
141 // Callback that is called when initial metrics gathering is complete.
142 base::Closure finished_gathering_initial_metrics_callback_;
143
110 base::WeakPtrFactory<ChromeMetricsServiceClient> weak_ptr_factory_; 144 base::WeakPtrFactory<ChromeMetricsServiceClient> weak_ptr_factory_;
111 145
112 DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServiceClient); 146 DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServiceClient);
113 }; 147 };
114 148
115 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ 149 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698