| 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 |
| 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/process_util.h" | 19 #include "base/process_util.h" |
| 20 #include "chrome/browser/io_thread.h" | 20 #include "chrome/browser/io_thread.h" |
| 21 #include "chrome/common/metrics_helpers.h" | 21 #include "chrome/common/metrics_helpers.h" |
| 22 #include "content/common/child_process_info.h" |
| 22 #include "content/public/common/url_fetcher_delegate.h" | 23 #include "content/public/common/url_fetcher_delegate.h" |
| 23 #include "content/public/browser/notification_observer.h" | 24 #include "content/public/browser/notification_observer.h" |
| 24 #include "content/public/browser/notification_registrar.h" | 25 #include "content/public/browser/notification_registrar.h" |
| 25 | 26 |
| 26 #if defined(OS_CHROMEOS) | 27 #if defined(OS_CHROMEOS) |
| 27 #include "chrome/browser/chromeos/external_metrics.h" | 28 #include "chrome/browser/chromeos/external_metrics.h" |
| 28 #endif | 29 #endif |
| 29 | 30 |
| 30 class BookmarkModel; | 31 class BookmarkModel; |
| 31 class BookmarkNode; | 32 class BookmarkNode; |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 const content::NotificationDetails& details); | 299 const content::NotificationDetails& details); |
| 299 | 300 |
| 300 // Checks whether a notification can be logged. | 301 // Checks whether a notification can be logged. |
| 301 bool CanLogNotification(int type, | 302 bool CanLogNotification(int type, |
| 302 const content::NotificationSource& source, | 303 const content::NotificationSource& source, |
| 303 const content::NotificationDetails& details); | 304 const content::NotificationDetails& details); |
| 304 | 305 |
| 305 // Sets the value of the specified path in prefs and schedules a save. | 306 // Sets the value of the specified path in prefs and schedules a save. |
| 306 void RecordBooleanPrefValue(const char* path, bool value); | 307 void RecordBooleanPrefValue(const char* path, bool value); |
| 307 | 308 |
| 309 // Returns true if process of type |type| should be counted as a plugin |
| 310 // process, and false otherwise. |
| 311 static bool IsPluginProcess(ChildProcessInfo::ProcessType type); |
| 312 |
| 308 content::NotificationRegistrar registrar_; | 313 content::NotificationRegistrar registrar_; |
| 309 | 314 |
| 310 // Indicate whether recording and reporting are currently happening. | 315 // Indicate whether recording and reporting are currently happening. |
| 311 // These should not be set directly, but by calling SetRecording and | 316 // These should not be set directly, but by calling SetRecording and |
| 312 // SetReporting. | 317 // SetReporting. |
| 313 bool recording_active_; | 318 bool recording_active_; |
| 314 bool reporting_active_; | 319 bool reporting_active_; |
| 315 | 320 |
| 316 // The progession of states made by the browser are recorded in the following | 321 // The progession of states made by the browser are recorded in the following |
| 317 // state. | 322 // state. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 | 383 |
| 379 #if defined(OS_CHROMEOS) | 384 #if defined(OS_CHROMEOS) |
| 380 // The external metric service is used to log ChromeOS UMA events. | 385 // The external metric service is used to log ChromeOS UMA events. |
| 381 scoped_refptr<chromeos::ExternalMetrics> external_metrics_; | 386 scoped_refptr<chromeos::ExternalMetrics> external_metrics_; |
| 382 #endif | 387 #endif |
| 383 | 388 |
| 384 // Reduntant marker to check that we completed our shutdown, and set the | 389 // Reduntant marker to check that we completed our shutdown, and set the |
| 385 // exited-cleanly bit in the prefs. | 390 // exited-cleanly bit in the prefs. |
| 386 static ShutdownCleanliness clean_shutdown_status_; | 391 static ShutdownCleanliness clean_shutdown_status_; |
| 387 | 392 |
| 388 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, ClientIdGeneratesAllZeroes); | |
| 389 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, ClientIdGeneratesCorrectly); | |
| 390 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, ClientIdCorrectlyFormatted); | 393 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, ClientIdCorrectlyFormatted); |
| 394 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess); |
| 391 | 395 |
| 392 DISALLOW_COPY_AND_ASSIGN(MetricsService); | 396 DISALLOW_COPY_AND_ASSIGN(MetricsService); |
| 393 }; | 397 }; |
| 394 | 398 |
| 395 // This class limits and documents access to the IsMetricsReportingEnabled() | 399 // This class limits and documents access to the IsMetricsReportingEnabled() |
| 396 // method. Since the method is private, each user has to be explicitly declared | 400 // method. Since the method is private, each user has to be explicitly declared |
| 397 // as a 'friend' below. | 401 // as a 'friend' below. |
| 398 class MetricsServiceHelper { | 402 class MetricsServiceHelper { |
| 399 private: | 403 private: |
| 400 friend class InstantFieldTrial; | 404 friend class InstantFieldTrial; |
| 401 friend bool prerender::IsOmniboxEnabled(Profile* profile); | 405 friend bool prerender::IsOmniboxEnabled(Profile* profile); |
| 402 | 406 |
| 403 // Returns true if prefs::kMetricsReportingEnabled is set. | 407 // Returns true if prefs::kMetricsReportingEnabled is set. |
| 404 static bool IsMetricsReportingEnabled(); | 408 static bool IsMetricsReportingEnabled(); |
| 405 | 409 |
| 406 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); | 410 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); |
| 407 }; | 411 }; |
| 408 | 412 |
| 409 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ | 413 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ |
| OLD | NEW |