Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / renderer / pepper / pepper_uma_host.h
blob7ea8a5f18cfb7691d230c4e1308b270d5a64fc1e
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.
5 #ifndef CHROME_RENDERER_PEPPER_PEPPER_UMA_HOST_H_
6 #define CHROME_RENDERER_PEPPER_PEPPER_UMA_HOST_H_
8 #include <set>
9 #include <string>
11 #include "base/files/file_path.h"
12 #include "ppapi/c/pp_instance.h"
13 #include "ppapi/c/pp_resource.h"
14 #include "ppapi/host/resource_host.h"
15 #include "url/gurl.h"
17 namespace content {
18 class RendererPpapiHost;
21 namespace ppapi {
22 namespace host {
23 struct HostMessageContext;
24 } // namespace host
25 } // namespace ppapi
27 class PepperUMAHost : public ppapi::host::ResourceHost {
28 public:
29 PepperUMAHost(content::RendererPpapiHost* host,
30 PP_Instance instance,
31 PP_Resource resource);
33 ~PepperUMAHost() override;
35 // ppapi::host::ResourceMessageHandler implementation.
36 int32_t OnResourceMessageReceived(
37 const IPC::Message& msg,
38 ppapi::host::HostMessageContext* context) override;
40 private:
41 bool IsPluginWhitelisted();
42 bool IsHistogramAllowed(const std::string& histogram);
44 int32_t OnHistogramCustomTimes(ppapi::host::HostMessageContext* context,
45 const std::string& name,
46 int64_t sample,
47 int64_t min,
48 int64_t max,
49 uint32_t bucket_count);
51 int32_t OnHistogramCustomCounts(ppapi::host::HostMessageContext* context,
52 const std::string& name,
53 int32_t sample,
54 int32_t min,
55 int32_t max,
56 uint32_t bucket_count);
58 int32_t OnHistogramEnumeration(ppapi::host::HostMessageContext* context,
59 const std::string& name,
60 int32_t sample,
61 int32_t boundary_value);
63 int32_t OnIsCrashReportingEnabled(ppapi::host::HostMessageContext* context);
65 const GURL document_url_;
66 bool is_plugin_in_process_;
67 base::FilePath plugin_base_name_;
69 // Set of origins that can use UMA private APIs from NaCl.
70 std::set<std::string> allowed_origins_;
71 // Set of hashed histogram prefixes that can be used from this interface.
72 std::set<std::string> allowed_histogram_prefixes_;
73 // Set of plugin files names that are allowed to use this interface.
74 std::set<std::string> allowed_plugin_base_names_;
76 DISALLOW_COPY_AND_ASSIGN(PepperUMAHost);
79 #endif // CHROME_RENDERER_PEPPER_PEPPER_UMA_HOST_H_