| 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 |
| 11 | 11 |
| 12 #include <map> | 12 #include <map> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
| 17 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
| 18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.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/common/url_fetcher_delegate.h" | 27 #include "net/url_request/url_fetcher_delegate.h" |
| 28 | 28 |
| 29 #if defined(OS_CHROMEOS) | 29 #if defined(OS_CHROMEOS) |
| 30 #include "chrome/browser/chromeos/external_metrics.h" | 30 #include "chrome/browser/chromeos/external_metrics.h" |
| 31 #endif | 31 #endif |
| 32 | 32 |
| 33 class BookmarkModel; | 33 class BookmarkModel; |
| 34 class BookmarkNode; | 34 class BookmarkNode; |
| 35 class MetricsReportingScheduler; | 35 class MetricsReportingScheduler; |
| 36 class PrefService; | 36 class PrefService; |
| 37 class Profile; | 37 class Profile; |
| 38 class TemplateURLService; | 38 class TemplateURLService; |
| 39 | 39 |
| 40 namespace base { | 40 namespace base { |
| 41 class DictionaryValue; | 41 class DictionaryValue; |
| 42 class MessageLoopProxy; | 42 class MessageLoopProxy; |
| 43 } | 43 } |
| 44 | 44 |
| 45 namespace content { | 45 namespace content { |
| 46 class RenderProcessHost; | 46 class RenderProcessHost; |
| 47 } | 47 } |
| 48 | 48 |
| 49 namespace extensions { | 49 namespace extensions { |
| 50 class ExtensionDownloader; | 50 class ExtensionDownloader; |
| 51 } | 51 } |
| 52 | 52 |
| 53 namespace net { |
| 54 class URLFetcher; |
| 55 } |
| 56 |
| 53 namespace prerender { | 57 namespace prerender { |
| 54 bool IsOmniboxEnabled(Profile* profile); | 58 bool IsOmniboxEnabled(Profile* profile); |
| 55 } | 59 } |
| 56 | 60 |
| 57 namespace tracked_objects { | 61 namespace tracked_objects { |
| 58 struct ProcessDataSnapshot; | 62 struct ProcessDataSnapshot; |
| 59 } | 63 } |
| 60 | 64 |
| 61 namespace webkit { | 65 namespace webkit { |
| 62 struct WebPluginInfo; | 66 struct WebPluginInfo; |
| 63 } | 67 } |
| 64 | 68 |
| 65 class MetricsService | 69 class MetricsService |
| 66 : public chrome_browser_metrics::TrackingSynchronizerObserver, | 70 : public chrome_browser_metrics::TrackingSynchronizerObserver, |
| 67 public content::NotificationObserver, | 71 public content::NotificationObserver, |
| 68 public content::URLFetcherDelegate, | 72 public net::URLFetcherDelegate, |
| 69 public MetricsServiceBase { | 73 public MetricsServiceBase { |
| 70 public: | 74 public: |
| 71 MetricsService(); | 75 MetricsService(); |
| 72 virtual ~MetricsService(); | 76 virtual ~MetricsService(); |
| 73 | 77 |
| 74 // Start/stop the metrics recording and uploading machine. These should be | 78 // Start/stop the metrics recording and uploading machine. These should be |
| 75 // used on startup and when the user clicks the checkbox in the prefs. | 79 // used on startup and when the user clicks the checkbox in the prefs. |
| 76 // StartRecordingOnly starts the metrics recording but not reporting, for use | 80 // StartRecordingOnly starts the metrics recording but not reporting, for use |
| 77 // in tests only. | 81 // in tests only. |
| 78 void Start(); | 82 void Start(); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 void PrepareInitialLog(); | 267 void PrepareInitialLog(); |
| 264 | 268 |
| 265 // Uploads the currently staged log (which must be non-null). | 269 // Uploads the currently staged log (which must be non-null). |
| 266 void SendStagedLog(); | 270 void SendStagedLog(); |
| 267 | 271 |
| 268 // Prepared the staged log to be passed to the server. Upon return, | 272 // Prepared the staged log to be passed to the server. Upon return, |
| 269 // current_fetch_ should be reset with its upload data set to a compressed | 273 // current_fetch_ should be reset with its upload data set to a compressed |
| 270 // copy of the staged log. | 274 // copy of the staged log. |
| 271 void PrepareFetchWithStagedLog(); | 275 void PrepareFetchWithStagedLog(); |
| 272 | 276 |
| 273 // Implementation of content::URLFetcherDelegate. Called after transmission | 277 // Implementation of net::URLFetcherDelegate. Called after transmission |
| 274 // completes (either successfully or with failure). | 278 // completes (either successfully or with failure). |
| 275 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 279 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| 276 | 280 |
| 277 // Logs debugging details, for the case where the server returns a response | 281 // Logs debugging details, for the case where the server returns a response |
| 278 // code other than 200. | 282 // code other than 200. |
| 279 void LogBadResponseCode(); | 283 void LogBadResponseCode(); |
| 280 | 284 |
| 281 // Records a window-related notification. | 285 // Records a window-related notification. |
| 282 void LogWindowChange(int type, | 286 void LogWindowChange(int type, |
| 283 const content::NotificationSource& source, | 287 const content::NotificationSource& source, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 // The list of plugins which was retrieved on the file thread. | 374 // The list of plugins which was retrieved on the file thread. |
| 371 std::vector<webkit::WebPluginInfo> plugins_; | 375 std::vector<webkit::WebPluginInfo> plugins_; |
| 372 | 376 |
| 373 // Google Update statistics, which were retrieved on a blocking pool thread. | 377 // Google Update statistics, which were retrieved on a blocking pool thread. |
| 374 GoogleUpdateMetrics google_update_metrics_; | 378 GoogleUpdateMetrics google_update_metrics_; |
| 375 | 379 |
| 376 // The initial log, used to record startup metrics. | 380 // The initial log, used to record startup metrics. |
| 377 scoped_ptr<MetricsLog> initial_log_; | 381 scoped_ptr<MetricsLog> initial_log_; |
| 378 | 382 |
| 379 // The outstanding transmission appears as a URL Fetch operation. | 383 // The outstanding transmission appears as a URL Fetch operation. |
| 380 scoped_ptr<content::URLFetcher> current_fetch_xml_; | 384 scoped_ptr<net::URLFetcher> current_fetch_xml_; |
| 381 scoped_ptr<content::URLFetcher> current_fetch_proto_; | 385 scoped_ptr<net::URLFetcher> current_fetch_proto_; |
| 382 | 386 |
| 383 // Cached responses from the XML request while we wait for a response to the | 387 // Cached responses from the XML request while we wait for a response to the |
| 384 // protubuf request. | 388 // protubuf request. |
| 385 int response_code_; | 389 int response_code_; |
| 386 std::string response_status_; | 390 std::string response_status_; |
| 387 std::string response_data_; | 391 std::string response_data_; |
| 388 | 392 |
| 389 // The URLs for the XML and protobuf metrics servers. | 393 // The URLs for the XML and protobuf metrics servers. |
| 390 string16 server_url_xml_; | 394 string16 server_url_xml_; |
| 391 string16 server_url_proto_; | 395 string16 server_url_proto_; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 friend bool prerender::IsOmniboxEnabled(Profile* profile); | 465 friend bool prerender::IsOmniboxEnabled(Profile* profile); |
| 462 friend class extensions::ExtensionDownloader; | 466 friend class extensions::ExtensionDownloader; |
| 463 | 467 |
| 464 // Returns true if prefs::kMetricsReportingEnabled is set. | 468 // Returns true if prefs::kMetricsReportingEnabled is set. |
| 465 static bool IsMetricsReportingEnabled(); | 469 static bool IsMetricsReportingEnabled(); |
| 466 | 470 |
| 467 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); | 471 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); |
| 468 }; | 472 }; |
| 469 | 473 |
| 470 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ | 474 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ |
| OLD | NEW |