OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 //------------------------------------------------------------------------------ | 155 //------------------------------------------------------------------------------ |
156 | 156 |
157 #include <windows.h> | 157 #include <windows.h> |
158 | 158 |
159 #include "chrome/browser/metrics_service.h" | 159 #include "chrome/browser/metrics_service.h" |
160 | 160 |
161 #include "base/histogram.h" | 161 #include "base/histogram.h" |
162 #include "base/path_service.h" | 162 #include "base/path_service.h" |
163 #include "base/string_util.h" | 163 #include "base/string_util.h" |
164 #include "base/task.h" | 164 #include "base/task.h" |
165 #include "chrome/browser/bookmarks/bookmark_bar_model.h" | 165 #include "chrome/browser/bookmarks/bookmark_model.h" |
166 #include "chrome/browser/browser.h" | 166 #include "chrome/browser/browser.h" |
167 #include "chrome/browser/browser_list.h" | 167 #include "chrome/browser/browser_list.h" |
168 #include "chrome/browser/browser_process.h" | 168 #include "chrome/browser/browser_process.h" |
169 #include "chrome/browser/load_notification_details.h" | 169 #include "chrome/browser/load_notification_details.h" |
170 #include "chrome/browser/memory_details.h" | 170 #include "chrome/browser/memory_details.h" |
171 #include "chrome/browser/plugin_process_info.h" | 171 #include "chrome/browser/plugin_process_info.h" |
172 #include "chrome/browser/plugin_service.h" | 172 #include "chrome/browser/plugin_service.h" |
173 #include "chrome/browser/profile.h" | 173 #include "chrome/browser/profile.h" |
174 #include "chrome/browser/render_process_host.h" | 174 #include "chrome/browser/render_process_host.h" |
175 #include "chrome/browser/template_url.h" | 175 #include "chrome/browser/template_url.h" |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 case TEMPLATE_URL_MODEL_LOADED: | 445 case TEMPLATE_URL_MODEL_LOADED: |
446 LogKeywords(Source<TemplateURLModel>(source).ptr()); | 446 LogKeywords(Source<TemplateURLModel>(source).ptr()); |
447 break; | 447 break; |
448 | 448 |
449 case NOTIFY_OMNIBOX_OPENED_URL: | 449 case NOTIFY_OMNIBOX_OPENED_URL: |
450 current_log_->RecordOmniboxOpenedURL( | 450 current_log_->RecordOmniboxOpenedURL( |
451 *Details<AutocompleteLog>(details).ptr()); | 451 *Details<AutocompleteLog>(details).ptr()); |
452 break; | 452 break; |
453 | 453 |
454 case NOTIFY_BOOKMARK_MODEL_LOADED: | 454 case NOTIFY_BOOKMARK_MODEL_LOADED: |
455 LogBookmarks(Source<Profile>(source)->GetBookmarkBarModel()); | 455 LogBookmarks(Source<Profile>(source)->GetBookmarkModel()); |
456 break; | 456 break; |
457 | 457 |
458 default: | 458 default: |
459 NOTREACHED(); | 459 NOTREACHED(); |
460 break; | 460 break; |
461 } | 461 } |
462 StartLogTransmissionTimer(); | 462 StartLogTransmissionTimer(); |
463 } | 463 } |
464 | 464 |
465 void MetricsService::RecordCleanShutdown() { | 465 void MetricsService::RecordCleanShutdown() { |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 stats.process_crashes++; | 1294 stats.process_crashes++; |
1295 break; | 1295 break; |
1296 | 1296 |
1297 default: | 1297 default: |
1298 NOTREACHED() << "Unexpected notification type " << type; | 1298 NOTREACHED() << "Unexpected notification type " << type; |
1299 return; | 1299 return; |
1300 } | 1300 } |
1301 } | 1301 } |
1302 | 1302 |
1303 // Recursively counts the number of bookmarks and folders in node. | 1303 // Recursively counts the number of bookmarks and folders in node. |
1304 static void CountBookmarks(BookmarkBarNode* node, | 1304 static void CountBookmarks(BookmarkNode* node, int* bookmarks, int* folders) { |
1305 int* bookmarks, | |
1306 int* folders) { | |
1307 if (node->GetType() == history::StarredEntry::URL) | 1305 if (node->GetType() == history::StarredEntry::URL) |
1308 (*bookmarks)++; | 1306 (*bookmarks)++; |
1309 else | 1307 else |
1310 (*folders)++; | 1308 (*folders)++; |
1311 for (int i = 0; i < node->GetChildCount(); ++i) | 1309 for (int i = 0; i < node->GetChildCount(); ++i) |
1312 CountBookmarks(node->GetChild(i), bookmarks, folders); | 1310 CountBookmarks(node->GetChild(i), bookmarks, folders); |
1313 } | 1311 } |
1314 | 1312 |
1315 void MetricsService::LogBookmarks(BookmarkBarNode* node, | 1313 void MetricsService::LogBookmarks(BookmarkNode* node, |
1316 const wchar_t* num_bookmarks_key, | 1314 const wchar_t* num_bookmarks_key, |
1317 const wchar_t* num_folders_key) { | 1315 const wchar_t* num_folders_key) { |
1318 DCHECK(node); | 1316 DCHECK(node); |
1319 int num_bookmarks = 0; | 1317 int num_bookmarks = 0; |
1320 int num_folders = 0; | 1318 int num_folders = 0; |
1321 CountBookmarks(node, &num_bookmarks, &num_folders); | 1319 CountBookmarks(node, &num_bookmarks, &num_folders); |
1322 num_folders--; // Don't include the root folder in the count. | 1320 num_folders--; // Don't include the root folder in the count. |
1323 | 1321 |
1324 PrefService* pref = g_browser_process->local_state(); | 1322 PrefService* pref = g_browser_process->local_state(); |
1325 DCHECK(pref); | 1323 DCHECK(pref); |
1326 pref->SetInteger(num_bookmarks_key, num_bookmarks); | 1324 pref->SetInteger(num_bookmarks_key, num_bookmarks); |
1327 pref->SetInteger(num_folders_key, num_folders); | 1325 pref->SetInteger(num_folders_key, num_folders); |
1328 } | 1326 } |
1329 | 1327 |
1330 void MetricsService::LogBookmarks(BookmarkBarModel* model) { | 1328 void MetricsService::LogBookmarks(BookmarkModel* model) { |
1331 DCHECK(model); | 1329 DCHECK(model); |
1332 LogBookmarks(model->GetBookmarkBarNode(), | 1330 LogBookmarks(model->GetBookmarkBarNode(), |
1333 prefs::kNumBookmarksOnBookmarkBar, | 1331 prefs::kNumBookmarksOnBookmarkBar, |
1334 prefs::kNumFoldersOnBookmarkBar); | 1332 prefs::kNumFoldersOnBookmarkBar); |
1335 LogBookmarks(model->other_node(), | 1333 LogBookmarks(model->other_node(), |
1336 prefs::kNumBookmarksInOtherBookmarkFolder, | 1334 prefs::kNumBookmarksInOtherBookmarkFolder, |
1337 prefs::kNumFoldersInOtherBookmarkFolder); | 1335 prefs::kNumFoldersInOtherBookmarkFolder); |
1338 ScheduleNextStateSave(); | 1336 ScheduleNextStateSave(); |
1339 } | 1337 } |
1340 | 1338 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1507 prof_prefs->SetInteger(pref_key.c_str(), value); | 1505 prof_prefs->SetInteger(pref_key.c_str(), value); |
1508 } | 1506 } |
1509 | 1507 |
1510 static bool IsSingleThreaded() { | 1508 static bool IsSingleThreaded() { |
1511 static int thread_id = 0; | 1509 static int thread_id = 0; |
1512 if (!thread_id) | 1510 if (!thread_id) |
1513 thread_id = GetCurrentThreadId(); | 1511 thread_id = GetCurrentThreadId(); |
1514 return GetCurrentThreadId() == thread_id; | 1512 return GetCurrentThreadId() == thread_id; |
1515 } | 1513 } |
1516 | 1514 |
OLD | NEW |