Pepper_47_C++_interfaces
removable_storage_dev.cc
Go to the documentation of this file.
1 /** <!-- -*- c++ -*- ****************************************************** -->
2  *
3  * @file removable_storage_dev.cc
4  * @author Michal Jurkiewicz <m.jurkiewicz@samsung.com>
5  * @date 11-10-2013
6  *
7  ******************************************************************************
8  *
9  * Copyright (c) 2013 Samsung Electronics, Visual Display Division.
10  * All Rights Reserved.
11  *
12  * This software is the confidential and proprietary information
13  * of Samsung Electronics, Inc. ("Confidential Information"). You
14  * shall not disclose such Confidential Information and shall use
15  * it only in accordance with the terms of the license agreement
16  * you entered into with Samsung.
17  *
18  *****************************************************************************/
19 
20 #include "ppapi/c/pp_errors.h"
24 #include "ppapi/cpp/module_impl.h"
25 #include "ppapi/cpp/resource.h"
26 
27 namespace pp {
28 
29 namespace {
30 
31 template <> const char* interface_name<PPB_RemovableStorage_Dev_0_1>()
32 {
33  return PPB_REMOVABLESTORAGE_DEV_INTERFACE_0_1;
34 }
35 
36 } // namespace
37 
39 {
40  if (has_interface<PPB_RemovableStorage_Dev_0_1>()) {
41  PassRefFromConstructor(get_interface<PPB_RemovableStorage_Dev_0_1>()->Create(
42  instance.pp_instance()));
43  }
44 }
45 
47 {
48  return get_interface<PPB_RemovableStorage_Dev_0_1>()->IsRemovableStorage(pp_resource());
49 }
50 
52 {
53  return has_interface<PPB_RemovableStorage_Dev_0_1>();
54 }
55 
57  const CompletionCallbackWithOutput<std::vector<DeviceRef_Dev> >& callback)
58 {
59  if (!has_interface<PPB_RemovableStorage_Dev_0_1>())
60  return callback.MayForce(PP_ERROR_NOINTERFACE);
61  if (!callback.pp_completion_callback().func)
62  return callback.MayForce(PP_ERROR_BLOCKS_MAIN_THREAD);
63 
64  return get_interface<PPB_RemovableStorage_Dev_0_1>()->EnumerateDevices(
65  pp_resource(), callback.output(), callback.pp_completion_callback());
66 
67 }
68 
69 int32_t RemovableStorage_Dev::MonitorDeviceChange(PP_MonitorDeviceChangeCallback callback,
70  void* user_data)
71 {
72  if (has_interface<PPB_RemovableStorage_Dev_0_1>())
73  return get_interface<PPB_RemovableStorage_Dev_0_1>()->MonitorDeviceChange(pp_resource(), callback, user_data);
74  return PP_ERROR_NOINTERFACE;
75 }
76 
78  const DeviceRef_Dev& device_ref,
79  const CompletionCallback& callback)
80 {
81  if (has_interface<PPB_RemovableStorage_Dev_0_1>()) {
82  return get_interface<PPB_RemovableStorage_Dev_0_1>()->Open(
83  pp_resource(), file_system.pp_resource(), device_ref.pp_resource(), callback.pp_completion_callback());
84  }
85 
86  return callback.MayForce(PP_ERROR_NOINTERFACE);
87 }
88 
89 } // namespace pp
void PassRefFromConstructor(PP_Resource resource)
Definition: resource.cc:50
int32_t MayForce(int32_t result) const
const PP_CompletionCallback & pp_completion_callback() const
int32_t Open(const FileSystem &file_system, const DeviceRef_Dev &device_ref, const CompletionCallback &callback)
int32_t EnumerateDevices(const CompletionCallbackWithOutput< std::vector< DeviceRef_Dev > > &callback)
int32_t MonitorDeviceChange(PP_MonitorDeviceChangeCallback callback, void *user_data)
PP_Resource pp_resource() const
Definition: resource.h:47
PP_Instance pp_instance() const
RemovableStorage_Dev(const InstanceHandle &instance)