OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
ddorwin
2013/04/04 19:09:50
leave, right?
xhwang
2013/04/04 23:10:33
Done.
| |
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_RENDERER_PLUGINS_PLUGIN_UMA_H_ | 5 #ifndef CHROME_RENDERER_PLUGINS_PLUGIN_UMA_H_ |
6 #define CHROME_RENDERER_PLUGINS_PLUGIN_UMA_H_ | 6 #define CHROME_RENDERER_PLUGINS_PLUGIN_UMA_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
13 | 13 |
14 // Used to send UMA data about missing plugins to UMA histogram server. Method | 14 // Used to send UMA data about missing plugins to UMA histogram server. Method |
15 // ReportPluginMissing should be called whenever plugin that is not available or | 15 // ReportPluginMissing should be called whenever plugin that is not available or |
16 // enabled is called. We try to determine plugin's type by requested mime type, | 16 // enabled is called. We try to determine plugin's type by requested mime type, |
17 // or, if mime type is unknown, by plugin's src url. | 17 // or, if mime type is unknown, by plugin's src url. |
18 class MissingPluginReporter { | 18 class PluginUMAReporter { |
19 public: | 19 public: |
20 enum ReportType { | |
21 MISSING_PLUGIN, | |
22 DISABLED_PLUGIN | |
23 }; | |
24 | |
20 // This must be sync'd with histogram values. | 25 // This must be sync'd with histogram values. |
21 enum PluginType { | 26 enum PluginType { |
22 WINDOWS_MEDIA_PLAYER = 0, | 27 WINDOWS_MEDIA_PLAYER = 0, |
23 SILVERLIGHT = 1, | 28 SILVERLIGHT = 1, |
24 REALPLAYER = 2, | 29 REALPLAYER = 2, |
25 JAVA = 3, | 30 JAVA = 3, |
26 QUICKTIME = 4, | 31 QUICKTIME = 4, |
27 OTHER = 5 | 32 OTHER = 5 |
28 }; | 33 }; |
29 | 34 |
30 // Sends UMA data, i.e. plugin's type. | 35 // Sends UMA data, i.e. plugin's type. |
31 class UMASender { | 36 class UMASender { |
32 public: | 37 public: |
33 virtual ~UMASender() {} | 38 virtual ~UMASender() {} |
34 virtual void SendPluginUMA(PluginType plugin_type) = 0; | 39 virtual void SendPluginUMA(ReportType report_type, |
40 PluginType plugin_type) = 0; | |
35 }; | 41 }; |
36 | 42 |
37 // Returns singleton instance. | 43 // Returns singleton instance. |
38 static MissingPluginReporter* GetInstance(); | 44 static PluginUMAReporter* GetInstance(); |
39 | 45 |
40 void ReportPluginMissing(std::string plugin_mime_type, | 46 void ReportPluginMissing(const std::string& plugin_mime_type, |
41 const GURL& plugin_src); | 47 const GURL& plugin_src); |
42 | 48 |
43 // Used in testing. | 49 void ReportPluginDisabled(const std::string& plugin_mime_type, |
44 void SetUMASender(UMASender* sender); | 50 const GURL& plugin_src); |
45 | 51 |
46 private: | 52 private: |
47 friend struct DefaultSingletonTraits<MissingPluginReporter>; | 53 friend struct DefaultSingletonTraits<PluginUMAReporter>; |
54 // For testing. | |
55 friend void ExpectPluginType(PluginType expected_plugin_type, | |
56 const std::string& plugin_mime_type, | |
57 const GURL& plugin_src); | |
48 | 58 |
49 MissingPluginReporter(); | 59 PluginUMAReporter(); |
50 ~MissingPluginReporter(); | 60 ~PluginUMAReporter(); |
51 | 61 |
52 static bool CompareCStrings(const char* first, const char* second); | 62 static bool CompareCStrings(const char* first, const char* second); |
53 bool CStringArrayContainsCString(const char** array, | 63 bool CStringArrayContainsCString(const char** array, |
54 size_t array_size, | 64 size_t array_size, |
55 const char* str); | 65 const char* str); |
56 // Extracts file extension from url. | 66 // Extracts file extension from url. |
57 void ExtractFileExtension(const GURL& src, std::string* extension); | 67 void ExtractFileExtension(const GURL& src, std::string* extension); |
58 | 68 |
69 PluginType GetPluginType(const std::string& plugin_mime_type, | |
70 const GURL& plugin_src); | |
71 | |
59 // Converts plugin's src to plugin type. | 72 // Converts plugin's src to plugin type. |
60 PluginType SrcToPluginType(const GURL& src); | 73 PluginType SrcToPluginType(const GURL& src); |
61 // Converts plugin's mime type to plugin type. | 74 // Converts plugin's mime type to plugin type. |
62 PluginType MimeTypeToPluginType(const std::string& mime_type); | 75 PluginType MimeTypeToPluginType(const std::string& mime_type); |
63 | 76 |
64 scoped_ptr<UMASender> report_sender_; | 77 scoped_ptr<UMASender> report_sender_; |
65 | 78 |
66 DISALLOW_COPY_AND_ASSIGN(MissingPluginReporter); | 79 DISALLOW_COPY_AND_ASSIGN(PluginUMAReporter); |
67 }; | 80 }; |
68 | 81 |
69 #endif // CHROME_RENDERER_PLUGINS_PLUGIN_UMA_H_ | 82 #endif // CHROME_RENDERER_PLUGINS_PLUGIN_UMA_H_ |
70 | 83 |
OLD | NEW |