Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1116)

Side by Side Diff: components/metrics/metrics_service.h

Issue 922383003: Enable UMA log uploads for cellular networks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Callback to set connection type in the scheduler Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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);
250
251 // Returns true if the connection type is 2G, 3G, or 4G.
252 bool IsCellularConnection();
253
254 // Passes the indicator of connection type to the scheduler.
255 void UpdateSchedulerConnectionType();
256
245 protected: 257 protected:
246 // Exposed for testing. 258 // Exposed for testing.
247 MetricsLogManager* log_manager() { return &log_manager_; } 259 MetricsLogManager* log_manager() { return &log_manager_; }
248 260
249 private: 261 private:
250 // The MetricsService has a lifecycle that is stored as a state. 262 // The MetricsService has a lifecycle that is stored as a state.
251 // See metrics_service.cc for description of this lifecycle. 263 // See metrics_service.cc for description of this lifecycle.
252 enum State { 264 enum State {
253 INITIALIZED, // Constructor was called. 265 INITIALIZED, // Constructor was called.
254 INIT_TASK_SCHEDULED, // Waiting for deferred init tasks to 266 INIT_TASK_SCHEDULED, // Waiting for deferred init tasks to
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 // List of observers of |synthetic_trial_groups_| changes. 486 // List of observers of |synthetic_trial_groups_| changes.
475 ObserverList<SyntheticTrialObserver> synthetic_trial_observer_list_; 487 ObserverList<SyntheticTrialObserver> synthetic_trial_observer_list_;
476 488
477 // Execution phase the browser is in. 489 // Execution phase the browser is in.
478 static ExecutionPhase execution_phase_; 490 static ExecutionPhase execution_phase_;
479 491
480 // Reduntant marker to check that we completed our shutdown, and set the 492 // Reduntant marker to check that we completed our shutdown, and set the
481 // exited-cleanly bit in the prefs. 493 // exited-cleanly bit in the prefs.
482 static ShutdownCleanliness clean_shutdown_status_; 494 static ShutdownCleanliness clean_shutdown_status_;
483 495
496 const NetworkMetricsProvider* network_metrics_provider_;
497
484 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess); 498 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess);
485 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, 499 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest,
486 PermutedEntropyCacheClearedWhenLowEntropyReset); 500 PermutedEntropyCacheClearedWhenLowEntropyReset);
487 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial); 501 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial);
488 502
489 // Weak pointers factory used to post task on different threads. All weak 503 // Weak pointers factory used to post task on different threads. All weak
490 // pointers managed by this factory have the same lifetime as MetricsService. 504 // pointers managed by this factory have the same lifetime as MetricsService.
491 base::WeakPtrFactory<MetricsService> self_ptr_factory_; 505 base::WeakPtrFactory<MetricsService> self_ptr_factory_;
492 506
493 // Weak pointers factory used for saving state. All weak pointers managed by 507 // Weak pointers factory used for saving state. All weak pointers managed by
494 // this factory are invalidated in ScheduleNextStateSave. 508 // this factory are invalidated in ScheduleNextStateSave.
495 base::WeakPtrFactory<MetricsService> state_saver_factory_; 509 base::WeakPtrFactory<MetricsService> state_saver_factory_;
496 510
497 DISALLOW_COPY_AND_ASSIGN(MetricsService); 511 DISALLOW_COPY_AND_ASSIGN(MetricsService);
498 }; 512 };
499 513
500 } // namespace metrics 514 } // namespace metrics
501 515
502 #endif // COMPONENTS_METRICS_METRICS_SERVICE_H_ 516 #endif // COMPONENTS_METRICS_METRICS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698