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

Side by Side Diff: chrome/browser/metrics/plugin_metrics_provider.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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_METRICS_PLUGIN_METRICS_PROVIDER_H_
6 #define CHROME_BROWSER_METRICS_PLUGIN_METRICS_PROVIDER_H_
7
8 #include <map>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/strings/string16.h"
14 #include "components/metrics/metrics_provider.h"
15 #include "content/public/browser/browser_child_process_observer.h"
16
17 namespace base {
18 class FilePath;
19 }
20
21 namespace content {
22 struct WebPluginInfo;
23 }
24
25 class PrefRegistrySimple;
26 class PrefService;
27
28 // PluginMetricsProvider is responsible for adding out plugin information to
29 // the UMA proto.
30 class PluginMetricsProvider : public metrics::MetricsProvider,
31 public content::BrowserChildProcessObserver {
32 public:
33 explicit PluginMetricsProvider(PrefService* local_state);
34 virtual ~PluginMetricsProvider();
35
36 // Fetches plugin information data asynchronously and calls |done_callback|
37 // when done.
38 void GetPluginInformation(const base::Closure& done_callback);
39
40 // metrics::MetricsDataProvider:
41 virtual void ProvideSystemProfileMetrics(
42 metrics::SystemProfileProto* system_profile_proto) OVERRIDE;
43 virtual void ProvideStabilityMetrics(
44 metrics::SystemProfileProto* system_profile_proto) OVERRIDE;
45
46 // Saves plugin-related updates from the in-object buffer to Local State
47 // for retrieval next time we send a Profile log (generally next launch).
48 void RecordPluginChanges();
49
50 // Notifies the provider about an error loading the plugin at |plugin_path|.
51 void LogPluginLoadingError(const base::FilePath& plugin_path);
52
53 // Sets this provider's list of plugins, exposed for testing.
54 void SetPluginsForTesting(const std::vector<content::WebPluginInfo>& plugins);
55
56 // Registers local state prefs used by this class.
57 static void RegisterPrefs(PrefRegistrySimple* registry);
58
59 private:
60 struct ChildProcessStats;
61
62 // Receives the plugin list from the PluginService and calls |done_callback|.
63 void OnGotPlugins(const base::Closure& done_callback,
64 const std::vector<content::WebPluginInfo>& plugins);
65
66 // Returns reference to ChildProcessStats corresponding to |data|.
67 ChildProcessStats& GetChildProcessStats(
68 const content::ChildProcessData& data);
69
70 // content::BrowserChildProcessObserver:
71 virtual void BrowserChildProcessHostConnected(
72 const content::ChildProcessData& data) OVERRIDE;
73 virtual void BrowserChildProcessCrashed(
74 const content::ChildProcessData& data) OVERRIDE;
75 virtual void BrowserChildProcessInstanceCreated(
76 const content::ChildProcessData& data) OVERRIDE;
77
78 PrefService* local_state_;
79
80 // The list of plugins which was retrieved on the file thread.
81 std::vector<content::WebPluginInfo> plugins_;
82
83 // Buffer of child process notifications for quick access.
84 std::map<base::string16, ChildProcessStats> child_process_stats_buffer_;
85
86 base::WeakPtrFactory<PluginMetricsProvider> weak_ptr_factory_;
87
88 DISALLOW_COPY_AND_ASSIGN(PluginMetricsProvider);
89 };
90
91 #endif // CHROME_BROWSER_METRICS_PLUGIN_METRICS_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698