Home | History | Annotate | Download | only in thunk
      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.
      4 
      5 // From private/ppb_flash_drm.idl modified Tue Dec  3 15:22:00 2013.
      6 
      7 #include "ppapi/c/pp_completion_callback.h"
      8 #include "ppapi/c/pp_errors.h"
      9 #include "ppapi/c/private/ppb_flash_drm.h"
     10 #include "ppapi/shared_impl/tracked_callback.h"
     11 #include "ppapi/thunk/enter.h"
     12 #include "ppapi/thunk/ppapi_thunk_export.h"
     13 #include "ppapi/thunk/ppb_flash_drm_api.h"
     14 
     15 namespace ppapi {
     16 namespace thunk {
     17 
     18 namespace {
     19 
     20 PP_Resource Create(PP_Instance instance) {
     21   VLOG(4) << "PPB_Flash_DRM::Create()";
     22   EnterResourceCreation enter(instance);
     23   if (enter.failed())
     24     return 0;
     25   return enter.functions()->CreateFlashDRM(instance);
     26 }
     27 
     28 int32_t GetDeviceID(PP_Resource drm,
     29                     struct PP_Var* id,
     30                     struct PP_CompletionCallback callback) {
     31   VLOG(4) << "PPB_Flash_DRM::GetDeviceID()";
     32   EnterResource<PPB_Flash_DRM_API> enter(drm, callback, true);
     33   if (enter.failed())
     34     return enter.retval();
     35   return enter.SetResult(enter.object()->GetDeviceID(id, enter.callback()));
     36 }
     37 
     38 PP_Bool GetHmonitor(PP_Resource drm, int64_t* hmonitor) {
     39   VLOG(4) << "PPB_Flash_DRM::GetHmonitor()";
     40   EnterResource<PPB_Flash_DRM_API> enter(drm, true);
     41   if (enter.failed())
     42     return PP_FALSE;
     43   return enter.object()->GetHmonitor(hmonitor);
     44 }
     45 
     46 int32_t GetVoucherFile(PP_Resource drm,
     47                        PP_Resource* file_ref,
     48                        struct PP_CompletionCallback callback) {
     49   VLOG(4) << "PPB_Flash_DRM::GetVoucherFile()";
     50   EnterResource<PPB_Flash_DRM_API> enter(drm, callback, true);
     51   if (enter.failed())
     52     return enter.retval();
     53   return enter.SetResult(enter.object()->GetVoucherFile(file_ref,
     54                                                         enter.callback()));
     55 }
     56 
     57 int32_t MonitorIsExternal(PP_Resource drm,
     58                           PP_Bool* is_external,
     59                           struct PP_CompletionCallback callback) {
     60   VLOG(4) << "PPB_Flash_DRM::MonitorIsExternal()";
     61   EnterResource<PPB_Flash_DRM_API> enter(drm, callback, true);
     62   if (enter.failed())
     63     return enter.retval();
     64   return enter.SetResult(enter.object()->MonitorIsExternal(is_external,
     65                                                            enter.callback()));
     66 }
     67 
     68 const PPB_Flash_DRM_1_0 g_ppb_flash_drm_thunk_1_0 = {
     69   &Create,
     70   &GetDeviceID,
     71   &GetHmonitor,
     72   &GetVoucherFile
     73 };
     74 
     75 const PPB_Flash_DRM_1_1 g_ppb_flash_drm_thunk_1_1 = {
     76   &Create,
     77   &GetDeviceID,
     78   &GetHmonitor,
     79   &GetVoucherFile,
     80   &MonitorIsExternal
     81 };
     82 
     83 }  // namespace
     84 
     85 PPAPI_THUNK_EXPORT const PPB_Flash_DRM_1_0* GetPPB_Flash_DRM_1_0_Thunk() {
     86   return &g_ppb_flash_drm_thunk_1_0;
     87 }
     88 
     89 PPAPI_THUNK_EXPORT const PPB_Flash_DRM_1_1* GetPPB_Flash_DRM_1_1_Thunk() {
     90   return &g_ppb_flash_drm_thunk_1_1;
     91 }
     92 
     93 }  // namespace thunk
     94 }  // namespace ppapi
     95