Disable ContentSettingBubbleModelTest.RPHAllow which is flaky.
[chromium-blink-merge.git] / content / renderer / pepper / pepper_device_enumeration_host_helper.h
blob0781f5834f607611acaaefae45d570adac02c1f7
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_DEVICE_ENUMERATION_HOST_HELPER_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_DEVICE_ENUMERATION_HOST_HELPER_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "content/common/content_export.h"
13 #include "ppapi/c/dev/ppb_device_ref_dev.h"
15 namespace ppapi {
16 struct DeviceRefData;
18 namespace host {
19 struct HostMessageContext;
20 struct ReplyMessageContext;
21 class ResourceHost;
25 namespace IPC {
26 class Message;
29 namespace webkit {
30 namespace ppapi {
31 class PluginDelegate;
35 namespace content {
37 // Resource hosts that support device enumeration can use this class to filter
38 // and process PpapiHostMsg_DeviceEnumeration_* messages.
39 // TODO(yzshen): Refactor ppapi::host::ResourceMessageFilter to support message
40 // handling on the same thread, and then derive this class from the filter
41 // class.
42 class CONTENT_EXPORT PepperDeviceEnumerationHostHelper {
43 public:
44 class Delegate {
45 public:
46 virtual ~Delegate() {}
48 // TODO(yzshen): Move the relevant functionality out of PluginDelegate and
49 // get rid of this method.
50 virtual webkit::ppapi::PluginDelegate* GetPluginDelegate() = 0;
53 // |resource_host| and |delegate| must outlive this object.
54 PepperDeviceEnumerationHostHelper(ppapi::host::ResourceHost* resource_host,
55 Delegate* delegate,
56 PP_DeviceType_Dev device_type);
57 ~PepperDeviceEnumerationHostHelper();
59 // Returns true if the message has been handled.
60 bool HandleResourceMessage(const IPC::Message& msg,
61 ppapi::host::HostMessageContext* context,
62 int32_t* result);
64 private:
65 class ScopedRequest;
67 // Has a different signature than HandleResourceMessage() in order to utilize
68 // message dispatching macros.
69 int32_t InternalHandleResourceMessage(
70 const IPC::Message& msg,
71 ppapi::host::HostMessageContext* context,
72 bool* handled);
74 int32_t OnEnumerateDevices(ppapi::host::HostMessageContext* context);
75 int32_t OnMonitorDeviceChange(ppapi::host::HostMessageContext* context,
76 uint32_t callback_id);
77 int32_t OnStopMonitoringDeviceChange(
78 ppapi::host::HostMessageContext* context);
80 void OnEnumerateDevicesComplete(
81 int request_id,
82 bool succeeded,
83 const std::vector<ppapi::DeviceRefData>& devices);
84 void OnNotifyDeviceChange(
85 uint32_t callback_id,
86 int request_id,
87 bool succeeded,
88 const std::vector<ppapi::DeviceRefData>& devices);
90 // Non-owning pointers.
91 ppapi::host::ResourceHost* resource_host_;
92 Delegate* delegate_;
94 PP_DeviceType_Dev device_type_;
96 scoped_ptr<ScopedRequest> enumerate_;
97 scoped_ptr<ScopedRequest> monitor_;
99 scoped_ptr<ppapi::host::ReplyMessageContext> enumerate_devices_context_;
101 DISALLOW_COPY_AND_ASSIGN(PepperDeviceEnumerationHostHelper);
104 } // namespace content
106 #endif // CONTENT_RENDERER_PEPPER_PEPPER_DEVICE_ENUMERATION_HOST_HELPER_H_