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

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

Issue 9702015: [UMA] Add performance profile data to UMA uploads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix BASE_EXPORT usage Created 8 years, 8 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 #pragma once 10 #pragma once
11 11
12 #include <map> 12 #include <map>
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/basictypes.h" 16 #include "base/basictypes.h"
17 #include "base/gtest_prod_util.h" 17 #include "base/gtest_prod_util.h"
18 #include "base/memory/weak_ptr.h"
19 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
20 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
21 #include "base/process_util.h" 20 #include "base/process_util.h"
21 #include "chrome/browser/metrics/tracking_synchronizer_observer.h"
22 #include "chrome/common/metrics/metrics_service_base.h" 22 #include "chrome/common/metrics/metrics_service_base.h"
23 #include "content/public/common/process_type.h"
24 #include "content/public/common/url_fetcher_delegate.h"
25 #include "content/public/browser/notification_observer.h" 23 #include "content/public/browser/notification_observer.h"
26 #include "content/public/browser/notification_registrar.h" 24 #include "content/public/browser/notification_registrar.h"
25 #include "content/public/common/url_fetcher_delegate.h"
27 26
28 #if defined(OS_CHROMEOS) 27 #if defined(OS_CHROMEOS)
29 #include "chrome/browser/chromeos/external_metrics.h" 28 #include "chrome/browser/chromeos/external_metrics.h"
30 #endif 29 #endif
31 30
32 class BookmarkModel; 31 class BookmarkModel;
33 class BookmarkNode; 32 class BookmarkNode;
33 class MetricsLog;
34 class MetricsReportingScheduler; 34 class MetricsReportingScheduler;
35 class PrefService; 35 class PrefService;
36 class Profile; 36 class Profile;
37 class TemplateURLService; 37 class TemplateURLService;
38 38
39 namespace base { 39 namespace base {
40 class DictionaryValue; 40 class DictionaryValue;
41 class MessageLoopProxy; 41 class MessageLoopProxy;
42 } 42 }
43 43
44 namespace content { 44 namespace content {
45 class RenderProcessHost; 45 class RenderProcessHost;
46 } 46 }
47 47
48 namespace extensions { 48 namespace extensions {
49 class ExtensionDownloader; 49 class ExtensionDownloader;
50 } 50 }
51 51
52 namespace prerender { 52 namespace prerender {
53 bool IsOmniboxEnabled(Profile* profile); 53 bool IsOmniboxEnabled(Profile* profile);
54 } 54 }
55 55
56 namespace tracked_objects {
57 struct ProcessDataSnapshot;
58 }
59
56 namespace webkit { 60 namespace webkit {
57 struct WebPluginInfo; 61 struct WebPluginInfo;
58 } 62 }
59 63
60 64 class MetricsService
61 class MetricsService : public content::NotificationObserver, 65 : public chrome_browser_metrics::TrackingSynchronizerObserver,
62 public content::URLFetcherDelegate, 66 public content::NotificationObserver,
63 public MetricsServiceBase { 67 public content::URLFetcherDelegate,
68 public MetricsServiceBase {
64 public: 69 public:
65 MetricsService(); 70 MetricsService();
66 virtual ~MetricsService(); 71 virtual ~MetricsService();
67 72
68 // Start/stop the metrics recording and uploading machine. These should be 73 // Start/stop the metrics recording and uploading machine. These should be
69 // used on startup and when the user clicks the checkbox in the prefs. 74 // used on startup and when the user clicks the checkbox in the prefs.
70 // StartRecordingOnly starts the metrics recording but not reporting, for use 75 // StartRecordingOnly starts the metrics recording but not reporting, for use
71 // in tests only. 76 // in tests only.
72 void Start(); 77 void Start();
73 void StartRecordingOnly(); 78 void StartRecordingOnly();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 159
155 // First part of the init task. Called on the FILE thread to load hardware 160 // First part of the init task. Called on the FILE thread to load hardware
156 // class information. 161 // class information.
157 static void InitTaskGetHardwareClass(base::WeakPtr<MetricsService> self, 162 static void InitTaskGetHardwareClass(base::WeakPtr<MetricsService> self,
158 base::MessageLoopProxy* target_loop); 163 base::MessageLoopProxy* target_loop);
159 164
160 // Callback from InitTaskGetHardwareClass() that continues the init task by 165 // Callback from InitTaskGetHardwareClass() that continues the init task by
161 // loading plugin information. 166 // loading plugin information.
162 void OnInitTaskGotHardwareClass(const std::string& hardware_class); 167 void OnInitTaskGotHardwareClass(const std::string& hardware_class);
163 168
164 // Callback from PluginService::GetPlugins() that moves the state to 169 // Callback from PluginService::GetPlugins() that continues the init task by
165 // INIT_TASK_DONE. 170 // loading profiler data.
166 void OnInitTaskGotPluginInfo( 171 void OnInitTaskGotPluginInfo(
167 const std::vector<webkit::WebPluginInfo>& plugins); 172 const std::vector<webkit::WebPluginInfo>& plugins);
168 173
174 // TrackingSynchronizerObserver:
175 virtual void ReceivedProfilerData(
176 const tracked_objects::ProcessDataSnapshot& process_data,
177 content::ProcessType process_type) OVERRIDE;
178 // Callback that moves the state to INIT_TASK_DONE.
179 virtual void FinishedReceivingProfilerData() OVERRIDE;
180
169 // When we start a new version of Chromium (different from our last run), we 181 // When we start a new version of Chromium (different from our last run), we
170 // need to discard the old crash stats so that we don't attribute crashes etc. 182 // need to discard the old crash stats so that we don't attribute crashes etc.
171 // in the old version to the current version (via current logs). 183 // in the old version to the current version (via current logs).
172 // Without this, a common reason to finally start a new version is to crash 184 // Without this, a common reason to finally start a new version is to crash
173 // the old version (after an autoupdate has arrived), and so we'd bias 185 // the old version (after an autoupdate has arrived), and so we'd bias
174 // initial results towards showing crashes :-(. 186 // initial results towards showing crashes :-(.
175 static void DiscardOldStabilityStats(PrefService* local_state); 187 static void DiscardOldStabilityStats(PrefService* local_state);
176 188
177 // Sets and gets whether metrics recording is active. 189 // Sets and gets whether metrics recording is active.
178 // SetRecording(false) also forces a persistent save of logging state (if 190 // SetRecording(false) also forces a persistent save of logging state (if
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 352
341 // Chrome OS hardware class (e.g., hardware qualification ID). This 353 // Chrome OS hardware class (e.g., hardware qualification ID). This
342 // class identifies the configured system components such as CPU, 354 // class identifies the configured system components such as CPU,
343 // WiFi adapter, etc. For non Chrome OS hosts, this will be an 355 // WiFi adapter, etc. For non Chrome OS hosts, this will be an
344 // empty string. 356 // empty string.
345 std::string hardware_class_; 357 std::string hardware_class_;
346 358
347 // The list of plugins which was retrieved on the file thread. 359 // The list of plugins which was retrieved on the file thread.
348 std::vector<webkit::WebPluginInfo> plugins_; 360 std::vector<webkit::WebPluginInfo> plugins_;
349 361
362 // The initial log, used to record startup metrics.
363 scoped_ptr<MetricsLog> initial_log_;
364
350 // The outstanding transmission appears as a URL Fetch operation. 365 // The outstanding transmission appears as a URL Fetch operation.
351 scoped_ptr<content::URLFetcher> current_fetch_xml_; 366 scoped_ptr<content::URLFetcher> current_fetch_xml_;
352 scoped_ptr<content::URLFetcher> current_fetch_proto_; 367 scoped_ptr<content::URLFetcher> current_fetch_proto_;
353 368
354 // Cached responses from the XML request while we wait for a response to the 369 // Cached responses from the XML request while we wait for a response to the
355 // protubuf request. 370 // protubuf request.
356 int response_code_; 371 int response_code_;
357 std::string response_status_; 372 std::string response_status_;
358 std::string response_data_; 373 std::string response_data_;
359 374
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 friend bool prerender::IsOmniboxEnabled(Profile* profile); 447 friend bool prerender::IsOmniboxEnabled(Profile* profile);
433 friend class extensions::ExtensionDownloader; 448 friend class extensions::ExtensionDownloader;
434 449
435 // Returns true if prefs::kMetricsReportingEnabled is set. 450 // Returns true if prefs::kMetricsReportingEnabled is set.
436 static bool IsMetricsReportingEnabled(); 451 static bool IsMetricsReportingEnabled();
437 452
438 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); 453 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper);
439 }; 454 };
440 455
441 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ 456 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_log_unittest.cc ('k') | chrome/browser/metrics/metrics_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698