Add an exponential backoff to rechecking the app list doodle.
[chromium-blink-merge.git] / ppapi / cpp / private / flash_drm.cc
blobc425c9f5b47dbdc397fc3f00a69ba0192d143555
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.
5 #include "ppapi/cpp/private/flash_drm.h"
7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/private/ppb_flash_device_id.h"
9 #include "ppapi/c/private/ppb_flash_drm.h"
10 #include "ppapi/cpp/module_impl.h"
12 namespace pp {
14 namespace {
16 template <> const char* interface_name<PPB_Flash_DRM_1_0>() {
17 return PPB_FLASH_DRM_INTERFACE_1_0;
20 template <> const char* interface_name<PPB_Flash_DRM_1_1>() {
21 return PPB_FLASH_DRM_INTERFACE_1_1;
24 template <> const char* interface_name<PPB_Flash_DeviceID_1_0>() {
25 return PPB_FLASH_DEVICEID_INTERFACE_1_0;
28 } // namespace
30 namespace flash {
32 DRM::DRM() {
35 DRM::DRM(const InstanceHandle& instance) : Resource() {
36 if (has_interface<PPB_Flash_DRM_1_1>()) {
37 PassRefFromConstructor(get_interface<PPB_Flash_DRM_1_1>()->Create(
38 instance.pp_instance()));
39 } else if (has_interface<PPB_Flash_DRM_1_0>()) {
40 PassRefFromConstructor(get_interface<PPB_Flash_DRM_1_0>()->Create(
41 instance.pp_instance()));
42 } else if (has_interface<PPB_Flash_DeviceID_1_0>()) {
43 PassRefFromConstructor(get_interface<PPB_Flash_DeviceID_1_0>()->Create(
44 instance.pp_instance()));
48 int32_t DRM::GetDeviceID(const CompletionCallbackWithOutput<Var>& callback) {
49 if (has_interface<PPB_Flash_DRM_1_1>()) {
50 return get_interface<PPB_Flash_DRM_1_1>()->GetDeviceID(
51 pp_resource(),
52 callback.output(),
53 callback.pp_completion_callback());
55 if (has_interface<PPB_Flash_DRM_1_0>()) {
56 return get_interface<PPB_Flash_DRM_1_0>()->GetDeviceID(
57 pp_resource(),
58 callback.output(),
59 callback.pp_completion_callback());
61 if (has_interface<PPB_Flash_DeviceID_1_0>()) {
62 return get_interface<PPB_Flash_DeviceID_1_0>()->GetDeviceID(
63 pp_resource(),
64 callback.output(),
65 callback.pp_completion_callback());
67 return callback.MayForce(PP_ERROR_NOINTERFACE);
70 bool DRM::GetHmonitor(int64_t* hmonitor) {
71 if (has_interface<PPB_Flash_DRM_1_1>()) {
72 return PP_ToBool(get_interface<PPB_Flash_DRM_1_1>()->GetHmonitor(
73 pp_resource(),
74 hmonitor));
76 if (has_interface<PPB_Flash_DRM_1_0>()) {
77 return PP_ToBool(get_interface<PPB_Flash_DRM_1_0>()->GetHmonitor(
78 pp_resource(),
79 hmonitor));
81 return 0;
84 int32_t DRM::GetVoucherFile(
85 const CompletionCallbackWithOutput<FileRef>& callback) {
86 if (has_interface<PPB_Flash_DRM_1_1>()) {
87 return get_interface<PPB_Flash_DRM_1_1>()->GetVoucherFile(
88 pp_resource(),
89 callback.output(),
90 callback.pp_completion_callback());
92 if (has_interface<PPB_Flash_DRM_1_0>()) {
93 return get_interface<PPB_Flash_DRM_1_0>()->GetVoucherFile(
94 pp_resource(),
95 callback.output(),
96 callback.pp_completion_callback());
98 return PP_ERROR_NOINTERFACE;
101 int32_t DRM::MonitorIsExternal(
102 const CompletionCallbackWithOutput<PP_Bool>& callback) {
103 if (has_interface<PPB_Flash_DRM_1_1>()) {
104 return get_interface<PPB_Flash_DRM_1_1>()->MonitorIsExternal(
105 pp_resource(),
106 callback.output(),
107 callback.pp_completion_callback());
109 return PP_ERROR_NOINTERFACE;
112 } // namespace flash
113 } // namespace pp