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

Side by Side Diff: ppapi/shared_impl/resource.h

Issue 10815073: Refactoring of new IPC-only pepper implementation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/proxy/resource_creation_proxy.cc ('k') | ppapi/shared_impl/resource.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 #ifndef PPAPI_SHARED_IMPL_RESOURCE_H_ 5 #ifndef PPAPI_SHARED_IMPL_RESOURCE_H_
6 #define PPAPI_SHARED_IMPL_RESOURCE_H_ 6 #define PPAPI_SHARED_IMPL_RESOURCE_H_
7 7
8 #include <stddef.h> // For NULL. 8 #include <stddef.h> // For NULL.
9 9
10 #include <string> 10 #include <string>
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 F(PPB_WebSocket_API) \ 64 F(PPB_WebSocket_API) \
65 F(PPB_Widget_API) \ 65 F(PPB_Widget_API) \
66 F(PPB_X509Certificate_Private_API) 66 F(PPB_X509Certificate_Private_API)
67 67
68 namespace IPC { 68 namespace IPC {
69 class Message; 69 class Message;
70 } 70 }
71 71
72 namespace ppapi { 72 namespace ppapi {
73 73
74 // Normally we shouldn't reply on proxy here, but this is to support
75 // OnReplyReceived. See that comment.
76 namespace proxy {
77 class ResourceMessageReplyParams;
78 }
79
74 // Forward declare all the resource APIs. 80 // Forward declare all the resource APIs.
75 namespace thunk { 81 namespace thunk {
76 #define DECLARE_RESOURCE_CLASS(RESOURCE) class RESOURCE; 82 #define DECLARE_RESOURCE_CLASS(RESOURCE) class RESOURCE;
77 FOR_ALL_PPAPI_RESOURCE_APIS(DECLARE_RESOURCE_CLASS) 83 FOR_ALL_PPAPI_RESOURCE_APIS(DECLARE_RESOURCE_CLASS)
78 #undef DECLARE_RESOURCE_CLASS 84 #undef DECLARE_RESOURCE_CLASS
79 } // namespace thunk 85 } // namespace thunk
80 86
81 // Resources have slightly different registration behaviors when the're an 87 // Resources have slightly different registration behaviors when the're an
82 // in-process ("impl") resource in the host (renderer) process, or when they're 88 // in-process ("impl") resource in the host (renderer) process, or when they're
83 // a proxied resource in the plugin process. This enum differentiates those 89 // a proxied resource in the plugin process. This enum differentiates those
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // return the interface. 165 // return the interface.
160 #define DEFINE_TYPE_GETTER(RESOURCE) \ 166 #define DEFINE_TYPE_GETTER(RESOURCE) \
161 virtual thunk::RESOURCE* As##RESOURCE(); 167 virtual thunk::RESOURCE* As##RESOURCE();
162 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_TYPE_GETTER) 168 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_TYPE_GETTER)
163 #undef DEFINE_TYPE_GETTER 169 #undef DEFINE_TYPE_GETTER
164 170
165 // Template-based dynamic casting. See specializations below. 171 // Template-based dynamic casting. See specializations below.
166 template <typename T> T* GetAs() { return NULL; } 172 template <typename T> T* GetAs() { return NULL; }
167 173
168 // Called when a PpapiPluginMsg_ResourceReply reply is received for a 174 // Called when a PpapiPluginMsg_ResourceReply reply is received for a
169 // previous CallRenderer. The sequence number is the value returned the 175 // previous CallRenderer. The message is the nested reply message, which may
170 // send function for the given request. The message is the nested reply 176 // be an empty message (depending on what the host sends).
171 // message, which may be an empty message (depending on what the host
172 // sends).
173 // 177 //
174 // The default implementation will assert (if you send a request, you should 178 // The default implementation will assert (if you send a request, you should
175 // override this function). 179 // override this function).
176 // 180 //
177 // (This function would make more conceptual sense on PluginResource but we 181 // (This function would make more conceptual sense on PluginResource but we
178 // need to call this function from general code that doesn't know how to 182 // need to call this function from general code that doesn't know how to
179 // distinguish the classes.) 183 // distinguish the classes.)
180 virtual void OnReplyReceived(int sequence, 184 virtual void OnReplyReceived(const proxy::ResourceMessageReplyParams& params,
181 int32_t result,
182 const IPC::Message& msg); 185 const IPC::Message& msg);
183 186
184 protected: 187 protected:
185 // Logs a message to the console from this resource. 188 // Logs a message to the console from this resource.
186 void Log(PP_LogLevel_Dev level, const std::string& message); 189 void Log(PP_LogLevel_Dev level, const std::string& message);
187 190
188 private: 191 private:
189 // See the getters above. 192 // See the getters above.
190 PP_Resource pp_resource_; 193 PP_Resource pp_resource_;
191 HostResource host_resource_; 194 HostResource host_resource_;
192 195
193 DISALLOW_IMPLICIT_CONSTRUCTORS(Resource); 196 DISALLOW_IMPLICIT_CONSTRUCTORS(Resource);
194 }; 197 };
195 198
196 // Template-based dynamic casting. These specializations forward to the 199 // Template-based dynamic casting. These specializations forward to the
197 // AsXXX virtual functions to return whether the given type is supported. 200 // AsXXX virtual functions to return whether the given type is supported.
198 #define DEFINE_RESOURCE_CAST(RESOURCE) \ 201 #define DEFINE_RESOURCE_CAST(RESOURCE) \
199 template<> inline thunk::RESOURCE* Resource::GetAs() { \ 202 template<> inline thunk::RESOURCE* Resource::GetAs() { \
200 return As##RESOURCE(); \ 203 return As##RESOURCE(); \
201 } 204 }
202 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_RESOURCE_CAST) 205 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_RESOURCE_CAST)
203 #undef DEFINE_RESOURCE_CAST 206 #undef DEFINE_RESOURCE_CAST
204 207
205 } // namespace ppapi 208 } // namespace ppapi
206 209
207 #endif // PPAPI_SHARED_IMPL_RESOURCE_H_ 210 #endif // PPAPI_SHARED_IMPL_RESOURCE_H_
OLDNEW
« no previous file with comments | « ppapi/proxy/resource_creation_proxy.cc ('k') | ppapi/shared_impl/resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698