Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_METRICS_METRICS_SERVICE_H_ | 8 #ifndef COMPONENTS_METRICS_METRICS_SERVICE_H_ |
| 9 #define COMPONENTS_METRICS_METRICS_SERVICE_H_ | 9 #define COMPONENTS_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/scoped_vector.h" | 18 #include "base/memory/scoped_vector.h" |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 20 #include "base/metrics/field_trial.h" | 20 #include "base/metrics/field_trial.h" |
| 21 #include "base/metrics/histogram_flattener.h" | 21 #include "base/metrics/histogram_flattener.h" |
| 22 #include "base/metrics/histogram_snapshot_manager.h" | 22 #include "base/metrics/histogram_snapshot_manager.h" |
| 23 #include "base/metrics/user_metrics.h" | 23 #include "base/metrics/user_metrics.h" |
| 24 #include "base/observer_list.h" | 24 #include "base/observer_list.h" |
| 25 #include "base/time/time.h" | 25 #include "base/time/time.h" |
| 26 #include "components/metrics/clean_exit_beacon.h" | 26 #include "components/metrics/clean_exit_beacon.h" |
| 27 #include "components/metrics/metrics_log.h" | 27 #include "components/metrics/metrics_log.h" |
| 28 #include "components/metrics/metrics_log_manager.h" | 28 #include "components/metrics/metrics_log_manager.h" |
| 29 #include "components/metrics/metrics_provider.h" | 29 #include "components/metrics/metrics_provider.h" |
| 30 #include "components/metrics/net/network_metrics_provider.h" | |
| 30 #include "components/variations/active_field_trials.h" | 31 #include "components/variations/active_field_trials.h" |
| 31 | 32 |
| 32 class MetricsServiceAccessor; | 33 class MetricsServiceAccessor; |
| 33 class PrefService; | 34 class PrefService; |
| 34 class PrefRegistrySimple; | 35 class PrefRegistrySimple; |
| 35 | 36 |
| 36 namespace base { | 37 namespace base { |
| 37 class DictionaryValue; | 38 class DictionaryValue; |
| 38 class HistogramSamples; | 39 class HistogramSamples; |
| 39 class MessageLoopProxy; | 40 class MessageLoopProxy; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 | 236 |
| 236 // Check if this install was cloned or imaged from another machine. If a | 237 // Check if this install was cloned or imaged from another machine. If a |
| 237 // clone is detected, reset the client id and low entropy source. This | 238 // clone is detected, reset the client id and low entropy source. This |
| 238 // should not be called more than once. | 239 // should not be called more than once. |
| 239 void CheckForClonedInstall( | 240 void CheckForClonedInstall( |
| 240 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | 241 scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
| 241 | 242 |
| 242 // Clears the stability metrics that are saved in local state. | 243 // Clears the stability metrics that are saved in local state. |
| 243 void ClearSavedStabilityMetrics(); | 244 void ClearSavedStabilityMetrics(); |
| 244 | 245 |
| 246 // Sets the pointer for network_metrics_provider for passing it through to | |
| 247 // scheduler when it is initialized. | |
| 248 void SetNetworkMetricsProvider( | |
| 249 NetworkMetricsProvider* network_metrics_provider); | |
|
Alexei Svitkine (slow)
2015/02/18 03:26:23
Pass the param by scoped_ptr to indicate transfer
gayane -on leave until 09-2017
2015/02/18 21:38:23
Done.
| |
| 250 | |
| 251 // Returns true if the connection type is 2G, 3G, or 4G. | |
| 252 bool IsCellularConnection(); | |
| 253 | |
| 254 // Assigns the passed |is_cellular_out| parameter whether current network | |
| 255 // connection is cellular. | |
| 256 void GetIsCellularConnection(bool* is_cellular_out); | |
| 257 | |
| 245 protected: | 258 protected: |
| 246 // Exposed for testing. | 259 // Exposed for testing. |
| 247 MetricsLogManager* log_manager() { return &log_manager_; } | 260 MetricsLogManager* log_manager() { return &log_manager_; } |
| 248 | 261 |
| 249 private: | 262 private: |
| 250 // The MetricsService has a lifecycle that is stored as a state. | 263 // The MetricsService has a lifecycle that is stored as a state. |
| 251 // See metrics_service.cc for description of this lifecycle. | 264 // See metrics_service.cc for description of this lifecycle. |
| 252 enum State { | 265 enum State { |
| 253 INITIALIZED, // Constructor was called. | 266 INITIALIZED, // Constructor was called. |
| 254 INIT_TASK_SCHEDULED, // Waiting for deferred init tasks to | 267 INIT_TASK_SCHEDULED, // Waiting for deferred init tasks to |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 474 // List of observers of |synthetic_trial_groups_| changes. | 487 // List of observers of |synthetic_trial_groups_| changes. |
| 475 ObserverList<SyntheticTrialObserver> synthetic_trial_observer_list_; | 488 ObserverList<SyntheticTrialObserver> synthetic_trial_observer_list_; |
| 476 | 489 |
| 477 // Execution phase the browser is in. | 490 // Execution phase the browser is in. |
| 478 static ExecutionPhase execution_phase_; | 491 static ExecutionPhase execution_phase_; |
| 479 | 492 |
| 480 // Reduntant marker to check that we completed our shutdown, and set the | 493 // Reduntant marker to check that we completed our shutdown, and set the |
| 481 // exited-cleanly bit in the prefs. | 494 // exited-cleanly bit in the prefs. |
| 482 static ShutdownCleanliness clean_shutdown_status_; | 495 static ShutdownCleanliness clean_shutdown_status_; |
| 483 | 496 |
| 497 const NetworkMetricsProvider* network_metrics_provider_; | |
| 498 | |
| 484 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess); | 499 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess); |
| 485 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, | 500 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, |
| 486 PermutedEntropyCacheClearedWhenLowEntropyReset); | 501 PermutedEntropyCacheClearedWhenLowEntropyReset); |
| 487 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial); | 502 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial); |
| 488 | 503 |
| 489 // Weak pointers factory used to post task on different threads. All weak | 504 // Weak pointers factory used to post task on different threads. All weak |
| 490 // pointers managed by this factory have the same lifetime as MetricsService. | 505 // pointers managed by this factory have the same lifetime as MetricsService. |
| 491 base::WeakPtrFactory<MetricsService> self_ptr_factory_; | 506 base::WeakPtrFactory<MetricsService> self_ptr_factory_; |
| 492 | 507 |
| 493 // Weak pointers factory used for saving state. All weak pointers managed by | 508 // Weak pointers factory used for saving state. All weak pointers managed by |
| 494 // this factory are invalidated in ScheduleNextStateSave. | 509 // this factory are invalidated in ScheduleNextStateSave. |
| 495 base::WeakPtrFactory<MetricsService> state_saver_factory_; | 510 base::WeakPtrFactory<MetricsService> state_saver_factory_; |
| 496 | 511 |
| 497 DISALLOW_COPY_AND_ASSIGN(MetricsService); | 512 DISALLOW_COPY_AND_ASSIGN(MetricsService); |
| 498 }; | 513 }; |
| 499 | 514 |
| 500 } // namespace metrics | 515 } // namespace metrics |
| 501 | 516 |
| 502 #endif // COMPONENTS_METRICS_METRICS_SERVICE_H_ | 517 #endif // COMPONENTS_METRICS_METRICS_SERVICE_H_ |
| OLD | NEW |