cc: Include Blink's display list memory usage in rasterize_and_record_micro results.
[chromium-blink-merge.git] / ppapi / proxy / video_capture_resource.h
blobadd971361294175db7fe619c0c3598cae4348f7b
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 PPAPI_PROXY_VIDEO_CAPTURE_RESOURCE_H_
6 #define PPAPI_PROXY_VIDEO_CAPTURE_RESOURCE_H_
8 #include "base/compiler_specific.h"
9 #include "ppapi/c/dev/ppp_video_capture_dev.h"
10 #include "ppapi/proxy/device_enumeration_resource_helper.h"
11 #include "ppapi/proxy/plugin_resource.h"
12 #include "ppapi/thunk/ppb_video_capture_api.h"
14 namespace ppapi {
15 namespace proxy {
17 class VideoCaptureResource
18 : public PluginResource,
19 public ::ppapi::thunk::PPB_VideoCapture_API {
20 public:
21 VideoCaptureResource(Connection connection,
22 PP_Instance instance,
23 PluginDispatcher* dispatcher);
24 ~VideoCaptureResource() override;
26 // PluginResource override.
27 thunk::PPB_VideoCapture_API* AsPPB_VideoCapture_API() override {
28 return this;
31 // PPB_VideoCapture_API implementation.
32 int32_t EnumerateDevices(
33 const PP_ArrayOutput& output,
34 scoped_refptr<TrackedCallback> callback) override;
35 int32_t MonitorDeviceChange(
36 PP_MonitorDeviceChangeCallback callback,
37 void* user_data) override;
38 int32_t Open(const std::string& device_id,
39 const PP_VideoCaptureDeviceInfo_Dev& requested_info,
40 uint32_t buffer_count,
41 scoped_refptr<TrackedCallback> callback) override;
42 int32_t StartCapture() override;
43 int32_t ReuseBuffer(uint32_t buffer) override;
44 int32_t StopCapture() override;
45 void Close() override;
46 int32_t EnumerateDevicesSync(const PP_ArrayOutput& devices) override;
48 protected:
49 // Resource override.
50 void LastPluginRefWasDeleted() override;
52 private:
53 enum OpenState {
54 BEFORE_OPEN,
55 OPENED,
56 CLOSED
59 // PluginResource overrides.
60 void OnReplyReceived(const ResourceMessageReplyParams& params,
61 const IPC::Message& msg) override;
63 void OnPluginMsgOnDeviceInfo(const ResourceMessageReplyParams& params,
64 const struct PP_VideoCaptureDeviceInfo_Dev& info,
65 const std::vector<HostResource>& buffers,
66 uint32_t buffer_size);
67 void OnPluginMsgOnStatus(const ResourceMessageReplyParams& params,
68 uint32_t status);
69 void OnPluginMsgOnError(const ResourceMessageReplyParams& params,
70 uint32_t error);
71 void OnPluginMsgOnBufferReady(const ResourceMessageReplyParams& params,
72 uint32_t buffer);
74 void OnPluginMsgOpenReply(const ResourceMessageReplyParams& params);
76 void SetBufferInUse(uint32_t buffer_index);
78 // Points to the C interface of client implementation.
79 const PPP_VideoCapture_Dev* ppp_video_capture_impl_;
81 // Indicates that the i-th buffer is currently in use.
82 std::vector<bool> buffer_in_use_;
84 // Holds a reference of the callback so that Close() can cancel it.
85 scoped_refptr<TrackedCallback> open_callback_;
86 OpenState open_state_;
88 DeviceEnumerationResourceHelper enumeration_helper_;
90 DISALLOW_COPY_AND_ASSIGN(VideoCaptureResource);
93 } // namespace proxy
94 } // namespace ppapi
96 #endif // PPAPI_PROXY_VIDEO_CAPTURE_RESOURCE_H_