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 connection type callback. | |
Alexei Svitkine (slow)
2015/02/23 20:18:15
Nit: Mention "that will be passed down to the sche
gayane -on leave until 09-2017
2015/02/23 20:27:53
Done.
| |
247 void SetConnectionTypeCallback( | |
248 base::Callback<void(bool*)> is_cellular_callback); | |
249 | |
245 protected: | 250 protected: |
246 // Exposed for testing. | 251 // Exposed for testing. |
247 MetricsLogManager* log_manager() { return &log_manager_; } | 252 MetricsLogManager* log_manager() { return &log_manager_; } |
248 | 253 |
249 private: | 254 private: |
250 // The MetricsService has a lifecycle that is stored as a state. | 255 // The MetricsService has a lifecycle that is stored as a state. |
251 // See metrics_service.cc for description of this lifecycle. | 256 // See metrics_service.cc for description of this lifecycle. |
252 enum State { | 257 enum State { |
253 INITIALIZED, // Constructor was called. | 258 INITIALIZED, // Constructor was called. |
254 INIT_TASK_SCHEDULED, // Waiting for deferred init tasks to | 259 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. | 479 // List of observers of |synthetic_trial_groups_| changes. |
475 ObserverList<SyntheticTrialObserver> synthetic_trial_observer_list_; | 480 ObserverList<SyntheticTrialObserver> synthetic_trial_observer_list_; |
476 | 481 |
477 // Execution phase the browser is in. | 482 // Execution phase the browser is in. |
478 static ExecutionPhase execution_phase_; | 483 static ExecutionPhase execution_phase_; |
479 | 484 |
480 // Reduntant marker to check that we completed our shutdown, and set the | 485 // Reduntant marker to check that we completed our shutdown, and set the |
481 // exited-cleanly bit in the prefs. | 486 // exited-cleanly bit in the prefs. |
482 static ShutdownCleanliness clean_shutdown_status_; | 487 static ShutdownCleanliness clean_shutdown_status_; |
483 | 488 |
489 // Callback function used to get current network connection type. | |
490 base::Callback<void(bool*)> is_cellular_callback_; | |
491 | |
484 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess); | 492 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess); |
485 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, | 493 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, |
486 PermutedEntropyCacheClearedWhenLowEntropyReset); | 494 PermutedEntropyCacheClearedWhenLowEntropyReset); |
487 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial); | 495 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial); |
488 | 496 |
489 // Weak pointers factory used to post task on different threads. All weak | 497 // Weak pointers factory used to post task on different threads. All weak |
490 // pointers managed by this factory have the same lifetime as MetricsService. | 498 // pointers managed by this factory have the same lifetime as MetricsService. |
491 base::WeakPtrFactory<MetricsService> self_ptr_factory_; | 499 base::WeakPtrFactory<MetricsService> self_ptr_factory_; |
492 | 500 |
493 // Weak pointers factory used for saving state. All weak pointers managed by | 501 // Weak pointers factory used for saving state. All weak pointers managed by |
494 // this factory are invalidated in ScheduleNextStateSave. | 502 // this factory are invalidated in ScheduleNextStateSave. |
495 base::WeakPtrFactory<MetricsService> state_saver_factory_; | 503 base::WeakPtrFactory<MetricsService> state_saver_factory_; |
496 | 504 |
497 DISALLOW_COPY_AND_ASSIGN(MetricsService); | 505 DISALLOW_COPY_AND_ASSIGN(MetricsService); |
498 }; | 506 }; |
499 | 507 |
500 } // namespace metrics | 508 } // namespace metrics |
501 | 509 |
502 #endif // COMPONENTS_METRICS_METRICS_SERVICE_H_ | 510 #endif // COMPONENTS_METRICS_METRICS_SERVICE_H_ |
OLD | NEW |