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

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

Issue 299783004: Create PluginMetricsProvider class. (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 23 matching lines...) Expand all
34 #include "content/public/browser/notification_registrar.h" 34 #include "content/public/browser/notification_registrar.h"
35 #include "content/public/browser/user_metrics.h" 35 #include "content/public/browser/user_metrics.h"
36 #include "net/url_request/url_fetcher_delegate.h" 36 #include "net/url_request/url_fetcher_delegate.h"
37 37
38 class ChromeBrowserMetricsServiceObserver; 38 class ChromeBrowserMetricsServiceObserver;
39 class GoogleUpdateMetricsProviderWin; 39 class GoogleUpdateMetricsProviderWin;
40 class MetricsReportingScheduler; 40 class MetricsReportingScheduler;
41 class PrefService; 41 class PrefService;
42 class PrefRegistrySimple; 42 class PrefRegistrySimple;
43 class Profile; 43 class Profile;
44 class PluginMetricsProvider;
44 class TemplateURLService; 45 class TemplateURLService;
45 46
46 namespace { 47 namespace {
47 class CrashesDOMHandler; 48 class CrashesDOMHandler;
48 class FlashDOMHandler; 49 class FlashDOMHandler;
49 } 50 }
50 51
51 namespace base { 52 namespace base {
52 class DictionaryValue; 53 class DictionaryValue;
53 class MessageLoopProxy; 54 class MessageLoopProxy;
54 } 55 }
55 56
56 namespace variations { 57 namespace variations {
57 struct ActiveGroupId; 58 struct ActiveGroupId;
58 } 59 }
59 60
60 namespace content { 61 namespace content {
61 class RenderProcessHost; 62 class RenderProcessHost;
62 class WebContents; 63 class WebContents;
63 struct WebPluginInfo;
64 } 64 }
65 65
66 namespace extensions { 66 namespace extensions {
67 class ExtensionDownloader; 67 class ExtensionDownloader;
68 class ManifestFetchData; 68 class ManifestFetchData;
69 class MetricsPrivateGetIsCrashReportingEnabledFunction; 69 class MetricsPrivateGetIsCrashReportingEnabledFunction;
70 } 70 }
71 71
72 namespace metrics { 72 namespace metrics {
73 class MetricsServiceClient; 73 class MetricsServiceClient;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 // types we'll be using. 185 // types we'll be using.
186 static void RegisterPrefs(PrefRegistrySimple* registry); 186 static void RegisterPrefs(PrefRegistrySimple* registry);
187 187
188 // Set up notifications which indicate that a user is performing work. This is 188 // Set up notifications which indicate that a user is performing work. This is
189 // useful to allow some features to sleep, until the machine becomes active, 189 // useful to allow some features to sleep, until the machine becomes active,
190 // such as precluding UMA uploads unless there was recent activity. 190 // such as precluding UMA uploads unless there was recent activity.
191 static void SetUpNotifications(content::NotificationRegistrar* registrar, 191 static void SetUpNotifications(content::NotificationRegistrar* registrar,
192 content::NotificationObserver* observer); 192 content::NotificationObserver* observer);
193 193
194 // Implementation of content::BrowserChildProcessObserver 194 // Implementation of content::BrowserChildProcessObserver
195 virtual void BrowserChildProcessHostConnected(
196 const content::ChildProcessData& data) OVERRIDE;
197 virtual void BrowserChildProcessCrashed( 195 virtual void BrowserChildProcessCrashed(
198 const content::ChildProcessData& data) OVERRIDE; 196 const content::ChildProcessData& data) OVERRIDE;
199 virtual void BrowserChildProcessInstanceCreated(
200 const content::ChildProcessData& data) OVERRIDE;
201 197
202 // Implementation of content::NotificationObserver 198 // Implementation of content::NotificationObserver
203 virtual void Observe(int type, 199 virtual void Observe(int type,
204 const content::NotificationSource& source, 200 const content::NotificationSource& source,
205 const content::NotificationDetails& details) OVERRIDE; 201 const content::NotificationDetails& details) OVERRIDE;
206 202
207 // This should be called when the application is not idle, i.e. the user seems 203 // This should be called when the application is not idle, i.e. the user seems
208 // to be interacting with the application. 204 // to be interacting with the application.
209 void OnApplicationNotIdle(); 205 void OnApplicationNotIdle();
210 206
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 SENDING_INITIAL_METRICS_LOG, // Initial metrics log being sent. 285 SENDING_INITIAL_METRICS_LOG, // Initial metrics log being sent.
290 SENDING_OLD_LOGS, // Sending unsent logs from last session. 286 SENDING_OLD_LOGS, // Sending unsent logs from last session.
291 SENDING_CURRENT_LOGS, // Sending ongoing logs as they accrue. 287 SENDING_CURRENT_LOGS, // Sending ongoing logs as they accrue.
292 }; 288 };
293 289
294 enum ShutdownCleanliness { 290 enum ShutdownCleanliness {
295 CLEANLY_SHUTDOWN = 0xdeadbeef, 291 CLEANLY_SHUTDOWN = 0xdeadbeef,
296 NEED_TO_SHUTDOWN = ~CLEANLY_SHUTDOWN 292 NEED_TO_SHUTDOWN = ~CLEANLY_SHUTDOWN
297 }; 293 };
298 294
299 struct ChildProcessStats;
300
301 typedef std::vector<SyntheticTrialGroup> SyntheticTrialGroups; 295 typedef std::vector<SyntheticTrialGroup> SyntheticTrialGroups;
302 296
303 // First part of the init task. Called on the FILE thread to load hardware 297 // First part of the init task. Called on the FILE thread to load hardware
304 // class information. 298 // class information.
305 static void InitTaskGetHardwareClass(base::WeakPtr<MetricsService> self, 299 static void InitTaskGetHardwareClass(base::WeakPtr<MetricsService> self,
306 base::MessageLoopProxy* target_loop); 300 base::MessageLoopProxy* target_loop);
307 301
308 // Callback from InitTaskGetHardwareClass() that continues the init task by 302 // Callback from InitTaskGetHardwareClass() that continues the init task by
309 // loading plugin information. 303 // loading plugin information.
310 void OnInitTaskGotHardwareClass(const std::string& hardware_class); 304 void OnInitTaskGotHardwareClass(const std::string& hardware_class);
311 305
312 // Callback from PluginService::GetPlugins() that continues the init task by 306 // Called after the Plugin init task has been completed that continues the
313 // launching a task to gather Google Update statistics. 307 // init task by launching a task to gather Google Update statistics.
314 void OnInitTaskGotPluginInfo( 308 void OnInitTaskGotPluginInfo();
315 const std::vector<content::WebPluginInfo>& plugins);
316 309
317 // Called after GoogleUpdate init task has been completed that continues the 310 // Called after GoogleUpdate init task has been completed that continues the
318 // init task by loading profiler data. 311 // init task by loading profiler data.
319 void OnInitTaskGotGoogleUpdateData(); 312 void OnInitTaskGotGoogleUpdateData();
320 313
321 void OnUserAction(const std::string& action); 314 void OnUserAction(const std::string& action);
322 315
323 // TrackingSynchronizerObserver: 316 // TrackingSynchronizerObserver:
324 virtual void ReceivedProfilerData( 317 virtual void ReceivedProfilerData(
325 const tracked_objects::ProcessDataSnapshot& process_data, 318 const tracked_objects::ProcessDataSnapshot& process_data,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 void LogRendererCrash(content::RenderProcessHost* host, 422 void LogRendererCrash(content::RenderProcessHost* host,
430 base::TerminationStatus status, 423 base::TerminationStatus status,
431 int exit_code); 424 int exit_code);
432 425
433 // Records a renderer process hang. 426 // Records a renderer process hang.
434 void LogRendererHang(); 427 void LogRendererHang();
435 428
436 // Records that the browser was shut down cleanly. 429 // Records that the browser was shut down cleanly.
437 void LogCleanShutdown(); 430 void LogCleanShutdown();
438 431
439 // Returns reference to ChildProcessStats corresponding to |data|.
440 ChildProcessStats& GetChildProcessStats(
441 const content::ChildProcessData& data);
442
443 // Saves plugin-related updates from the in-object buffer to Local State
444 // for retrieval next time we send a Profile log (generally next launch).
445 void RecordPluginChanges(PrefService* pref);
446
447 // Records state that should be periodically saved, like uptime and 432 // Records state that should be periodically saved, like uptime and
448 // buffered plugin stability statistics. 433 // buffered plugin stability statistics.
449 void RecordCurrentState(PrefService* pref); 434 void RecordCurrentState(PrefService* pref);
450 435
451 // Logs the initiation of a page load and uses |web_contents| to do 436 // Logs the initiation of a page load and uses |web_contents| to do
452 // additional logging of the type of page loaded. 437 // additional logging of the type of page loaded.
453 void LogLoadStarted(content::WebContents* web_contents); 438 void LogLoadStarted(content::WebContents* web_contents);
454 439
455 // Checks whether events should currently be logged. 440 // Checks whether events should currently be logged.
456 bool ShouldLogEvents(); 441 bool ShouldLogEvents();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 483
499 // Whether the initial stability log has been recorded during startup. 484 // Whether the initial stability log has been recorded during startup.
500 bool has_initial_stability_log_; 485 bool has_initial_stability_log_;
501 486
502 // Chrome OS hardware class (e.g., hardware qualification ID). This 487 // Chrome OS hardware class (e.g., hardware qualification ID). This
503 // class identifies the configured system components such as CPU, 488 // class identifies the configured system components such as CPU,
504 // WiFi adapter, etc. For non Chrome OS hosts, this will be an 489 // WiFi adapter, etc. For non Chrome OS hosts, this will be an
505 // empty string. 490 // empty string.
506 std::string hardware_class_; 491 std::string hardware_class_;
507 492
508 // The list of plugins which was retrieved on the file thread. 493 #if defined(ENABLE_PLUGINS)
509 std::vector<content::WebPluginInfo> plugins_; 494 PluginMetricsProvider* plugin_metrics_provider_;
495 #endif
510 496
511 #if defined(OS_WIN) 497 #if defined(OS_WIN)
512 GoogleUpdateMetricsProviderWin* google_update_metrics_provider_; 498 GoogleUpdateMetricsProviderWin* google_update_metrics_provider_;
513 #endif 499 #endif
514 500
515 // The initial metrics log, used to record startup metrics (histograms and 501 // The initial metrics log, used to record startup metrics (histograms and
516 // profiler data). Note that if a crash occurred in the previous session, an 502 // profiler data). Note that if a crash occurred in the previous session, an
517 // initial stability log may be sent before this. 503 // initial stability log may be sent before this.
518 scoped_ptr<MetricsLog> initial_metrics_log_; 504 scoped_ptr<MetricsLog> initial_metrics_log_;
519 505
520 // The outstanding transmission appears as a URL Fetch operation. 506 // The outstanding transmission appears as a URL Fetch operation.
521 scoped_ptr<net::URLFetcher> current_fetch_; 507 scoped_ptr<net::URLFetcher> current_fetch_;
522 508
523 // Whether the MetricsService object has received any notifications since 509 // Whether the MetricsService object has received any notifications since
524 // the last time a transmission was sent. 510 // the last time a transmission was sent.
525 bool idle_since_last_transmission_; 511 bool idle_since_last_transmission_;
526 512
527 // A number that identifies the how many times the app has been launched. 513 // A number that identifies the how many times the app has been launched.
528 int session_id_; 514 int session_id_;
529 515
530 // Maps WebContentses (corresponding to tabs) or Browsers (corresponding to 516 // Maps WebContentses (corresponding to tabs) or Browsers (corresponding to
531 // Windows) to a unique integer that we will use to identify them. 517 // Windows) to a unique integer that we will use to identify them.
532 // |next_window_id_| is used to track which IDs we have used so far. 518 // |next_window_id_| is used to track which IDs we have used so far.
533 typedef std::map<uintptr_t, int> WindowMap; 519 typedef std::map<uintptr_t, int> WindowMap;
534 WindowMap window_map_; 520 WindowMap window_map_;
535 int next_window_id_; 521 int next_window_id_;
536 522
537 // Buffer of child process notifications for quick access.
538 std::map<base::string16, ChildProcessStats> child_process_stats_buffer_;
539
540 // Weak pointers factory used to post task on different threads. All weak 523 // Weak pointers factory used to post task on different threads. All weak
541 // pointers managed by this factory have the same lifetime as MetricsService. 524 // pointers managed by this factory have the same lifetime as MetricsService.
542 base::WeakPtrFactory<MetricsService> self_ptr_factory_; 525 base::WeakPtrFactory<MetricsService> self_ptr_factory_;
543 526
544 // Weak pointers factory used for saving state. All weak pointers managed by 527 // Weak pointers factory used for saving state. All weak pointers managed by
545 // this factory are invalidated in ScheduleNextStateSave. 528 // this factory are invalidated in ScheduleNextStateSave.
546 base::WeakPtrFactory<MetricsService> state_saver_factory_; 529 base::WeakPtrFactory<MetricsService> state_saver_factory_;
547 530
548 // The scheduler for determining when uploads should happen. 531 // The scheduler for determining when uploads should happen.
549 scoped_ptr<MetricsReportingScheduler> scheduler_; 532 scoped_ptr<MetricsReportingScheduler> scheduler_;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 600
618 // Registers/unregisters |observer| to receive MetricsLog notifications 601 // Registers/unregisters |observer| to receive MetricsLog notifications
619 // from metrics service. 602 // from metrics service.
620 static void AddMetricsServiceObserver(MetricsServiceObserver* observer); 603 static void AddMetricsServiceObserver(MetricsServiceObserver* observer);
621 static void RemoveMetricsServiceObserver(MetricsServiceObserver* observer); 604 static void RemoveMetricsServiceObserver(MetricsServiceObserver* observer);
622 605
623 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); 606 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper);
624 }; 607 };
625 608
626 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ 609 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698