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

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

Powered by Google App Engine
This is Rietveld 408576698