Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(456)

Side by Side Diff: ppapi/proxy/output_protection_resource.cc

Issue 24039002: Pepper API implementation for output protection. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix test on chromeos Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 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/proxy/output_protection_resource.h"
6
7 #include "base/logging.h"
8 #include "ppapi/proxy/plugin_globals.h"
9 #include "ppapi/proxy/plugin_resource_tracker.h"
10 #include "ppapi/proxy/ppapi_messages.h"
11 #include "ppapi/shared_impl/proxy_lock.h"
12 #include "ppapi/shared_impl/resource_tracker.h"
13 #include "ppapi/shared_impl/tracked_callback.h"
14 #include "ppapi/thunk/enter.h"
15 #include "ppapi/thunk/ppb_output_protection_api.h"
16
17 namespace ppapi {
18 namespace proxy {
19
20 OutputProtectionResource::OutputProtectionResource(
21 Connection connection,
22 PP_Instance instance)
23 : PluginResource(connection, instance) {
24 SendCreate(BROWSER, PpapiHostMsg_OutputProtection_Create());
25 Post(BROWSER, PpapiHostMsg_OutputProtection_Init());
26 }
27
28 OutputProtectionResource::~OutputProtectionResource() {
29 if (TrackedCallback::IsPending(query_status_callback_))
30 query_status_callback_->PostAbort();
31 if (TrackedCallback::IsPending(enable_protection_callback_))
32 enable_protection_callback_->PostAbort();
33 Post(BROWSER, PpapiHostMsg_OutputProtection_Terminate());
34 }
35
36 thunk::PPB_OutputProtection_API*
37 OutputProtectionResource::AsPPB_OutputProtection_API() {
38 return this;
39 }
40
41 int32_t OutputProtectionResource::QueryStatus(
42 uint32_t* link_mask,
43 uint32_t* protection_mask,
44 const scoped_refptr<TrackedCallback>& callback) {
45 if (!link_mask || !protection_mask)
46 return PP_ERROR_BADARGUMENT;
47 if (TrackedCallback::IsPending(query_status_callback_))
48 return PP_ERROR_INPROGRESS;
49
50 query_status_callback_ = callback;
51
52 Call<PpapiPluginMsg_OutputProtection_QueryStatusReply>(
53 BROWSER,
54 PpapiHostMsg_OutputProtection_QueryStatus(),
55 base::Bind(&OutputProtectionResource::OnPluginMsgQueryStatusReply,
56 base::Unretained(this),
57 link_mask,
58 protection_mask));
59 return PP_OK_COMPLETIONPENDING;
60 }
61
62 void OutputProtectionResource::OnPluginMsgQueryStatusReply(
63 uint32_t* out_link_mask,
64 uint32_t* out_protection_mask,
65 const ResourceMessageReplyParams& params,
66 uint32_t link_mask,
67 uint32_t protection_mask) {
68 // The callback may have been aborted.
69 if (!TrackedCallback::IsPending(query_status_callback_))
70 return;
71
72 int32_t result = params.result();
73
74 if (result == PP_OK) {
75 DCHECK(out_link_mask);
76 DCHECK(out_protection_mask);
77 *out_link_mask = link_mask;
78 *out_protection_mask = protection_mask;
79 }
80 query_status_callback_->Run(result);
81 }
82
83 int32_t OutputProtectionResource::EnableProtection(
84 uint32_t desired_method_mask,
85 const scoped_refptr<TrackedCallback>& callback) {
86 if (TrackedCallback::IsPending(enable_protection_callback_))
87 return PP_ERROR_INPROGRESS;
88
89 enable_protection_callback_ = callback;
90
91 Call<PpapiPluginMsg_OutputProtection_EnableProtectionReply>(
92 BROWSER,
93 PpapiHostMsg_OutputProtection_EnableProtection(desired_method_mask),
94 base::Bind(&OutputProtectionResource::OnPluginMsgEnableProtectionReply,
95 base::Unretained(this)));
96 return PP_OK_COMPLETIONPENDING;
97 }
98
99 void OutputProtectionResource::OnPluginMsgEnableProtectionReply(
100 const ResourceMessageReplyParams& params) {
101 // The callback may have been aborted.
102 if (TrackedCallback::IsPending(enable_protection_callback_))
103 enable_protection_callback_->Run(params.result());
104 }
105
106 } // namespace proxy
107 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698