| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "content/common/notification_observer.h" | 21 #include "content/common/notification_observer.h" |
| 22 #include "content/common/notification_registrar.h" | 22 #include "content/common/notification_registrar.h" |
| 23 #include "content/common/url_fetcher.h" | 23 #include "content/common/url_fetcher.h" |
| 24 | 24 |
| 25 #if defined(OS_CHROMEOS) | 25 #if defined(OS_CHROMEOS) |
| 26 #include "chrome/browser/chromeos/external_metrics.h" | 26 #include "chrome/browser/chromeos/external_metrics.h" |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 class BookmarkModel; | 29 class BookmarkModel; |
| 30 class BookmarkNode; | 30 class BookmarkNode; |
| 31 class DictionaryValue; | |
| 32 class ListValue; | |
| 33 class HistogramSynchronizer; | 31 class HistogramSynchronizer; |
| 34 class MetricsLogBase; | 32 class MetricsLogBase; |
| 35 class MetricsReportingScheduler; | 33 class MetricsReportingScheduler; |
| 36 class PrefService; | 34 class PrefService; |
| 37 class TemplateURLService; | 35 class TemplateURLService; |
| 38 | 36 |
| 37 namespace base { |
| 38 class DictionaryValue; |
| 39 class ListValue; |
| 40 } |
| 41 |
| 39 namespace webkit { | 42 namespace webkit { |
| 40 namespace npapi { | 43 namespace npapi { |
| 41 struct WebPluginInfo; | 44 struct WebPluginInfo; |
| 42 } | 45 } |
| 43 } | 46 } |
| 44 | 47 |
| 45 | 48 |
| 46 class MetricsService : public NotificationObserver, | 49 class MetricsService : public NotificationObserver, |
| 47 public URLFetcher::Delegate, | 50 public URLFetcher::Delegate, |
| 48 public MetricsServiceBase { | 51 public MetricsServiceBase { |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 // Check to see if there are any unsent logs from previous sessions. | 233 // Check to see if there are any unsent logs from previous sessions. |
| 231 bool unsent_logs() const { | 234 bool unsent_logs() const { |
| 232 return !unsent_initial_logs_.empty() || !unsent_ongoing_logs_.empty(); | 235 return !unsent_initial_logs_.empty() || !unsent_ongoing_logs_.empty(); |
| 233 } | 236 } |
| 234 // Record stats, client ID, Session ID, etc. in a special "first" log. | 237 // Record stats, client ID, Session ID, etc. in a special "first" log. |
| 235 void PrepareInitialLog(); | 238 void PrepareInitialLog(); |
| 236 // Pull copies of unsent logs from prefs into instance variables. | 239 // Pull copies of unsent logs from prefs into instance variables. |
| 237 void RecallUnsentLogs(); | 240 void RecallUnsentLogs(); |
| 238 // Decode and verify written pref log data. | 241 // Decode and verify written pref log data. |
| 239 static MetricsService::LogRecallStatus RecallUnsentLogsHelper( | 242 static MetricsService::LogRecallStatus RecallUnsentLogsHelper( |
| 240 const ListValue& list, | 243 const base::ListValue& list, |
| 241 std::vector<std::string>* local_list); | 244 std::vector<std::string>* local_list); |
| 242 // Encode and write list size and checksum for perf log data. | 245 // Encode and write list size and checksum for perf log data. |
| 243 static void StoreUnsentLogsHelper(const std::vector<std::string>& local_list, | 246 static void StoreUnsentLogsHelper(const std::vector<std::string>& local_list, |
| 244 const size_t kMaxLocalListSize, | 247 const size_t kMaxLocalListSize, |
| 245 ListValue* list); | 248 base::ListValue* list); |
| 246 // Convert |pending_log_| to XML in |compressed_log_|, and compress it for | 249 // Convert |pending_log_| to XML in |compressed_log_|, and compress it for |
| 247 // transmission. | 250 // transmission. |
| 248 void PreparePendingLogText(); | 251 void PreparePendingLogText(); |
| 249 | 252 |
| 250 // Convert pending_log_ to XML, compress it, and prepare to pass to server. | 253 // Convert pending_log_ to XML, compress it, and prepare to pass to server. |
| 251 // Upon return, current_fetch_ should be reset with its upload data set to | 254 // Upon return, current_fetch_ should be reset with its upload data set to |
| 252 // a compressed copy of the pending log. | 255 // a compressed copy of the pending log. |
| 253 void PrepareFetchWithPendingLog(); | 256 void PrepareFetchWithPendingLog(); |
| 254 | 257 |
| 255 // Implementation of URLFetcher::Delegate. Called after transmission | 258 // Implementation of URLFetcher::Delegate. Called after transmission |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 // Buffer of child process notifications for quick access. See | 402 // Buffer of child process notifications for quick access. See |
| 400 // ChildProcessStats documentation above for more details. | 403 // ChildProcessStats documentation above for more details. |
| 401 struct ChildProcessStats; | 404 struct ChildProcessStats; |
| 402 std::map<std::wstring, ChildProcessStats> child_process_stats_buffer_; | 405 std::map<std::wstring, ChildProcessStats> child_process_stats_buffer_; |
| 403 | 406 |
| 404 ScopedRunnableMethodFactory<MetricsService> log_sender_factory_; | 407 ScopedRunnableMethodFactory<MetricsService> log_sender_factory_; |
| 405 ScopedRunnableMethodFactory<MetricsService> state_saver_factory_; | 408 ScopedRunnableMethodFactory<MetricsService> state_saver_factory_; |
| 406 | 409 |
| 407 // Dictionary containing all the profile specific metrics. This is set | 410 // Dictionary containing all the profile specific metrics. This is set |
| 408 // at creation time from the prefs. | 411 // at creation time from the prefs. |
| 409 scoped_ptr<DictionaryValue> profile_dictionary_; | 412 scoped_ptr<base::DictionaryValue> profile_dictionary_; |
| 410 | 413 |
| 411 // The scheduler for determining when uploads should happen. | 414 // The scheduler for determining when uploads should happen. |
| 412 scoped_ptr<MetricsReportingScheduler> scheduler_; | 415 scoped_ptr<MetricsReportingScheduler> scheduler_; |
| 413 | 416 |
| 414 // Indicates that an asynchronous reporting step is running. | 417 // Indicates that an asynchronous reporting step is running. |
| 415 // This is used only for debugging. | 418 // This is used only for debugging. |
| 416 bool waiting_for_asynchronus_reporting_step_; | 419 bool waiting_for_asynchronus_reporting_step_; |
| 417 | 420 |
| 418 #if defined(OS_CHROMEOS) | 421 #if defined(OS_CHROMEOS) |
| 419 // The external metric service is used to log ChromeOS UMA events. | 422 // The external metric service is used to log ChromeOS UMA events. |
| 420 scoped_refptr<chromeos::ExternalMetrics> external_metrics_; | 423 scoped_refptr<chromeos::ExternalMetrics> external_metrics_; |
| 421 #endif | 424 #endif |
| 422 | 425 |
| 423 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, EmptyLogList); | 426 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, EmptyLogList); |
| 424 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, SingleElementLogList); | 427 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, SingleElementLogList); |
| 425 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, OverLimitLogList); | 428 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, OverLimitLogList); |
| 426 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, SmallRecoveredListSize); | 429 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, SmallRecoveredListSize); |
| 427 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RemoveSizeFromLogList); | 430 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RemoveSizeFromLogList); |
| 428 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, CorruptSizeOfLogList); | 431 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, CorruptSizeOfLogList); |
| 429 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, CorruptChecksumOfLogList); | 432 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, CorruptChecksumOfLogList); |
| 430 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, ClientIdGeneratesAllZeroes); | 433 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, ClientIdGeneratesAllZeroes); |
| 431 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, ClientIdGeneratesCorrectly); | 434 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, ClientIdGeneratesCorrectly); |
| 432 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, ClientIdCorrectlyFormatted); | 435 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, ClientIdCorrectlyFormatted); |
| 433 | 436 |
| 434 DISALLOW_COPY_AND_ASSIGN(MetricsService); | 437 DISALLOW_COPY_AND_ASSIGN(MetricsService); |
| 435 }; | 438 }; |
| 436 | 439 |
| 437 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ | 440 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ |
| OLD | NEW |