| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 5 |
| 6 | 6 |
| 7 //------------------------------------------------------------------------------ | 7 //------------------------------------------------------------------------------ |
| 8 // Description of the life cycle of a instance of MetricsService. | 8 // Description of the life cycle of a instance of MetricsService. |
| 9 // | 9 // |
| 10 // OVERVIEW | 10 // OVERVIEW |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 #include "chrome/browser/profiles/profile.h" | 177 #include "chrome/browser/profiles/profile.h" |
| 178 #include "chrome/browser/renderer_host/render_process_host.h" | 178 #include "chrome/browser/renderer_host/render_process_host.h" |
| 179 #include "chrome/browser/search_engines/template_url_model.h" | 179 #include "chrome/browser/search_engines/template_url_model.h" |
| 180 #include "chrome/common/child_process_info.h" | 180 #include "chrome/common/child_process_info.h" |
| 181 #include "chrome/common/child_process_logging.h" | 181 #include "chrome/common/child_process_logging.h" |
| 182 #include "chrome/common/chrome_switches.h" | 182 #include "chrome/common/chrome_switches.h" |
| 183 #include "chrome/common/guid.h" | 183 #include "chrome/common/guid.h" |
| 184 #include "chrome/common/notification_service.h" | 184 #include "chrome/common/notification_service.h" |
| 185 #include "chrome/common/pref_names.h" | 185 #include "chrome/common/pref_names.h" |
| 186 #include "chrome/common/render_messages.h" | 186 #include "chrome/common/render_messages.h" |
| 187 #include "webkit/glue/plugins/plugin_list.h" | 187 #include "webkit/plugins/npapi/plugin_list.h" |
| 188 #include "webkit/glue/plugins/webplugininfo.h" | 188 #include "webkit/plugins/npapi/webplugininfo.h" |
| 189 #include "libxml/xmlwriter.h" | 189 #include "libxml/xmlwriter.h" |
| 190 | 190 |
| 191 // TODO(port): port browser_distribution.h. | 191 // TODO(port): port browser_distribution.h. |
| 192 #if !defined(OS_POSIX) | 192 #if !defined(OS_POSIX) |
| 193 #include "chrome/installer/util/browser_distribution.h" | 193 #include "chrome/installer/util/browser_distribution.h" |
| 194 #endif | 194 #endif |
| 195 | 195 |
| 196 #if defined(OS_CHROMEOS) | 196 #if defined(OS_CHROMEOS) |
| 197 #include "chrome/browser/chromeos/cros/cros_library.h" | 197 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 198 #include "chrome/browser/chromeos/cros/system_library.h" | 198 #include "chrome/browser/chromeos/cros/system_library.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 | 329 |
| 330 private: | 330 private: |
| 331 ~MetricsMemoryDetails() {} | 331 ~MetricsMemoryDetails() {} |
| 332 | 332 |
| 333 Task* completion_; | 333 Task* completion_; |
| 334 DISALLOW_COPY_AND_ASSIGN(MetricsMemoryDetails); | 334 DISALLOW_COPY_AND_ASSIGN(MetricsMemoryDetails); |
| 335 }; | 335 }; |
| 336 | 336 |
| 337 class MetricsService::InitTaskComplete : public Task { | 337 class MetricsService::InitTaskComplete : public Task { |
| 338 public: | 338 public: |
| 339 explicit InitTaskComplete(const std::string& hardware_class, | 339 explicit InitTaskComplete( |
| 340 const std::vector<WebPluginInfo>& plugins) | 340 const std::string& hardware_class, |
| 341 const std::vector<webkit::npapi::WebPluginInfo>& plugins) |
| 341 : hardware_class_(hardware_class), plugins_(plugins) {} | 342 : hardware_class_(hardware_class), plugins_(plugins) {} |
| 342 | 343 |
| 343 virtual void Run() { | 344 virtual void Run() { |
| 344 g_browser_process->metrics_service()->OnInitTaskComplete( | 345 g_browser_process->metrics_service()->OnInitTaskComplete( |
| 345 hardware_class_, plugins_); | 346 hardware_class_, plugins_); |
| 346 } | 347 } |
| 347 | 348 |
| 348 private: | 349 private: |
| 349 std::string hardware_class_; | 350 std::string hardware_class_; |
| 350 std::vector<WebPluginInfo> plugins_; | 351 std::vector<webkit::npapi::WebPluginInfo> plugins_; |
| 351 }; | 352 }; |
| 352 | 353 |
| 353 class MetricsService::InitTask : public Task { | 354 class MetricsService::InitTask : public Task { |
| 354 public: | 355 public: |
| 355 explicit InitTask(MessageLoop* callback_loop) | 356 explicit InitTask(MessageLoop* callback_loop) |
| 356 : callback_loop_(callback_loop) {} | 357 : callback_loop_(callback_loop) {} |
| 357 | 358 |
| 358 virtual void Run() { | 359 virtual void Run() { |
| 359 std::vector<WebPluginInfo> plugins; | 360 std::vector<webkit::npapi::WebPluginInfo> plugins; |
| 360 NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins); | 361 webkit::npapi::PluginList::Singleton()->GetPlugins(false, &plugins); |
| 361 std::string hardware_class; // Empty string by default. | 362 std::string hardware_class; // Empty string by default. |
| 362 #if defined(OS_CHROMEOS) | 363 #if defined(OS_CHROMEOS) |
| 363 chromeos::SystemLibrary* system_library = | 364 chromeos::SystemLibrary* system_library = |
| 364 chromeos::CrosLibrary::Get()->GetSystemLibrary(); | 365 chromeos::CrosLibrary::Get()->GetSystemLibrary(); |
| 365 system_library->GetMachineStatistic("hardware_class", &hardware_class); | 366 system_library->GetMachineStatistic("hardware_class", &hardware_class); |
| 366 #endif // OS_CHROMEOS | 367 #endif // OS_CHROMEOS |
| 367 callback_loop_->PostTask(FROM_HERE, new InitTaskComplete( | 368 callback_loop_->PostTask(FROM_HERE, new InitTaskComplete( |
| 368 hardware_class, plugins)); | 369 hardware_class, plugins)); |
| 369 } | 370 } |
| 370 | 371 |
| 371 private: | 372 private: |
| 372 MessageLoop* callback_loop_; | 373 MessageLoop* callback_loop_; |
| 373 }; | 374 }; |
| 374 | 375 |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 UMA_HISTOGRAM_COUNTS_100("Chrome.CommandLineUncommonFlagCount", | 795 UMA_HISTOGRAM_COUNTS_100("Chrome.CommandLineUncommonFlagCount", |
| 795 command_line->GetSwitchCount() - common_commands); | 796 command_line->GetSwitchCount() - common_commands); |
| 796 | 797 |
| 797 // Kick off the process of saving the state (so the uptime numbers keep | 798 // Kick off the process of saving the state (so the uptime numbers keep |
| 798 // getting updated) every n minutes. | 799 // getting updated) every n minutes. |
| 799 ScheduleNextStateSave(); | 800 ScheduleNextStateSave(); |
| 800 } | 801 } |
| 801 | 802 |
| 802 void MetricsService::OnInitTaskComplete( | 803 void MetricsService::OnInitTaskComplete( |
| 803 const std::string& hardware_class, | 804 const std::string& hardware_class, |
| 804 const std::vector<WebPluginInfo>& plugins) { | 805 const std::vector<webkit::npapi::WebPluginInfo>& plugins) { |
| 805 DCHECK(state_ == INIT_TASK_SCHEDULED); | 806 DCHECK(state_ == INIT_TASK_SCHEDULED); |
| 806 hardware_class_ = hardware_class; | 807 hardware_class_ = hardware_class; |
| 807 plugins_ = plugins; | 808 plugins_ = plugins; |
| 808 if (state_ == INIT_TASK_SCHEDULED) | 809 if (state_ == INIT_TASK_SCHEDULED) |
| 809 state_ = INIT_TASK_DONE; | 810 state_ = INIT_TASK_DONE; |
| 810 } | 811 } |
| 811 | 812 |
| 812 std::string MetricsService::GenerateClientID() { | 813 std::string MetricsService::GenerateClientID() { |
| 813 return guid::GenerateGUID(); | 814 return guid::GenerateGUID(); |
| 814 } | 815 } |
| (...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1908 thread_id = PlatformThread::CurrentId(); | 1909 thread_id = PlatformThread::CurrentId(); |
| 1909 return PlatformThread::CurrentId() == thread_id; | 1910 return PlatformThread::CurrentId() == thread_id; |
| 1910 } | 1911 } |
| 1911 | 1912 |
| 1912 #if defined(OS_CHROMEOS) | 1913 #if defined(OS_CHROMEOS) |
| 1913 void MetricsService::StartExternalMetrics() { | 1914 void MetricsService::StartExternalMetrics() { |
| 1914 external_metrics_ = new chromeos::ExternalMetrics; | 1915 external_metrics_ = new chromeos::ExternalMetrics; |
| 1915 external_metrics_->Start(); | 1916 external_metrics_->Start(); |
| 1916 } | 1917 } |
| 1917 #endif | 1918 #endif |
| OLD | NEW |