OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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 PPAPI_PROXY_IMAGE_CAPTURE_RESOURCE_H_ | |
6 #define PPAPI_PROXY_IMAGE_CAPTURE_RESOURCE_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "ppapi/c/pp_size.h" | |
10 #include "ppapi/proxy/connection.h" | |
11 #include "ppapi/proxy/plugin_resource.h" | |
12 #include "ppapi/proxy/ppapi_proxy_export.h" | |
13 #include "ppapi/shared_impl/resource.h" | |
14 #include "ppapi/thunk/ppb_image_capture_api.h" | |
15 | |
16 namespace ppapi { | |
17 namespace proxy { | |
18 | |
19 class CameraCapabilitiesResource; | |
20 class ImageCaptureConfigResource; | |
21 | |
22 class PPAPI_PROXY_EXPORT ImageCaptureResource | |
23 : public PluginResource, | |
24 public thunk::PPB_ImageCapture_API { | |
25 public: | |
26 ImageCaptureResource(Connection connection, PP_Instance instance); | |
27 ~ImageCaptureResource() override; | |
28 | |
29 // Resource overrides: | |
30 thunk::PPB_ImageCapture_API* AsPPB_ImageCapture_API() override { | |
31 return this; | |
32 } | |
33 | |
34 // PPB_ImageCapture_API implementation. | |
35 int32_t Open(PP_Var device_id, | |
36 const scoped_refptr<TrackedCallback>& callback) override; | |
37 void Close() override; | |
38 int32_t GetCameraCapabilities( | |
39 PP_Resource* capabilities, | |
40 const scoped_refptr<TrackedCallback>& callback) override; | |
41 | |
42 private: | |
43 enum OpenState { BEFORE_OPEN, OPENED, CLOSED }; | |
dcheng
2015/02/12 21:47:20
Prefer enum class.
Justin Chuang
2015/02/16 19:15:24
Done. Thanks. Looks better.
| |
44 | |
45 void OnPluginMsgGetPreviewSizesReply( | |
46 PP_Resource* capabilities_output, | |
47 const ResourceMessageReplyParams& params, | |
48 const std::vector<PP_Size>& preview_sizes); | |
49 void OnPluginMsgOpenReply(const ResourceMessageReplyParams& params); | |
50 | |
51 bool is_opened() const { return open_state_ == OPENED; } | |
52 | |
53 // Holds a reference of the callback so that Close() can cancel it. | |
54 scoped_refptr<TrackedCallback> open_callback_; | |
55 OpenState open_state_; | |
56 | |
57 scoped_refptr<TrackedCallback> get_capabilities_callback_; | |
58 scoped_refptr<CameraCapabilitiesResource> camera_capabilities_; | |
59 | |
60 DISALLOW_COPY_AND_ASSIGN(ImageCaptureResource); | |
61 }; | |
62 | |
63 } // namespace proxy | |
64 } // namespace ppapi | |
65 | |
66 #endif // PPAPI_PROXY_IMAGE_CAPTURE_RESOURCE_H_ | |
OLD | NEW |