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 #include "ppapi/cpp/private/image_capture_private.h" |
| 6 |
| 7 #include "ppapi/c/pp_bool.h" |
| 8 #include "ppapi/c/pp_errors.h" |
| 9 #include "ppapi/cpp/completion_callback.h" |
| 10 #include "ppapi/cpp/instance_handle.h" |
| 11 #include "ppapi/cpp/module_impl.h" |
| 12 #include "ppapi/cpp/private/camera_capabilities_private.h" |
| 13 |
| 14 namespace pp { |
| 15 |
| 16 namespace { |
| 17 |
| 18 template <> |
| 19 const char* interface_name<PPB_ImageCapture_Private_0_1>() { |
| 20 return PPB_IMAGECAPTURE_PRIVATE_INTERFACE_0_1; |
| 21 } |
| 22 |
| 23 } // namespace |
| 24 |
| 25 ImageCapture_Private::ImageCapture_Private() { |
| 26 } |
| 27 |
| 28 ImageCapture_Private::ImageCapture_Private(const ImageCapture_Private& other) |
| 29 : Resource(other) { |
| 30 } |
| 31 |
| 32 ImageCapture_Private::ImageCapture_Private(const Resource& resource) |
| 33 : Resource(resource) { |
| 34 PP_DCHECK(IsImageCapture(resource)); |
| 35 } |
| 36 |
| 37 ImageCapture_Private::ImageCapture_Private(const InstanceHandle& instance) { |
| 38 if (has_interface<PPB_ImageCapture_Private_0_1>()) { |
| 39 PassRefFromConstructor( |
| 40 get_interface<PPB_ImageCapture_Private_0_1>()->Create( |
| 41 instance.pp_instance())); |
| 42 return; |
| 43 } |
| 44 PP_DCHECK(false); |
| 45 } |
| 46 |
| 47 ImageCapture_Private::ImageCapture_Private(PassRef, PP_Resource resource) |
| 48 : Resource(PASS_REF, resource) { |
| 49 } |
| 50 |
| 51 ImageCapture_Private::~ImageCapture_Private() { |
| 52 } |
| 53 |
| 54 int32_t ImageCapture_Private::Open(const Var& device_id, |
| 55 const CompletionCallback& callback) { |
| 56 if (!has_interface<PPB_ImageCapture_Private_0_1>()) |
| 57 return callback.MayForce(PP_ERROR_NOINTERFACE); |
| 58 |
| 59 return get_interface<PPB_ImageCapture_Private_0_1>()->Open( |
| 60 pp_resource(), device_id.pp_var(), callback.pp_completion_callback()); |
| 61 } |
| 62 |
| 63 void ImageCapture_Private::Close() { |
| 64 if (has_interface<PPB_ImageCapture_Private_0_1>()) |
| 65 get_interface<PPB_ImageCapture_Private_0_1>()->Close(pp_resource()); |
| 66 } |
| 67 |
| 68 int32_t ImageCapture_Private::GetCameraCapabilities( |
| 69 const CompletionCallbackWithOutput<CameraCapabilities_Private>& callback) { |
| 70 if (!has_interface<PPB_ImageCapture_Private_0_1>()) |
| 71 return callback.MayForce(PP_ERROR_NOINTERFACE); |
| 72 |
| 73 return get_interface<PPB_ImageCapture_Private_0_1>()->GetCameraCapabilities( |
| 74 pp_resource(), callback.output(), callback.pp_completion_callback()); |
| 75 } |
| 76 |
| 77 // static |
| 78 bool ImageCapture_Private::IsImageCapture(const Resource& resource) { |
| 79 if (!has_interface<PPB_ImageCapture_Private_0_1>()) |
| 80 return false; |
| 81 |
| 82 return PP_ToBool( |
| 83 get_interface<PPB_ImageCapture_Private_0_1>()->IsImageCapture( |
| 84 resource.pp_resource())); |
| 85 } |
| 86 |
| 87 } // namespace pp |
OLD | NEW |