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

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

Issue 441013002: Eliminate MetricsProvider::RecordCurrentState() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_METRICS_PLUGIN_METRICS_PROVIDER_H_ 5 #ifndef CHROME_BROWSER_METRICS_PLUGIN_METRICS_PROVIDER_H_
6 #define CHROME_BROWSER_METRICS_PLUGIN_METRICS_PROVIDER_H_ 6 #define CHROME_BROWSER_METRICS_PLUGIN_METRICS_PROVIDER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "components/metrics/metrics_provider.h" 14 #include "components/metrics/metrics_provider.h"
15 #include "content/public/browser/browser_child_process_observer.h" 15 #include "content/public/browser/browser_child_process_observer.h"
16 16
17 namespace base { 17 namespace base {
18 class FilePath; 18 class FilePath;
19 } 19 }
20 20
21 namespace content { 21 namespace content {
22 struct WebPluginInfo; 22 struct WebPluginInfo;
23 } 23 }
24 24
25 class PrefRegistrySimple; 25 class PrefRegistrySimple;
26 class PrefService; 26 class PrefService;
27 27
28 extern const int kRecordStateDelaySec;
Alexei Svitkine (slow) 2014/08/05 20:13:12 I don't think this needs to be in the header.
gayane -on leave until 09-2017 2014/08/05 21:24:55 Done.
29
28 // PluginMetricsProvider is responsible for adding out plugin information to 30 // PluginMetricsProvider is responsible for adding out plugin information to
29 // the UMA proto. 31 // the UMA proto.
30 class PluginMetricsProvider : public metrics::MetricsProvider, 32 class PluginMetricsProvider : public metrics::MetricsProvider,
31 public content::BrowserChildProcessObserver { 33 public content::BrowserChildProcessObserver {
32 public: 34 public:
33 explicit PluginMetricsProvider(PrefService* local_state); 35 explicit PluginMetricsProvider(PrefService* local_state);
34 virtual ~PluginMetricsProvider(); 36 virtual ~PluginMetricsProvider();
35 37
36 // Fetches plugin information data asynchronously and calls |done_callback| 38 // Fetches plugin information data asynchronously and calls |done_callback|
37 // when done. 39 // when done.
38 void GetPluginInformation(const base::Closure& done_callback); 40 void GetPluginInformation(const base::Closure& done_callback);
39 41
40 // metrics::MetricsDataProvider: 42 // metrics::MetricsDataProvider:
41 virtual void ProvideSystemProfileMetrics( 43 virtual void ProvideSystemProfileMetrics(
42 metrics::SystemProfileProto* system_profile_proto) OVERRIDE; 44 metrics::SystemProfileProto* system_profile_proto) OVERRIDE;
43 virtual void ProvideStabilityMetrics( 45 virtual void ProvideStabilityMetrics(
44 metrics::SystemProfileProto* system_profile_proto) OVERRIDE; 46 metrics::SystemProfileProto* system_profile_proto) OVERRIDE;
45 virtual void RecordCurrentState() OVERRIDE; 47 void RecordCurrentState();
46 48
47 // Notifies the provider about an error loading the plugin at |plugin_path|. 49 // Notifies the provider about an error loading the plugin at |plugin_path|.
48 void LogPluginLoadingError(const base::FilePath& plugin_path); 50 void LogPluginLoadingError(const base::FilePath& plugin_path);
49 51
50 // Sets this provider's list of plugins, exposed for testing. 52 // Sets this provider's list of plugins, exposed for testing.
51 void SetPluginsForTesting(const std::vector<content::WebPluginInfo>& plugins); 53 void SetPluginsForTesting(const std::vector<content::WebPluginInfo>& plugins);
52 54
53 // Returns true if process of type |type| should be counted as a plugin 55 // Returns true if process of type |type| should be counted as a plugin
54 // process, and false otherwise. 56 // process, and false otherwise.
55 static bool IsPluginProcess(int process_type); 57 static bool IsPluginProcess(int process_type);
56 58
57 // Registers local state prefs used by this class. 59 // Registers local state prefs used by this class.
58 static void RegisterPrefs(PrefRegistrySimple* registry); 60 static void RegisterPrefs(PrefRegistrySimple* registry);
59 61
62 // Posts delayed execution for RecordCurrentState. Returns true if new task is
Alexei Svitkine (slow) 2014/08/05 20:13:12 Nit: "delayed execution" -> "a delayed task"
gayane -on leave until 09-2017 2014/08/05 21:24:55 Done.
63 // posted and false if there was one already waiting for execution.
64 bool DelayedRecordCurrentState(int delay_sec);
Alexei Svitkine (slow) 2014/08/05 20:13:12 Move this function definition above the static fun
gayane -on leave until 09-2017 2014/08/05 21:24:55 Done.
65
60 private: 66 private:
61 struct ChildProcessStats; 67 struct ChildProcessStats;
62 68
63 // Receives the plugin list from the PluginService and calls |done_callback|. 69 // Receives the plugin list from the PluginService and calls |done_callback|.
64 void OnGotPlugins(const base::Closure& done_callback, 70 void OnGotPlugins(const base::Closure& done_callback,
65 const std::vector<content::WebPluginInfo>& plugins); 71 const std::vector<content::WebPluginInfo>& plugins);
66 72
67 // Returns reference to ChildProcessStats corresponding to |data|. 73 // Returns reference to ChildProcessStats corresponding to |data|.
68 ChildProcessStats& GetChildProcessStats( 74 ChildProcessStats& GetChildProcessStats(
69 const content::ChildProcessData& data); 75 const content::ChildProcessData& data);
(...skipping 13 matching lines...) Expand all
83 89
84 // Buffer of child process notifications for quick access. 90 // Buffer of child process notifications for quick access.
85 std::map<base::string16, ChildProcessStats> child_process_stats_buffer_; 91 std::map<base::string16, ChildProcessStats> child_process_stats_buffer_;
86 92
87 base::WeakPtrFactory<PluginMetricsProvider> weak_ptr_factory_; 93 base::WeakPtrFactory<PluginMetricsProvider> weak_ptr_factory_;
88 94
89 DISALLOW_COPY_AND_ASSIGN(PluginMetricsProvider); 95 DISALLOW_COPY_AND_ASSIGN(PluginMetricsProvider);
90 }; 96 };
91 97
92 #endif // CHROME_BROWSER_METRICS_PLUGIN_METRICS_PROVIDER_H_ 98 #endif // CHROME_BROWSER_METRICS_PLUGIN_METRICS_PROVIDER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/metrics/plugin_metrics_provider.cc » ('j') | chrome/browser/metrics/plugin_metrics_provider.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698