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

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: fix for IOS 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 network metrics provider and registers it as a provider.
247 void SetNetworkMetricsProvider(
248 scoped_ptr<NetworkMetricsProvider> network_metrics_provider);
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 void RecordCurrentEnvironment(MetricsLog* log); 399 void RecordCurrentEnvironment(MetricsLog* log);
395 400
396 // Record complete list of histograms into the current log. 401 // Record complete list of histograms into the current log.
397 // Called when we close a log. 402 // Called when we close a log.
398 void RecordCurrentHistograms(); 403 void RecordCurrentHistograms();
399 404
400 // Record complete list of stability histograms into the current log, 405 // Record complete list of stability histograms into the current log,
401 // i.e., histograms with the |kUmaStabilityHistogramFlag| flag set. 406 // i.e., histograms with the |kUmaStabilityHistogramFlag| flag set.
402 void RecordCurrentStabilityHistograms(); 407 void RecordCurrentStabilityHistograms();
403 408
409 // Returns true if the connection type is 2G, 3G, or 4G.
410 bool IsCellularConnection();
411
412 // Assigns the passed |is_cellular_out| parameter based on whether current
413 // network connection is cellular.
414 void GetIsCellularConnection(bool* is_cellular_out);
415
404 // Manager for the various in-flight logs. 416 // Manager for the various in-flight logs.
405 MetricsLogManager log_manager_; 417 MetricsLogManager log_manager_;
406 418
407 // |histogram_snapshot_manager_| prepares histogram deltas for transmission. 419 // |histogram_snapshot_manager_| prepares histogram deltas for transmission.
408 base::HistogramSnapshotManager histogram_snapshot_manager_; 420 base::HistogramSnapshotManager histogram_snapshot_manager_;
409 421
410 // Used to manage various metrics reporting state prefs, such as client id, 422 // Used to manage various metrics reporting state prefs, such as client id,
411 // low entropy source and whether metrics reporting is enabled. Weak pointer. 423 // low entropy source and whether metrics reporting is enabled. Weak pointer.
412 MetricsStateManager* const state_manager_; 424 MetricsStateManager* const state_manager_;
413 425
(...skipping 60 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 // Network metrics provider used for getting current connection type.
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698