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 | 10 |
11 #include <map> | 11 #include <map> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
16 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/metrics/field_trial.h" | 19 #include "base/metrics/field_trial.h" |
20 #include "base/process_util.h" | 20 #include "base/process_util.h" |
21 #include "chrome/browser/metrics/metrics_log.h" | 21 #include "chrome/browser/metrics/metrics_log.h" |
22 #include "chrome/browser/metrics/tracking_synchronizer_observer.h" | 22 #include "chrome/browser/metrics/tracking_synchronizer_observer.h" |
23 #include "chrome/common/metrics/metrics_service_base.h" | 23 #include "chrome/common/metrics/metrics_service_base.h" |
24 #include "chrome/installer/util/google_update_settings.h" | 24 #include "chrome/installer/util/google_update_settings.h" |
25 #include "content/public/browser/notification_observer.h" | 25 #include "content/public/browser/notification_observer.h" |
26 #include "content/public/browser/notification_registrar.h" | 26 #include "content/public/browser/notification_registrar.h" |
| 27 #include "content/public/browser/user_metrics.h" |
27 #include "net/url_request/url_fetcher_delegate.h" | 28 #include "net/url_request/url_fetcher_delegate.h" |
28 | 29 |
29 #if defined(OS_CHROMEOS) | 30 #if defined(OS_CHROMEOS) |
30 #include "chrome/browser/chromeos/external_metrics.h" | 31 #include "chrome/browser/chromeos/external_metrics.h" |
31 #endif | 32 #endif |
32 | 33 |
33 class BookmarkModel; | 34 class BookmarkModel; |
34 class BookmarkNode; | 35 class BookmarkNode; |
35 class MetricsReportingScheduler; | 36 class MetricsReportingScheduler; |
36 class PrefService; | 37 class PrefService; |
(...skipping 27 matching lines...) Expand all Loading... |
64 struct ProcessDataSnapshot; | 65 struct ProcessDataSnapshot; |
65 } | 66 } |
66 | 67 |
67 namespace webkit { | 68 namespace webkit { |
68 struct WebPluginInfo; | 69 struct WebPluginInfo; |
69 } | 70 } |
70 | 71 |
71 class MetricsService | 72 class MetricsService |
72 : public chrome_browser_metrics::TrackingSynchronizerObserver, | 73 : public chrome_browser_metrics::TrackingSynchronizerObserver, |
73 public content::NotificationObserver, | 74 public content::NotificationObserver, |
| 75 public content::UserMetricsObserver, |
74 public net::URLFetcherDelegate, | 76 public net::URLFetcherDelegate, |
75 public MetricsServiceBase { | 77 public MetricsServiceBase { |
76 public: | 78 public: |
77 MetricsService(); | 79 MetricsService(); |
78 virtual ~MetricsService(); | 80 virtual ~MetricsService(); |
79 | 81 |
80 // Starts the metrics system, turning on recording and uploading of metrics. | 82 // Starts the metrics system, turning on recording and uploading of metrics. |
81 // Should be called when starting up with metrics enabled, or when metrics | 83 // Should be called when starting up with metrics enabled, or when metrics |
82 // are turned on. | 84 // are turned on. |
83 void Start(); | 85 void Start(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 // useful to allow some features to sleep, until the machine becomes active, | 132 // useful to allow some features to sleep, until the machine becomes active, |
131 // such as precluding UMA uploads unless there was recent activity. | 133 // such as precluding UMA uploads unless there was recent activity. |
132 static void SetUpNotifications(content::NotificationRegistrar* registrar, | 134 static void SetUpNotifications(content::NotificationRegistrar* registrar, |
133 content::NotificationObserver* observer); | 135 content::NotificationObserver* observer); |
134 | 136 |
135 // Implementation of content::NotificationObserver | 137 // Implementation of content::NotificationObserver |
136 virtual void Observe(int type, | 138 virtual void Observe(int type, |
137 const content::NotificationSource& source, | 139 const content::NotificationSource& source, |
138 const content::NotificationDetails& details) OVERRIDE; | 140 const content::NotificationDetails& details) OVERRIDE; |
139 | 141 |
| 142 // Implementation of content::UserMetricsObserver |
| 143 virtual void UserAction(const std::string& action) OVERRIDE; |
| 144 |
140 // Invoked when we get a WM_SESSIONEND. This places a value in prefs that is | 145 // Invoked when we get a WM_SESSIONEND. This places a value in prefs that is |
141 // reset when RecordCompletedSessionEnd is invoked. | 146 // reset when RecordCompletedSessionEnd is invoked. |
142 void RecordStartOfSessionEnd(); | 147 void RecordStartOfSessionEnd(); |
143 | 148 |
144 // This should be called when the application is shutting down. It records | 149 // This should be called when the application is shutting down. It records |
145 // that session end was successful. | 150 // that session end was successful. |
146 void RecordCompletedSessionEnd(); | 151 void RecordCompletedSessionEnd(); |
147 | 152 |
148 #if defined(OS_ANDROID) || defined(OS_IOS) | 153 #if defined(OS_ANDROID) || defined(OS_IOS) |
149 // Called when the application is going into background mode. | 154 // Called when the application is going into background mode. |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 | 396 |
392 // Logs the initiation of a page load | 397 // Logs the initiation of a page load |
393 void LogLoadStarted(); | 398 void LogLoadStarted(); |
394 | 399 |
395 // Records a page load notification. | 400 // Records a page load notification. |
396 void LogLoadComplete(int type, | 401 void LogLoadComplete(int type, |
397 const content::NotificationSource& source, | 402 const content::NotificationSource& source, |
398 const content::NotificationDetails& details); | 403 const content::NotificationDetails& details); |
399 | 404 |
400 // Checks whether a notification can be logged. | 405 // Checks whether a notification can be logged. |
401 bool CanLogNotification(int type, | 406 bool CanLogNotification(); |
402 const content::NotificationSource& source, | |
403 const content::NotificationDetails& details); | |
404 | 407 |
405 // Sets the value of the specified path in prefs and schedules a save. | 408 // Sets the value of the specified path in prefs and schedules a save. |
406 void RecordBooleanPrefValue(const char* path, bool value); | 409 void RecordBooleanPrefValue(const char* path, bool value); |
407 | 410 |
408 // Returns true if process of type |type| should be counted as a plugin | 411 // Returns true if process of type |type| should be counted as a plugin |
409 // process, and false otherwise. | 412 // process, and false otherwise. |
410 static bool IsPluginProcess(content::ProcessType type); | 413 static bool IsPluginProcess(content::ProcessType type); |
411 | 414 |
412 content::NotificationRegistrar registrar_; | 415 content::NotificationRegistrar registrar_; |
413 | 416 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 friend class extensions::ExtensionDownloader; | 531 friend class extensions::ExtensionDownloader; |
529 friend class extensions::ManifestFetchData; | 532 friend class extensions::ManifestFetchData; |
530 | 533 |
531 // Returns true if prefs::kMetricsReportingEnabled is set. | 534 // Returns true if prefs::kMetricsReportingEnabled is set. |
532 static bool IsMetricsReportingEnabled(); | 535 static bool IsMetricsReportingEnabled(); |
533 | 536 |
534 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); | 537 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); |
535 }; | 538 }; |
536 | 539 |
537 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ | 540 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ |
OLD | NEW |