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

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

Issue 16271005: Implement pepper interface and plumbing for HRD's UI on ChromeOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't use IPC::Message::Schema::Read in unittest - build break Created 7 years, 6 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
« no previous file with comments | « ppapi/proxy/talk_resource.h ('k') | ppapi/proxy/talk_resource_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/proxy/talk_resource.h" 5 #include "ppapi/proxy/talk_resource.h"
6 6
7 #include "ppapi/proxy/ppapi_messages.h" 7 #include "ppapi/proxy/ppapi_messages.h"
8 8
9 namespace ppapi { 9 namespace ppapi {
10 namespace proxy { 10 namespace proxy {
11 11
12 TalkResource::TalkResource(Connection connection, PP_Instance instance) 12 TalkResource::TalkResource(Connection connection, PP_Instance instance)
13 : PluginResource(connection, instance) { 13 : PluginResource(connection, instance),
14 event_callback_(NULL),
15 event_callback_user_data_(NULL) {
16 SendCreate(BROWSER, PpapiHostMsg_Talk_Create());
14 } 17 }
15 18
16 TalkResource::~TalkResource() { 19 TalkResource::~TalkResource() {
17 } 20 }
18 21
19 thunk::PPB_Talk_Private_API* TalkResource::AsPPB_Talk_Private_API() { 22 thunk::PPB_Talk_Private_API* TalkResource::AsPPB_Talk_Private_API() {
20 return this; 23 return this;
21 } 24 }
22 25
23 int32_t TalkResource::GetPermission(scoped_refptr<TrackedCallback> callback) { 26 int32_t TalkResource::RequestPermission(
24 if (TrackedCallback::IsPending(callback_)) 27 PP_TalkPermission permission,
28 scoped_refptr<TrackedCallback> callback) {
29 if (TrackedCallback::IsPending(permission_callback_))
25 return PP_ERROR_INPROGRESS; 30 return PP_ERROR_INPROGRESS;
26 callback_ = callback;
27 31
28 if (!sent_create_to_browser()) 32 permission_callback_ = callback;
29 SendCreate(BROWSER, PpapiHostMsg_Talk_Create());
30 33
31 Call<PpapiPluginMsg_Talk_GetPermissionReply>( 34 Call<PpapiPluginMsg_Talk_RequestPermissionReply>(
32 BROWSER, 35 BROWSER,
33 PpapiHostMsg_Talk_GetPermission(), 36 PpapiHostMsg_Talk_RequestPermission(permission),
34 base::Bind(&TalkResource::GetPermissionReply, base::Unretained(this))); 37 base::Bind(&TalkResource::OnRequestPermissionReply,
38 base::Unretained(this)));
35 return PP_OK_COMPLETIONPENDING; 39 return PP_OK_COMPLETIONPENDING;
36 } 40 }
37 41
38 void TalkResource::GetPermissionReply( 42 int32_t TalkResource::StartRemoting(PP_TalkEventCallback event_callback,
43 void* user_data,
44 scoped_refptr<TrackedCallback> callback) {
45 if (TrackedCallback::IsPending(start_callback_) ||
46 event_callback_ != NULL)
47 return PP_ERROR_INPROGRESS;
48
49 start_callback_ = callback;
50 event_callback_ = event_callback;
51 event_callback_user_data_ = user_data;
52
53 Call<PpapiPluginMsg_Talk_StartRemotingReply>(
54 BROWSER,
55 PpapiHostMsg_Talk_StartRemoting(),
56 base::Bind(&TalkResource::OnStartRemotingReply,
57 base::Unretained(this)));
58 return PP_OK_COMPLETIONPENDING;
59 }
60
61 int32_t TalkResource::StopRemoting(scoped_refptr<TrackedCallback> callback) {
62 if (TrackedCallback::IsPending(stop_callback_))
63 return PP_ERROR_INPROGRESS;
64
65 if (event_callback_ == NULL)
66 return PP_ERROR_FAILED;
67
68 stop_callback_ = callback;
69
70 Call<PpapiPluginMsg_Talk_StopRemotingReply>(
71 BROWSER,
72 PpapiHostMsg_Talk_StopRemoting(),
73 base::Bind(&TalkResource::OnStopRemotingReply,
74 base::Unretained(this)));
75 return PP_OK_COMPLETIONPENDING;
76 }
77
78 void TalkResource::OnReplyReceived(const ResourceMessageReplyParams& params,
79 const IPC::Message& msg) {
80 IPC_BEGIN_MESSAGE_MAP(TalkResource, msg)
81 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
82 PpapiPluginMsg_Talk_NotifyEvent,
83 OnNotifyEvent)
84 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED(
85 PluginResource::OnReplyReceived(params, msg))
86 IPC_END_MESSAGE_MAP()
87 }
88
89 void TalkResource::OnNotifyEvent(const ResourceMessageReplyParams& params,
90 PP_TalkEvent event) {
91 if (event_callback_ != NULL)
92 event_callback_(event_callback_user_data_, event);
93 }
94
95 void TalkResource::OnRequestPermissionReply(
39 const ResourceMessageReplyParams& params) { 96 const ResourceMessageReplyParams& params) {
40 callback_->Run(params.result()); 97 permission_callback_->Run(params.result());
98 }
99
100 void TalkResource::OnStartRemotingReply(
101 const ResourceMessageReplyParams& params) {
102 start_callback_->Run(params.result());
103 }
104
105 void TalkResource::OnStopRemotingReply(
106 const ResourceMessageReplyParams& params) {
107 event_callback_ = NULL;
108 event_callback_user_data_ = NULL;
109 stop_callback_->Run(params.result());
41 } 110 }
42 111
43 } // namespace proxy 112 } // namespace proxy
44 } // namespace ppapi 113 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/talk_resource.h ('k') | ppapi/proxy/talk_resource_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698