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

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: Implemented requested changes. 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
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(
27 PP_TalkPermission permission,
28 scoped_refptr<TrackedCallback> callback) {
24 if (TrackedCallback::IsPending(callback_)) 29 if (TrackedCallback::IsPending(callback_))
25 return PP_ERROR_INPROGRESS; 30 return PP_ERROR_INPROGRESS;
26 callback_ = callback; 31 callback_ = callback;
27 32
28 if (!sent_create_to_browser()) 33 Call<PpapiPluginMsg_Talk_RequestPermissionReply>(
29 SendCreate(BROWSER, PpapiHostMsg_Talk_Create());
30
31 Call<PpapiPluginMsg_Talk_GetPermissionReply>(
32 BROWSER, 34 BROWSER,
33 PpapiHostMsg_Talk_GetPermission(), 35 PpapiHostMsg_Talk_RequestPermission(permission),
34 base::Bind(&TalkResource::GetPermissionReply, base::Unretained(this))); 36 base::Bind(&TalkResource::OnRequestPermissionReply,
37 base::Unretained(this)));
35 return PP_OK_COMPLETIONPENDING; 38 return PP_OK_COMPLETIONPENDING;
36 } 39 }
37 40
38 void TalkResource::GetPermissionReply( 41 int32_t TalkResource::StartRemoting(PP_TalkEventCallback event_callback,
42 void* user_data) {
43 if (event_callback_ != NULL)
44 return PP_ERROR_INPROGRESS;
45
46 event_callback_ = event_callback;
47 event_callback_user_data_ = user_data;
48
49 Post(BROWSER, PpapiHostMsg_Talk_StartRemoting());
50 return PP_OK;
51 }
52
53 void TalkResource::StopRemoting() {
54 event_callback_ = NULL;
55 event_callback_user_data_ = NULL;
56 Post(BROWSER, PpapiHostMsg_Talk_StopRemoting());
57 }
58
59 void TalkResource::OnReplyReceived(const ResourceMessageReplyParams& params,
60 const IPC::Message& msg) {
61 IPC_BEGIN_MESSAGE_MAP(TalkResource, msg)
62 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
63 PpapiPluginMsg_Talk_NotifyEvent,
64 OnNotifyEvent)
65 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED(
66 PluginResource::OnReplyReceived(params, msg))
67 IPC_END_MESSAGE_MAP()
68 }
69
70 void TalkResource::OnNotifyEvent(const ResourceMessageReplyParams& params,
71 PP_TalkEvent event) {
72 if (event_callback_ != NULL)
73 event_callback_(event_callback_user_data_, event);
74 }
75
76 void TalkResource::OnRequestPermissionReply(
39 const ResourceMessageReplyParams& params) { 77 const ResourceMessageReplyParams& params) {
40 callback_->Run(params.result()); 78 callback_->Run(params.result());
41 } 79 }
42 80
43 } // namespace proxy 81 } // namespace proxy
44 } // namespace ppapi 82 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698