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

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

Issue 8414054: Hello Pepper API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/ppb_hello_proxy.h ('k') | ppapi/proxy/resource_creation_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 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/ppb_hello_proxy.h"
6
7 #include <stdio.h>
8
9 #include "base/logging.h"
10 #include "build/build_config.h"
11 #include "ppapi/c/pp_errors.h"
12 #include "ppapi/c/pp_resource.h"
13 #include "ppapi/c/dev/ppb_hello_dev.h"
14 #include "ppapi/cpp/completion_callback.h"
15 #include "ppapi/proxy/host_dispatcher.h"
16 #include "ppapi/proxy/plugin_dispatcher.h"
17 #include "ppapi/proxy/ppapi_messages.h"
18 #include "ppapi/thunk/enter.h"
19 #include "ppapi/thunk/resource_creation_api.h"
20 #include "ppapi/thunk/thunk.h"
21
22 using ppapi::thunk::PPB_Hello_API;
23
24 namespace ppapi {
25 namespace proxy {
26
27 class Hello : public Resource, public HelloImpl {
28 public:
29 Hello(const HostResource& hello_id);
30 virtual ~Hello();
31
32 // Resource overrides.
33 virtual PPB_Hello_API* AsPPB_Hello_API();
34
35 // PPB_Hello_API implementation.
36 virtual int32_t SayHello() OVERRIDE;
37 virtual void WhoAreYou(char* name, uint32_t size,
38 pp::CompletionCallback callback) OVERRIDE;
39
40 DISALLOW_COPY_AND_ASSIGN(Hello);
41 };
42
43 Hello::Hello(const HostResource& hello) : Resource(hello) {
44 LOG(ERROR) << "Hello (constructor)";
45 }
46
47 Hello::~Hello() {
48 LOG(ERROR) << "~Hello (destructor)";
49 }
50
51 PPB_Hello_API* Hello::AsPPB_Hello_API() {
52 LOG(ERROR) << "AsPPB_Hello_API";
53 return this;
54 }
55
56 int32_t Hello::SayHello() {
57 LOG(ERROR) << "SayHello";
58 HelloImpl();
59 PluginDispatcher::GetForResource(this)->Send(
60 new PpapiHostMsg_PPBHello_Hello(API_ID_PPB_HELLO, host_resource()));
61 return PP_OK;
62 }
63
64 void Hello::WhoAreYou(char* name, uint32_t size,
65 pp::CompletionCallback callback) {
66 LOG(ERROR) << "WhoAreYou";
67 ReceiveSerializedVarReturnValue result;
68 PluginDispatcher::GetForResource(this)->Send(
69 new PpapiHostMsg_PPBHello_WhoAreYou(API_ID_PPB_HELLO, host_resource(),
70 &result));
71 //PP_Var var = result.Return(dispatcher);
72 // TODO: Copy var to name
73 }
74
75 PPB_Hello_Proxy::PPB_Hello_Proxy(Dispatcher* dispatcher)
76 : InterfaceProxy(dispatcher) {
77 LOG(ERROR) << "PPB_Hello_Proxy";
78 }
79
80 PPB_Hello_Proxy::~PPB_Hello_Proxy() {
81 LOG(ERROR) << "~PPB_Hello_Proxy";
82 }
83
84 // static
85 PP_Resource PPB_Hello_Proxy::CreateProxyResource(PP_Instance instance) {
86 LOG(ERROR) << "CreateProxyResource";
87 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
88 if (!dispatcher) {
89 LOG(ERROR) << "Can not get dispatcher";
90 return 0;
91 }
92
93 LOG(ERROR) << "dispatcher->Send...";
94 HostResource result;
95 dispatcher->Send(new PpapiHostMsg_PPBHello_Create(
96 API_ID_PPB_HELLO, instance, &result));
97 if (result.is_null()) {
98 LOG(ERROR) << "result is null";
99 return 0;
100 }
101
102 return (new Hello(result))->GetReference();
103 }
104
105 bool PPB_Hello_Proxy::OnMessageReceived(const IPC::Message& msg) {
106 //puts("OnMessageReceived");
107 LOG(ERROR) << "OnMessageReceived";
108 bool handled = true;
109 IPC_BEGIN_MESSAGE_MAP(PPB_Hello_Proxy, msg)
110 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBHello_Create, OnMsgCreate)
111 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBHello_Hello, OnMsgHello)
112 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBHello_WhoAreYou, OnMsgWhoAreYou)
113 IPC_MESSAGE_UNHANDLED(handled = false)
114 IPC_END_MESSAGE_MAP()
115 return handled;
116 }
117
118 void PPB_Hello_Proxy::OnMsgCreate(PP_Instance instance, HostResource* result) {
119 LOG(ERROR) << "OnMsgCreate";
120 thunk::EnterFunction<thunk::ResourceCreationAPI> resource_creation(
121 instance, true);
122 if (resource_creation.failed())
123 return;
124
125 LOG(ERROR) << "resource_creation";
126 if (resource_creation.failed())
127 return;
128
129 LOG(ERROR) << "SetHostResource";
130 result->SetHostResource(
131 instance, resource_creation.functions()->CreateHello(instance));
132 if (result->is_null())
133 return;
134 }
135
136 void PPB_Hello_Proxy::OnMsgHello(const HostResource& host_resource) {
137 LOG(ERROR) << "OnMsgHello";
138 }
139
140 void PPB_Hello_Proxy::OnMsgWhoAreYou(const HostResource& host_resource,
141 SerializedVarReturnValue result) {
142 LOG(ERROR) << "OnMsgWhoAreYou";
143 PP_Var var = PP_MakeUndefined();
144 // TODO: Make String
145 result.Return(dispatcher(), var);
146 }
147
148 } // namespace proxy
149 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_hello_proxy.h ('k') | ppapi/proxy/resource_creation_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698