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

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: modify pepper host as message filter. rewrite methods in real_output_configurator_delegate. 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 link_mask_(NULL),
25 protection_mask_(NULL) {
26 SendCreate(BROWSER, PpapiHostMsg_OutputProtection_Create());
27 }
28
29 OutputProtectionResource::~OutputProtectionResource() {
30 if (TrackedCallback::IsPending(query_status_callback_))
31 query_status_callback_->PostAbort();
32 if (TrackedCallback::IsPending(enable_protection_callback_))
33 enable_protection_callback_->PostAbort();
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 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 link_mask_ = link_mask;
51 protection_mask_ = protection_mask;
52 query_status_callback_ = callback;
53
54 Call<PpapiPluginMsg_OutputProtection_QueryStatusReply>(
55 BROWSER,
56 PpapiHostMsg_OutputProtection_QueryStatus(),
57 base::Bind(&OutputProtectionResource::OnPluginMsgQueryStatusReply,
58 base::Unretained(this)));
59 return PP_OK_COMPLETIONPENDING;
60 }
61
62 void OutputProtectionResource::OnPluginMsgQueryStatusReply(
63 const ResourceMessageReplyParams& params,
64 uint32_t link_mask,
65 uint32_t protection_mask) {
66 // The callback may have been aborted.
67 if (!TrackedCallback::IsPending(query_status_callback_))
68 return;
69 if (link_mask_ == NULL || protection_mask_ == NULL) {
70 NOTREACHED();
71 return;
72 }
73
74 int32_t result = params.result();
75
76 if (result == PP_OK) {
77 *link_mask_ = link_mask;
78 *protection_mask_ = protection_mask;
79 }
80 link_mask_ = NULL;
81 protection_mask_ = NULL;
82 query_status_callback_->Run(result);
83 }
84
85 int32_t OutputProtectionResource::EnableProtection(uint32_t desired_method_mask,
86 scoped_refptr<TrackedCallback> callback) {
87 if (TrackedCallback::IsPending(enable_protection_callback_))
88 return PP_ERROR_INPROGRESS;
89
90 enable_protection_callback_ = callback;
91
92 Call<PpapiPluginMsg_OutputProtection_EnableProtectionReply>(
93 BROWSER,
94 PpapiHostMsg_OutputProtection_EnableProtection(desired_method_mask),
95 base::Bind(&OutputProtectionResource::OnPluginMsgEnableProtectionReply,
96 base::Unretained(this)));
97 return PP_OK_COMPLETIONPENDING;
98 }
99
100 void OutputProtectionResource::OnPluginMsgEnableProtectionReply(
101 const ResourceMessageReplyParams& params) {
102 // The callback may have been aborted.
103 if (TrackedCallback::IsPending(enable_protection_callback_))
104 enable_protection_callback_->Run(params.result());
105 }
106
107 } // namespace proxy
108 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698