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

Side by Side Diff: chrome/browser/metrics/metrics_service.h

Issue 291153013: Make MetricsService upload logs through an interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 10
(...skipping 14 matching lines...) Expand all
25 #include "base/observer_list.h" 25 #include "base/observer_list.h"
26 #include "base/strings/string16.h" 26 #include "base/strings/string16.h"
27 #include "base/threading/thread_checker.h" 27 #include "base/threading/thread_checker.h"
28 #include "base/time/time.h" 28 #include "base/time/time.h"
29 #include "chrome/browser/metrics/metrics_log.h" 29 #include "chrome/browser/metrics/metrics_log.h"
30 #include "chrome/browser/metrics/tracking_synchronizer_observer.h" 30 #include "chrome/browser/metrics/tracking_synchronizer_observer.h"
31 #include "components/metrics/metrics_log_manager.h" 31 #include "components/metrics/metrics_log_manager.h"
32 #include "components/metrics/metrics_provider.h" 32 #include "components/metrics/metrics_provider.h"
33 #include "components/metrics/metrics_service_observer.h" 33 #include "components/metrics/metrics_service_observer.h"
34 #include "components/variations/active_field_trials.h" 34 #include "components/variations/active_field_trials.h"
35 #include "net/url_request/url_fetcher_delegate.h"
36 35
37 class GoogleUpdateMetricsProviderWin; 36 class GoogleUpdateMetricsProviderWin;
38 class MetricsReportingScheduler; 37 class MetricsReportingScheduler;
39 class PrefService; 38 class PrefService;
40 class PrefRegistrySimple; 39 class PrefRegistrySimple;
41 class PluginMetricsProvider; 40 class PluginMetricsProvider;
42 41
43 namespace base { 42 namespace base {
44 class DictionaryValue; 43 class DictionaryValue;
45 class HistogramSamples; 44 class HistogramSamples;
46 class MessageLoopProxy; 45 class MessageLoopProxy;
47 } 46 }
48 47
49 namespace variations { 48 namespace variations {
50 struct ActiveGroupId; 49 struct ActiveGroupId;
51 } 50 }
52 51
53 namespace content { 52 namespace content {
54 } 53 }
55 54
56 namespace metrics { 55 namespace metrics {
56 class MetricsLogUploader;
57 class MetricsServiceClient; 57 class MetricsServiceClient;
58 class MetricsStateManager; 58 class MetricsStateManager;
59 } 59 }
60 60
61 namespace net { 61 namespace net {
62 class URLFetcher; 62 class URLFetcher;
63 } 63 }
64 64
65 namespace tracked_objects { 65 namespace tracked_objects {
66 struct ProcessDataSnapshot; 66 struct ProcessDataSnapshot;
(...skipping 14 matching lines...) Expand all
81 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial); 81 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial);
82 82
83 // This constructor is private specifically so as to control which code is 83 // This constructor is private specifically so as to control which code is
84 // able to access it. New code that wishes to use it should be added as a 84 // able to access it. New code that wishes to use it should be added as a
85 // friend class. 85 // friend class.
86 SyntheticTrialGroup(uint32 trial, uint32 group); 86 SyntheticTrialGroup(uint32 trial, uint32 group);
87 }; 87 };
88 88
89 class MetricsService 89 class MetricsService
90 : public base::HistogramFlattener, 90 : public base::HistogramFlattener,
91 public chrome_browser_metrics::TrackingSynchronizerObserver, 91 public chrome_browser_metrics::TrackingSynchronizerObserver {
92 public net::URLFetcherDelegate {
93 public: 92 public:
94 // The execution phase of the browser. 93 // The execution phase of the browser.
95 enum ExecutionPhase { 94 enum ExecutionPhase {
96 UNINITIALIZED_PHASE = 0, 95 UNINITIALIZED_PHASE = 0,
97 START_METRICS_RECORDING = 100, 96 START_METRICS_RECORDING = 100,
98 CREATE_PROFILE = 200, 97 CREATE_PROFILE = 200,
99 STARTUP_TIMEBOMB_ARM = 300, 98 STARTUP_TIMEBOMB_ARM = 300,
100 THREAD_WATCHER_START = 400, 99 THREAD_WATCHER_START = 400,
101 MAIN_MESSAGE_LOOP_RUN = 500, 100 MAIN_MESSAGE_LOOP_RUN = 500,
102 SHUTDOWN_TIMEBOMB_ARM = 600, 101 SHUTDOWN_TIMEBOMB_ARM = 600,
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 // system profile from the previous session. 349 // system profile from the previous session.
351 void PrepareInitialStabilityLog(); 350 void PrepareInitialStabilityLog();
352 351
353 // Prepares the initial metrics log, which includes startup histograms and 352 // Prepares the initial metrics log, which includes startup histograms and
354 // profiler data, as well as incremental stability-related metrics. 353 // profiler data, as well as incremental stability-related metrics.
355 void PrepareInitialMetricsLog(); 354 void PrepareInitialMetricsLog();
356 355
357 // Uploads the currently staged log (which must be non-null). 356 // Uploads the currently staged log (which must be non-null).
358 void SendStagedLog(); 357 void SendStagedLog();
359 358
360 // Prepared the staged log to be passed to the server. Upon return, 359 // Called after transmission completes (either successfully or with failure).
361 // current_fetch_ should be reset with its upload data set to a compressed 360 void OnLogUploadComplete(int response_code);
362 // copy of the staged log.
363 void PrepareFetchWithStagedLog();
364
365 // Implementation of net::URLFetcherDelegate. Called after transmission
366 // completes (either successfully or with failure).
367 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
368 361
369 // Reads, increments and then sets the specified integer preference. 362 // Reads, increments and then sets the specified integer preference.
370 void IncrementPrefValue(const char* path); 363 void IncrementPrefValue(const char* path);
371 364
372 // Reads, increments and then sets the specified long preference that is 365 // Reads, increments and then sets the specified long preference that is
373 // stored as a string. 366 // stored as a string.
374 void IncrementLongPrefsValue(const char* path); 367 void IncrementLongPrefsValue(const char* path);
375 368
376 // Records that the browser was shut down cleanly. 369 // Records that the browser was shut down cleanly.
377 void LogCleanShutdown(); 370 void LogCleanShutdown();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 443
451 #if defined(OS_WIN) 444 #if defined(OS_WIN)
452 GoogleUpdateMetricsProviderWin* google_update_metrics_provider_; 445 GoogleUpdateMetricsProviderWin* google_update_metrics_provider_;
453 #endif 446 #endif
454 447
455 // The initial metrics log, used to record startup metrics (histograms and 448 // The initial metrics log, used to record startup metrics (histograms and
456 // profiler data). Note that if a crash occurred in the previous session, an 449 // profiler data). Note that if a crash occurred in the previous session, an
457 // initial stability log may be sent before this. 450 // initial stability log may be sent before this.
458 scoped_ptr<MetricsLog> initial_metrics_log_; 451 scoped_ptr<MetricsLog> initial_metrics_log_;
459 452
460 // The outstanding transmission appears as a URL Fetch operation. 453 // Instance of the helper class for uploading logs.
461 scoped_ptr<net::URLFetcher> current_fetch_; 454 scoped_ptr<metrics::MetricsLogUploader> log_uploader_;
455
456 // Whether there is a current log upload in progress.
457 bool log_upload_in_progress_;
462 458
463 // Whether the MetricsService object has received any notifications since 459 // Whether the MetricsService object has received any notifications since
464 // the last time a transmission was sent. 460 // the last time a transmission was sent.
465 bool idle_since_last_transmission_; 461 bool idle_since_last_transmission_;
466 462
467 // A number that identifies the how many times the app has been launched. 463 // A number that identifies the how many times the app has been launched.
468 int session_id_; 464 int session_id_;
469 465
470 // Maps WebContentses (corresponding to tabs) or Browsers (corresponding to 466 // Maps WebContentses (corresponding to tabs) or Browsers (corresponding to
471 // Windows) to a unique integer that we will use to identify them. 467 // Windows) to a unique integer that we will use to identify them.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess); 511 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess);
516 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, MetricsServiceObserver); 512 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, MetricsServiceObserver);
517 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, 513 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest,
518 PermutedEntropyCacheClearedWhenLowEntropyReset); 514 PermutedEntropyCacheClearedWhenLowEntropyReset);
519 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial); 515 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial);
520 516
521 DISALLOW_COPY_AND_ASSIGN(MetricsService); 517 DISALLOW_COPY_AND_ASSIGN(MetricsService);
522 }; 518 };
523 519
524 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ 520 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698