| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 #include "base/platform_thread.h" | 174 #include "base/platform_thread.h" |
| 175 #include "base/rand_util.h" | 175 #include "base/rand_util.h" |
| 176 #include "base/string_util.h" | 176 #include "base/string_util.h" |
| 177 #include "base/task.h" | 177 #include "base/task.h" |
| 178 #include "chrome/browser/bookmarks/bookmark_model.h" | 178 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 179 #include "chrome/browser/browser.h" | 179 #include "chrome/browser/browser.h" |
| 180 #include "chrome/browser/browser_list.h" | 180 #include "chrome/browser/browser_list.h" |
| 181 #include "chrome/browser/browser_process.h" | 181 #include "chrome/browser/browser_process.h" |
| 182 #include "chrome/browser/load_notification_details.h" | 182 #include "chrome/browser/load_notification_details.h" |
| 183 #include "chrome/browser/memory_details.h" | 183 #include "chrome/browser/memory_details.h" |
| 184 #include "chrome/browser/plugin_service.h" | |
| 185 #include "chrome/browser/profile.h" | 184 #include "chrome/browser/profile.h" |
| 186 #include "chrome/browser/renderer_host/render_process_host.h" | 185 #include "chrome/browser/renderer_host/render_process_host.h" |
| 187 #include "chrome/browser/search_engines/template_url.h" | 186 #include "chrome/browser/search_engines/template_url.h" |
| 188 #include "chrome/browser/search_engines/template_url_model.h" | 187 #include "chrome/browser/search_engines/template_url_model.h" |
| 189 #include "chrome/common/child_process_info.h" | 188 #include "chrome/common/child_process_info.h" |
| 190 #include "chrome/common/chrome_paths.h" | 189 #include "chrome/common/chrome_paths.h" |
| 191 #include "chrome/common/chrome_switches.h" | 190 #include "chrome/common/chrome_switches.h" |
| 192 #include "chrome/common/histogram_synchronizer.h" | 191 #include "chrome/common/histogram_synchronizer.h" |
| 193 #include "chrome/common/libxml_utils.h" | 192 #include "chrome/common/libxml_utils.h" |
| 194 #include "chrome/common/notification_service.h" | 193 #include "chrome/common/notification_service.h" |
| 195 #include "chrome/common/pref_names.h" | 194 #include "chrome/common/pref_names.h" |
| 196 #include "chrome/common/pref_service.h" | 195 #include "chrome/common/pref_service.h" |
| 197 #include "chrome/common/render_messages.h" | 196 #include "chrome/common/render_messages.h" |
| 198 #include "googleurl/src/gurl.h" | 197 #include "googleurl/src/gurl.h" |
| 199 #include "net/base/load_flags.h" | 198 #include "net/base/load_flags.h" |
| 199 #include "webkit/glue/plugins/plugin_list.h" |
| 200 | 200 |
| 201 #if defined(OS_POSIX) | 201 #if defined(OS_POSIX) |
| 202 // TODO(port): Move these headers above as they are ported. | 202 // TODO(port): Move these headers above as they are ported. |
| 203 #include "chrome/common/temp_scaffolding_stubs.h" | 203 #include "chrome/common/temp_scaffolding_stubs.h" |
| 204 #else | 204 #else |
| 205 #include "chrome/installer/util/browser_distribution.h" | 205 #include "chrome/installer/util/browser_distribution.h" |
| 206 #include "chrome/installer/util/google_update_settings.h" | 206 #include "chrome/installer/util/google_update_settings.h" |
| 207 #endif | 207 #endif |
| 208 | 208 |
| 209 using base::Time; | 209 using base::Time; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 virtual void OnDetailsAvailable() { | 281 virtual void OnDetailsAvailable() { |
| 282 MessageLoop::current()->PostTask(FROM_HERE, completion_); | 282 MessageLoop::current()->PostTask(FROM_HERE, completion_); |
| 283 } | 283 } |
| 284 | 284 |
| 285 private: | 285 private: |
| 286 Task* completion_; | 286 Task* completion_; |
| 287 DISALLOW_EVIL_CONSTRUCTORS(MetricsMemoryDetails); | 287 DISALLOW_EVIL_CONSTRUCTORS(MetricsMemoryDetails); |
| 288 }; | 288 }; |
| 289 | 289 |
| 290 class MetricsService::GetPluginListTaskComplete : public Task { | 290 class MetricsService::GetPluginListTaskComplete : public Task { |
| 291 public: |
| 292 explicit GetPluginListTaskComplete( |
| 293 const std::vector<WebPluginInfo>& plugins) : plugins_(plugins) { } |
| 291 virtual void Run() { | 294 virtual void Run() { |
| 292 g_browser_process->metrics_service()->OnGetPluginListTaskComplete(); | 295 g_browser_process->metrics_service()->OnGetPluginListTaskComplete(plugins_); |
| 293 } | 296 } |
| 297 |
| 298 private: |
| 299 std::vector<WebPluginInfo> plugins_; |
| 294 }; | 300 }; |
| 295 | 301 |
| 296 class MetricsService::GetPluginListTask : public Task { | 302 class MetricsService::GetPluginListTask : public Task { |
| 297 public: | 303 public: |
| 298 explicit GetPluginListTask(MessageLoop* callback_loop) | 304 explicit GetPluginListTask(MessageLoop* callback_loop) |
| 299 : callback_loop_(callback_loop) {} | 305 : callback_loop_(callback_loop) {} |
| 300 | 306 |
| 301 virtual void Run() { | 307 virtual void Run() { |
| 302 std::vector<WebPluginInfo> plugins; | 308 std::vector<WebPluginInfo> plugins; |
| 303 PluginService::GetInstance()->GetPlugins(false, &plugins); | 309 NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins); |
| 304 | 310 |
| 305 callback_loop_->PostTask(FROM_HERE, new GetPluginListTaskComplete()); | 311 callback_loop_->PostTask( |
| 312 FROM_HERE, new GetPluginListTaskComplete(plugins)); |
| 306 } | 313 } |
| 307 | 314 |
| 308 private: | 315 private: |
| 309 MessageLoop* callback_loop_; | 316 MessageLoop* callback_loop_; |
| 310 }; | 317 }; |
| 311 | 318 |
| 312 // static | 319 // static |
| 313 void MetricsService::RegisterPrefs(PrefService* local_state) { | 320 void MetricsService::RegisterPrefs(PrefService* local_state) { |
| 314 DCHECK(IsSingleThreaded()); | 321 DCHECK(IsSingleThreaded()); |
| 315 local_state->RegisterStringPref(prefs::kMetricsClientID, L""); | 322 local_state->RegisterStringPref(prefs::kMetricsClientID, L""); |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 UMA_HISTOGRAM_COUNTS_100("Chrome.CommandLineFlagCount", | 751 UMA_HISTOGRAM_COUNTS_100("Chrome.CommandLineFlagCount", |
| 745 command_line->GetSwitchCount()); | 752 command_line->GetSwitchCount()); |
| 746 UMA_HISTOGRAM_COUNTS_100("Chrome.CommandLineUncommonFlagCount", | 753 UMA_HISTOGRAM_COUNTS_100("Chrome.CommandLineUncommonFlagCount", |
| 747 command_line->GetSwitchCount() - common_commands); | 754 command_line->GetSwitchCount() - common_commands); |
| 748 | 755 |
| 749 // Kick off the process of saving the state (so the uptime numbers keep | 756 // Kick off the process of saving the state (so the uptime numbers keep |
| 750 // getting updated) every n minutes. | 757 // getting updated) every n minutes. |
| 751 ScheduleNextStateSave(); | 758 ScheduleNextStateSave(); |
| 752 } | 759 } |
| 753 | 760 |
| 754 void MetricsService::OnGetPluginListTaskComplete() { | 761 void MetricsService::OnGetPluginListTaskComplete( |
| 762 const std::vector<WebPluginInfo>& plugins) { |
| 755 DCHECK(state_ == PLUGIN_LIST_REQUESTED); | 763 DCHECK(state_ == PLUGIN_LIST_REQUESTED); |
| 764 plugins_ = plugins; |
| 756 if (state_ == PLUGIN_LIST_REQUESTED) | 765 if (state_ == PLUGIN_LIST_REQUESTED) |
| 757 state_ = PLUGIN_LIST_ARRIVED; | 766 state_ = PLUGIN_LIST_ARRIVED; |
| 758 } | 767 } |
| 759 | 768 |
| 760 std::string MetricsService::GenerateClientID() { | 769 std::string MetricsService::GenerateClientID() { |
| 761 #if defined(OS_WIN) | 770 #if defined(OS_WIN) |
| 762 const int kGUIDSize = 39; | 771 const int kGUIDSize = 39; |
| 763 | 772 |
| 764 GUID guid; | 773 GUID guid; |
| 765 HRESULT guid_result = CoCreateGuid(&guid); | 774 HRESULT guid_result = CoCreateGuid(&guid); |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 return true; | 1124 return true; |
| 1116 | 1125 |
| 1117 case SENDING_CURRENT_LOGS: | 1126 case SENDING_CURRENT_LOGS: |
| 1118 default: | 1127 default: |
| 1119 return false; | 1128 return false; |
| 1120 } | 1129 } |
| 1121 } | 1130 } |
| 1122 | 1131 |
| 1123 void MetricsService::PrepareInitialLog() { | 1132 void MetricsService::PrepareInitialLog() { |
| 1124 DCHECK(state_ == PLUGIN_LIST_ARRIVED); | 1133 DCHECK(state_ == PLUGIN_LIST_ARRIVED); |
| 1125 std::vector<WebPluginInfo> plugins; | |
| 1126 PluginService::GetInstance()->GetPlugins(false, &plugins); | |
| 1127 | 1134 |
| 1128 MetricsLog* log = new MetricsLog(client_id_, session_id_); | 1135 MetricsLog* log = new MetricsLog(client_id_, session_id_); |
| 1129 log->RecordEnvironment(plugins, profile_dictionary_.get()); | 1136 log->RecordEnvironment(plugins_, profile_dictionary_.get()); |
| 1130 | 1137 |
| 1131 // Histograms only get written to current_log_, so setup for the write. | 1138 // Histograms only get written to current_log_, so setup for the write. |
| 1132 MetricsLog* save_log = current_log_; | 1139 MetricsLog* save_log = current_log_; |
| 1133 current_log_ = log; | 1140 current_log_ = log; |
| 1134 RecordCurrentHistograms(); // Into current_log_... which is really log. | 1141 RecordCurrentHistograms(); // Into current_log_... which is really log. |
| 1135 current_log_ = save_log; | 1142 current_log_ = save_log; |
| 1136 | 1143 |
| 1137 log->CloseLog(); | 1144 log->CloseLog(); |
| 1138 DCHECK(!pending_log()); | 1145 DCHECK(!pending_log()); |
| 1139 pending_log_ = log; | 1146 pending_log_ = log; |
| (...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1924 L"." + key; | 1931 L"." + key; |
| 1925 prof_prefs->SetInteger(pref_key.c_str(), value); | 1932 prof_prefs->SetInteger(pref_key.c_str(), value); |
| 1926 } | 1933 } |
| 1927 | 1934 |
| 1928 static bool IsSingleThreaded() { | 1935 static bool IsSingleThreaded() { |
| 1929 static PlatformThreadId thread_id = 0; | 1936 static PlatformThreadId thread_id = 0; |
| 1930 if (!thread_id) | 1937 if (!thread_id) |
| 1931 thread_id = PlatformThread::CurrentId(); | 1938 thread_id = PlatformThread::CurrentId(); |
| 1932 return PlatformThread::CurrentId() == thread_id; | 1939 return PlatformThread::CurrentId() == thread_id; |
| 1933 } | 1940 } |
| OLD | NEW |