Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 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 PP_ERROR_NOINTERFACE; | |
|
dmichael (off chromium)
2015/02/09 22:26:59
You should use callback.MayForce here and in other
Justin Chuang
2015/02/10 16:01:02
Done.
| |
| 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 } | |
|
dmichael (off chromium)
2015/02/09 22:26:59
nit: no curly braces here, for consistency
Justin Chuang
2015/02/10 16:01:02
Done.
| |
| 67 } | |
| 68 | |
| 69 int32_t ImageCapture_Private::GetCameraCapabilities( | |
| 70 const CompletionCallbackWithOutput<CameraCapabilities_Private>& callback) { | |
| 71 if (!has_interface<PPB_ImageCapture_Private_0_1>()) | |
| 72 return PP_ERROR_NOINTERFACE; | |
| 73 | |
| 74 return get_interface<PPB_ImageCapture_Private_0_1>()->GetCameraCapabilities( | |
| 75 pp_resource(), callback.output(), callback.pp_completion_callback()); | |
| 76 } | |
| 77 | |
| 78 // static | |
| 79 bool ImageCapture_Private::IsImageCapture(const Resource& resource) { | |
| 80 if (!has_interface<PPB_ImageCapture_Private_0_1>()) | |
| 81 return false; | |
| 82 | |
| 83 return PP_ToBool( | |
| 84 get_interface<PPB_ImageCapture_Private_0_1>()->IsImageCapture( | |
| 85 resource.pp_resource())); | |
| 86 } | |
| 87 | |
| 88 } // namespace pp | |
| OLD | NEW |