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

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 21 matching lines...) Expand all
32 #include "components/metrics/metrics_service_observer.h" 32 #include "components/metrics/metrics_service_observer.h"
33 #include "components/variations/active_field_trials.h" 33 #include "components/variations/active_field_trials.h"
34 #include "content/public/browser/browser_child_process_observer.h" 34 #include "content/public/browser/browser_child_process_observer.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 GoogleUpdateMetricsProviderWin; 38 class GoogleUpdateMetricsProviderWin;
39 class MetricsReportingScheduler; 39 class MetricsReportingScheduler;
40 class PrefService; 40 class PrefService;
41 class PrefRegistrySimple; 41 class PrefRegistrySimple;
42 class PluginMetricsProvider;
42 43
43 namespace base { 44 namespace base {
44 class DictionaryValue; 45 class DictionaryValue;
45 class HistogramSamples; 46 class HistogramSamples;
46 class MessageLoopProxy; 47 class MessageLoopProxy;
47 } 48 }
48 49
49 namespace variations { 50 namespace variations {
50 struct ActiveGroupId; 51 struct ActiveGroupId;
51 } 52 }
52 53
53 namespace content { 54 namespace content {
54 struct WebPluginInfo;
55 } 55 }
56 56
57 namespace metrics { 57 namespace metrics {
58 class MetricsServiceClient; 58 class MetricsServiceClient;
59 class MetricsStateManager; 59 class MetricsStateManager;
60 } 60 }
61 61
62 namespace net { 62 namespace net {
63 class URLFetcher; 63 class URLFetcher;
64 } 64 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // HistogramFlattener: 164 // HistogramFlattener:
165 virtual void RecordDelta(const base::HistogramBase& histogram, 165 virtual void RecordDelta(const base::HistogramBase& histogram,
166 const base::HistogramSamples& snapshot) OVERRIDE; 166 const base::HistogramSamples& snapshot) OVERRIDE;
167 virtual void InconsistencyDetected( 167 virtual void InconsistencyDetected(
168 base::HistogramBase::Inconsistency problem) OVERRIDE; 168 base::HistogramBase::Inconsistency problem) OVERRIDE;
169 virtual void UniqueInconsistencyDetected( 169 virtual void UniqueInconsistencyDetected(
170 base::HistogramBase::Inconsistency problem) OVERRIDE; 170 base::HistogramBase::Inconsistency problem) OVERRIDE;
171 virtual void InconsistencyDetectedInLoggedCount(int amount) OVERRIDE; 171 virtual void InconsistencyDetectedInLoggedCount(int amount) OVERRIDE;
172 172
173 // Implementation of content::BrowserChildProcessObserver 173 // Implementation of content::BrowserChildProcessObserver
174 virtual void BrowserChildProcessHostConnected(
175 const content::ChildProcessData& data) OVERRIDE;
176 virtual void BrowserChildProcessCrashed( 174 virtual void BrowserChildProcessCrashed(
177 const content::ChildProcessData& data) OVERRIDE; 175 const content::ChildProcessData& data) OVERRIDE;
178 virtual void BrowserChildProcessInstanceCreated(
179 const content::ChildProcessData& data) OVERRIDE;
180 176
181 // This should be called when the application is not idle, i.e. the user seems 177 // This should be called when the application is not idle, i.e. the user seems
182 // to be interacting with the application. 178 // to be interacting with the application.
183 void OnApplicationNotIdle(); 179 void OnApplicationNotIdle();
184 180
185 // Invoked when we get a WM_SESSIONEND. This places a value in prefs that is 181 // Invoked when we get a WM_SESSIONEND. This places a value in prefs that is
186 // reset when RecordCompletedSessionEnd is invoked. 182 // reset when RecordCompletedSessionEnd is invoked.
187 void RecordStartOfSessionEnd(); 183 void RecordStartOfSessionEnd();
188 184
189 // This should be called when the application is shutting down. It records 185 // This should be called when the application is shutting down. It records
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 SENDING_INITIAL_METRICS_LOG, // Initial metrics log being sent. 263 SENDING_INITIAL_METRICS_LOG, // Initial metrics log being sent.
268 SENDING_OLD_LOGS, // Sending unsent logs from last session. 264 SENDING_OLD_LOGS, // Sending unsent logs from last session.
269 SENDING_CURRENT_LOGS, // Sending ongoing logs as they accrue. 265 SENDING_CURRENT_LOGS, // Sending ongoing logs as they accrue.
270 }; 266 };
271 267
272 enum ShutdownCleanliness { 268 enum ShutdownCleanliness {
273 CLEANLY_SHUTDOWN = 0xdeadbeef, 269 CLEANLY_SHUTDOWN = 0xdeadbeef,
274 NEED_TO_SHUTDOWN = ~CLEANLY_SHUTDOWN 270 NEED_TO_SHUTDOWN = ~CLEANLY_SHUTDOWN
275 }; 271 };
276 272
277 struct ChildProcessStats;
278
279 typedef std::vector<SyntheticTrialGroup> SyntheticTrialGroups; 273 typedef std::vector<SyntheticTrialGroup> SyntheticTrialGroups;
280 274
281 // First part of the init task. Called on the FILE thread to load hardware 275 // First part of the init task. Called on the FILE thread to load hardware
282 // class information. 276 // class information.
283 static void InitTaskGetHardwareClass(base::WeakPtr<MetricsService> self, 277 static void InitTaskGetHardwareClass(base::WeakPtr<MetricsService> self,
284 base::MessageLoopProxy* target_loop); 278 base::MessageLoopProxy* target_loop);
285 279
286 // Callback from InitTaskGetHardwareClass() that continues the init task by 280 // Callback from InitTaskGetHardwareClass() that continues the init task by
287 // loading plugin information. 281 // loading plugin information.
288 void OnInitTaskGotHardwareClass(const std::string& hardware_class); 282 void OnInitTaskGotHardwareClass(const std::string& hardware_class);
289 283
290 // Callback from PluginService::GetPlugins() that continues the init task by 284 // Called after the Plugin init task has been completed that continues the
291 // launching a task to gather Google Update statistics. 285 // init task by launching a task to gather Google Update statistics.
292 void OnInitTaskGotPluginInfo( 286 void OnInitTaskGotPluginInfo();
293 const std::vector<content::WebPluginInfo>& plugins);
294 287
295 // Called after GoogleUpdate init task has been completed that continues the 288 // Called after GoogleUpdate init task has been completed that continues the
296 // init task by loading profiler data. 289 // init task by loading profiler data.
297 void OnInitTaskGotGoogleUpdateData(); 290 void OnInitTaskGotGoogleUpdateData();
298 291
299 void OnUserAction(const std::string& action); 292 void OnUserAction(const std::string& action);
300 293
301 // TrackingSynchronizerObserver: 294 // TrackingSynchronizerObserver:
302 virtual void ReceivedProfilerData( 295 virtual void ReceivedProfilerData(
303 const tracked_objects::ProcessDataSnapshot& process_data, 296 const tracked_objects::ProcessDataSnapshot& process_data,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 // Reads, increments and then sets the specified integer preference. 386 // Reads, increments and then sets the specified integer preference.
394 void IncrementPrefValue(const char* path); 387 void IncrementPrefValue(const char* path);
395 388
396 // Reads, increments and then sets the specified long preference that is 389 // Reads, increments and then sets the specified long preference that is
397 // stored as a string. 390 // stored as a string.
398 void IncrementLongPrefsValue(const char* path); 391 void IncrementLongPrefsValue(const char* path);
399 392
400 // Records that the browser was shut down cleanly. 393 // Records that the browser was shut down cleanly.
401 void LogCleanShutdown(); 394 void LogCleanShutdown();
402 395
403 // Returns reference to ChildProcessStats corresponding to |data|.
404 ChildProcessStats& GetChildProcessStats(
405 const content::ChildProcessData& data);
406
407 // Saves plugin-related updates from the in-object buffer to Local State
408 // for retrieval next time we send a Profile log (generally next launch).
409 void RecordPluginChanges(PrefService* pref);
410
411 // Records state that should be periodically saved, like uptime and 396 // Records state that should be periodically saved, like uptime and
412 // buffered plugin stability statistics. 397 // buffered plugin stability statistics.
413 void RecordCurrentState(PrefService* pref); 398 void RecordCurrentState(PrefService* pref);
414 399
415 // Checks whether events should currently be logged. 400 // Checks whether events should currently be logged.
416 bool ShouldLogEvents(); 401 bool ShouldLogEvents();
417 402
418 // Sets the value of the specified path in prefs and schedules a save. 403 // Sets the value of the specified path in prefs and schedules a save.
419 void RecordBooleanPrefValue(const char* path, bool value); 404 void RecordBooleanPrefValue(const char* path, bool value);
420 405
421 // Returns true if process of type |type| should be counted as a plugin
422 // process, and false otherwise.
423 static bool IsPluginProcess(int process_type);
424
425 // Returns a list of synthetic field trials that were active for the entire 406 // Returns a list of synthetic field trials that were active for the entire
426 // duration of the current log. 407 // duration of the current log.
427 void GetCurrentSyntheticFieldTrials( 408 void GetCurrentSyntheticFieldTrials(
428 std::vector<variations::ActiveGroupId>* synthetic_trials); 409 std::vector<variations::ActiveGroupId>* synthetic_trials);
429 410
430 // Creates a new MetricsLog instance with the given |log_type|. 411 // Creates a new MetricsLog instance with the given |log_type|.
431 scoped_ptr<MetricsLog> CreateLog(MetricsLog::LogType log_type); 412 scoped_ptr<MetricsLog> CreateLog(MetricsLog::LogType log_type);
432 413
433 // Record complete list of histograms into the current log. 414 // Record complete list of histograms into the current log.
434 // Called when we close a log. 415 // Called when we close a log.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 454
474 // Whether the initial stability log has been recorded during startup. 455 // Whether the initial stability log has been recorded during startup.
475 bool has_initial_stability_log_; 456 bool has_initial_stability_log_;
476 457
477 // Chrome OS hardware class (e.g., hardware qualification ID). This 458 // Chrome OS hardware class (e.g., hardware qualification ID). This
478 // class identifies the configured system components such as CPU, 459 // class identifies the configured system components such as CPU,
479 // WiFi adapter, etc. For non Chrome OS hosts, this will be an 460 // WiFi adapter, etc. For non Chrome OS hosts, this will be an
480 // empty string. 461 // empty string.
481 std::string hardware_class_; 462 std::string hardware_class_;
482 463
483 // The list of plugins which was retrieved on the file thread. 464 #if defined(ENABLE_PLUGINS)
484 std::vector<content::WebPluginInfo> plugins_; 465 PluginMetricsProvider* plugin_metrics_provider_;
466 #endif
485 467
486 #if defined(OS_WIN) 468 #if defined(OS_WIN)
487 GoogleUpdateMetricsProviderWin* google_update_metrics_provider_; 469 GoogleUpdateMetricsProviderWin* google_update_metrics_provider_;
488 #endif 470 #endif
489 471
490 // The initial metrics log, used to record startup metrics (histograms and 472 // The initial metrics log, used to record startup metrics (histograms and
491 // profiler data). Note that if a crash occurred in the previous session, an 473 // profiler data). Note that if a crash occurred in the previous session, an
492 // initial stability log may be sent before this. 474 // initial stability log may be sent before this.
493 scoped_ptr<MetricsLog> initial_metrics_log_; 475 scoped_ptr<MetricsLog> initial_metrics_log_;
494 476
495 // The outstanding transmission appears as a URL Fetch operation. 477 // The outstanding transmission appears as a URL Fetch operation.
496 scoped_ptr<net::URLFetcher> current_fetch_; 478 scoped_ptr<net::URLFetcher> current_fetch_;
497 479
498 // Whether the MetricsService object has received any notifications since 480 // Whether the MetricsService object has received any notifications since
499 // the last time a transmission was sent. 481 // the last time a transmission was sent.
500 bool idle_since_last_transmission_; 482 bool idle_since_last_transmission_;
501 483
502 // A number that identifies the how many times the app has been launched. 484 // A number that identifies the how many times the app has been launched.
503 int session_id_; 485 int session_id_;
504 486
505 // Maps WebContentses (corresponding to tabs) or Browsers (corresponding to 487 // Maps WebContentses (corresponding to tabs) or Browsers (corresponding to
506 // Windows) to a unique integer that we will use to identify them. 488 // Windows) to a unique integer that we will use to identify them.
507 // |next_window_id_| is used to track which IDs we have used so far. 489 // |next_window_id_| is used to track which IDs we have used so far.
508 typedef std::map<uintptr_t, int> WindowMap; 490 typedef std::map<uintptr_t, int> WindowMap;
509 WindowMap window_map_; 491 WindowMap window_map_;
510 int next_window_id_; 492 int next_window_id_;
511 493
512 // Buffer of child process notifications for quick access.
513 std::map<base::string16, ChildProcessStats> child_process_stats_buffer_;
514
515 // Weak pointers factory used to post task on different threads. All weak 494 // Weak pointers factory used to post task on different threads. All weak
516 // pointers managed by this factory have the same lifetime as MetricsService. 495 // pointers managed by this factory have the same lifetime as MetricsService.
517 base::WeakPtrFactory<MetricsService> self_ptr_factory_; 496 base::WeakPtrFactory<MetricsService> self_ptr_factory_;
518 497
519 // Weak pointers factory used for saving state. All weak pointers managed by 498 // Weak pointers factory used for saving state. All weak pointers managed by
520 // this factory are invalidated in ScheduleNextStateSave. 499 // this factory are invalidated in ScheduleNextStateSave.
521 base::WeakPtrFactory<MetricsService> state_saver_factory_; 500 base::WeakPtrFactory<MetricsService> state_saver_factory_;
522 501
523 // The scheduler for determining when uploads should happen. 502 // The scheduler for determining when uploads should happen.
524 scoped_ptr<MetricsReportingScheduler> scheduler_; 503 scoped_ptr<MetricsReportingScheduler> scheduler_;
(...skipping 28 matching lines...) Expand all
553 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess); 532 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess);
554 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, MetricsServiceObserver); 533 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, MetricsServiceObserver);
555 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, 534 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest,
556 PermutedEntropyCacheClearedWhenLowEntropyReset); 535 PermutedEntropyCacheClearedWhenLowEntropyReset);
557 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial); 536 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial);
558 537
559 DISALLOW_COPY_AND_ASSIGN(MetricsService); 538 DISALLOW_COPY_AND_ASSIGN(MetricsService);
560 }; 539 };
561 540
562 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ 541 #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