1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ppapi/proxy/flash_drm_resource.h"
#include "base/bind.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/proxy/dispatch_reply_message.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/ppb_file_ref_proxy.h"
#include "ppapi/shared_impl/ppb_file_ref_shared.h"
#include "ppapi/shared_impl/var.h"
namespace ppapi {
namespace proxy {
FlashDRMResource::FlashDRMResource(Connection connection,
PP_Instance instance)
: PluginResource(connection, instance) {
SendCreate(BROWSER, PpapiHostMsg_FlashDRM_Create());
SendCreate(RENDERER, PpapiHostMsg_FlashDRM_Create());
}
FlashDRMResource::~FlashDRMResource() {
}
thunk::PPB_Flash_DRM_API* FlashDRMResource::AsPPB_Flash_DRM_API() {
return this;
}
int32_t FlashDRMResource::GetDeviceID(PP_Var* id,
scoped_refptr<TrackedCallback> callback) {
if (!id)
return PP_ERROR_BADARGUMENT;
*id = PP_MakeUndefined();
Call<PpapiPluginMsg_FlashDRM_GetDeviceIDReply>(
BROWSER,
PpapiHostMsg_FlashDRM_GetDeviceID(),
base::Bind(&FlashDRMResource::OnPluginMsgGetDeviceIDReply, this,
id, callback));
return PP_OK_COMPLETIONPENDING;
}
PP_Bool FlashDRMResource::GetHmonitor(int64_t* hmonitor) {
int64_t hmonitor_out;
int32_t result = SyncCall<PpapiPluginMsg_FlashDRM_GetHmonitorReply>(
BROWSER,
PpapiHostMsg_FlashDRM_GetHmonitor(),
&hmonitor_out);
if (result != PP_OK)
return PP_FALSE;
*hmonitor = hmonitor_out;
return PP_TRUE;
}
int32_t FlashDRMResource::GetVoucherFile(
PP_Resource* file_ref,
scoped_refptr<TrackedCallback> callback) {
if (!file_ref)
return PP_ERROR_BADARGUMENT;
*file_ref = 0;
Call<PpapiPluginMsg_FlashDRM_GetVoucherFileReply>(
RENDERER,
PpapiHostMsg_FlashDRM_GetVoucherFile(),
base::Bind(&FlashDRMResource::OnPluginMsgGetVoucherFileReply, this,
file_ref, callback));
return PP_OK_COMPLETIONPENDING;
}
void FlashDRMResource::OnPluginMsgGetDeviceIDReply(
PP_Var* dest,
scoped_refptr<TrackedCallback> callback,
const ResourceMessageReplyParams& params,
const std::string& id) {
if (TrackedCallback::IsPending(callback)) {
if (params.result() == PP_OK)
*dest = StringVar::StringToPPVar(id);
callback->Run(params.result());
}
}
void FlashDRMResource::OnPluginMsgGetVoucherFileReply(
PP_Resource* dest,
scoped_refptr<TrackedCallback> callback,
const ResourceMessageReplyParams& params,
const PPB_FileRef_CreateInfo& file_info) {
if (TrackedCallback::IsPending(callback)) {
if (params.result() == PP_OK)
*dest = PPB_FileRef_Proxy::DeserializeFileRef(file_info);
callback->Run(params.result());
}
}
} // namespace proxy
} // namespace ppapi
|