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 // This file defines a service that collects information about the user | 5 // This file defines a service that collects information about the user |
| 6 // experience in order to help improve future versions of the app. | 6 // experience in order to help improve future versions of the app. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ | 8 #ifndef CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ |
| 9 #define CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ | 9 #define CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ |
| 10 #pragma once | 10 #pragma once |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 class BookmarkNode; | 32 class BookmarkNode; |
| 33 class MetricsLog; | 33 class MetricsLog; |
| 34 class MetricsReportingScheduler; | 34 class MetricsReportingScheduler; |
| 35 class PrefService; | 35 class PrefService; |
| 36 class Profile; | 36 class Profile; |
| 37 class TemplateURLService; | 37 class TemplateURLService; |
| 38 | 38 |
| 39 namespace base { | 39 namespace base { |
| 40 class DictionaryValue; | 40 class DictionaryValue; |
| 41 class MessageLoopProxy; | 41 class MessageLoopProxy; |
| 42 class Time; | |
| 42 } | 43 } |
| 43 | 44 |
| 44 namespace content { | 45 namespace content { |
| 45 class RenderProcessHost; | 46 class RenderProcessHost; |
| 46 } | 47 } |
| 47 | 48 |
| 48 namespace extensions { | 49 namespace extensions { |
| 49 class ExtensionDownloader; | 50 class ExtensionDownloader; |
| 50 } | 51 } |
| 51 | 52 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 INITIAL_LOG_READY, // Initial log generated, and waiting for reply. | 151 INITIAL_LOG_READY, // Initial log generated, and waiting for reply. |
| 151 SENDING_OLD_LOGS, // Sending unsent logs from previous session. | 152 SENDING_OLD_LOGS, // Sending unsent logs from previous session. |
| 152 SENDING_CURRENT_LOGS, // Sending standard current logs as they acrue. | 153 SENDING_CURRENT_LOGS, // Sending standard current logs as they acrue. |
| 153 }; | 154 }; |
| 154 | 155 |
| 155 enum ShutdownCleanliness { | 156 enum ShutdownCleanliness { |
| 156 CLEANLY_SHUTDOWN = 0xdeadbeef, | 157 CLEANLY_SHUTDOWN = 0xdeadbeef, |
| 157 NEED_TO_SHUTDOWN = ~CLEANLY_SHUTDOWN | 158 NEED_TO_SHUTDOWN = ~CLEANLY_SHUTDOWN |
| 158 }; | 159 }; |
| 159 | 160 |
| 160 // First part of the init task. Called on the FILE thread to load hardware | 161 // First init task, that starts retrieving the hardware class. It proceeds |
| 161 // class information. | 162 // to InitTaskGetPluginInfo after reading the hardware_class, or after |
| 162 static void InitTaskGetHardwareClass(base::WeakPtr<MetricsService> self, | 163 // timing out waiting for it. |
| 163 base::MessageLoopProxy* target_loop); | 164 void InitTaskGetHardwareClass(); |
| 164 | 165 |
| 165 // Callback from InitTaskGetHardwareClass() that continues the init task by | 166 // Callback for the StatisticsProvider to signal that hardware data has been |
| 166 // loading plugin information. | 167 // loaded. Retrieves the hardware class and stores it in hardware_class_. |
| 167 void OnInitTaskGotHardwareClass(const std::string& hardware_class); | 168 // |start_time| is a timestamp of when the initialization was first requested. |
| 169 void OnStatisticsProviderReady(const base::Time& start_time); | |
| 170 | |
| 171 // Handles a timeout while waiting for the StatisticsProvider to become ready | |
| 172 // during initialization. | |
| 173 void OnStatisticsProviderTimeout(); | |
| 174 | |
| 175 // Second init task, that starts retrieving plugin info. | |
| 176 void InitTaskGetPluginInfo(); | |
| 168 | 177 |
| 169 // Callback from PluginService::GetPlugins() that continues the init task by | 178 // Callback from PluginService::GetPlugins() that continues the init task by |
| 170 // loading profiler data. | 179 // loading profiler data. |
| 171 void OnInitTaskGotPluginInfo( | 180 void OnInitTaskGotPluginInfo( |
| 172 const std::vector<webkit::WebPluginInfo>& plugins); | 181 const std::vector<webkit::WebPluginInfo>& plugins); |
| 173 | 182 |
| 174 // TrackingSynchronizerObserver: | 183 // TrackingSynchronizerObserver: |
| 175 virtual void ReceivedProfilerData( | 184 virtual void ReceivedProfilerData( |
| 176 const tracked_objects::ProcessDataSnapshot& process_data, | 185 const tracked_objects::ProcessDataSnapshot& process_data, |
| 177 content::ProcessType process_type) OVERRIDE; | 186 content::ProcessType process_type) OVERRIDE; |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 405 std::map<string16, ChildProcessStats> child_process_stats_buffer_; | 414 std::map<string16, ChildProcessStats> child_process_stats_buffer_; |
| 406 | 415 |
| 407 // Weak pointers factory used to post task on different threads. All weak | 416 // Weak pointers factory used to post task on different threads. All weak |
| 408 // pointers managed by this factory have the same lifetime as MetricsService. | 417 // pointers managed by this factory have the same lifetime as MetricsService. |
| 409 base::WeakPtrFactory<MetricsService> self_ptr_factory_; | 418 base::WeakPtrFactory<MetricsService> self_ptr_factory_; |
| 410 | 419 |
| 411 // Weak pointers factory used for saving state. All weak pointers managed by | 420 // Weak pointers factory used for saving state. All weak pointers managed by |
| 412 // this factory are invalidated in ScheduleNextStateSave. | 421 // this factory are invalidated in ScheduleNextStateSave. |
| 413 base::WeakPtrFactory<MetricsService> state_saver_factory_; | 422 base::WeakPtrFactory<MetricsService> state_saver_factory_; |
| 414 | 423 |
| 424 // Weak pointers factory used to post and invalidate the timeout task. | |
| 425 base::WeakPtrFactory<MetricsService> timeout_task_factory_; | |
|
Ilya Sherman
2012/04/30 07:36:41
nit: Why not just use self_ptr_factory_ here?
Joao da Silva
2012/05/15 13:52:47
Because self_ptr_factory_ is used to post other ta
| |
| 426 | |
| 415 // Dictionary containing all the profile specific metrics. This is set | 427 // Dictionary containing all the profile specific metrics. This is set |
| 416 // at creation time from the prefs. | 428 // at creation time from the prefs. |
| 417 scoped_ptr<base::DictionaryValue> profile_dictionary_; | 429 scoped_ptr<base::DictionaryValue> profile_dictionary_; |
| 418 | 430 |
| 419 // The scheduler for determining when uploads should happen. | 431 // The scheduler for determining when uploads should happen. |
| 420 scoped_ptr<MetricsReportingScheduler> scheduler_; | 432 scoped_ptr<MetricsReportingScheduler> scheduler_; |
| 421 | 433 |
| 422 // Indicates that an asynchronous reporting step is running. | 434 // Indicates that an asynchronous reporting step is running. |
| 423 // This is used only for debugging. | 435 // This is used only for debugging. |
| 424 bool waiting_for_asynchronus_reporting_step_; | 436 bool waiting_for_asynchronus_reporting_step_; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 447 friend bool prerender::IsOmniboxEnabled(Profile* profile); | 459 friend bool prerender::IsOmniboxEnabled(Profile* profile); |
| 448 friend class extensions::ExtensionDownloader; | 460 friend class extensions::ExtensionDownloader; |
| 449 | 461 |
| 450 // Returns true if prefs::kMetricsReportingEnabled is set. | 462 // Returns true if prefs::kMetricsReportingEnabled is set. |
| 451 static bool IsMetricsReportingEnabled(); | 463 static bool IsMetricsReportingEnabled(); |
| 452 | 464 |
| 453 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); | 465 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); |
| 454 }; | 466 }; |
| 455 | 467 |
| 456 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ | 468 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ |
| OLD | NEW |