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

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

Issue 10572040: Create a PPAPI host for new resource message routing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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/dispatcher.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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 F(PPB_URLRequestInfo_API) \ 58 F(PPB_URLRequestInfo_API) \
59 F(PPB_URLResponseInfo_API) \ 59 F(PPB_URLResponseInfo_API) \
60 F(PPB_VideoCapture_API) \ 60 F(PPB_VideoCapture_API) \
61 F(PPB_VideoDecoder_API) \ 61 F(PPB_VideoDecoder_API) \
62 F(PPB_VideoLayer_API) \ 62 F(PPB_VideoLayer_API) \
63 F(PPB_View_API) \ 63 F(PPB_View_API) \
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 {
69 class Message;
70 }
71
68 namespace ppapi { 72 namespace ppapi {
69 73
70 // Forward declare all the resource APIs. 74 // Forward declare all the resource APIs.
71 namespace thunk { 75 namespace thunk {
72 #define DECLARE_RESOURCE_CLASS(RESOURCE) class RESOURCE; 76 #define DECLARE_RESOURCE_CLASS(RESOURCE) class RESOURCE;
73 FOR_ALL_PPAPI_RESOURCE_APIS(DECLARE_RESOURCE_CLASS) 77 FOR_ALL_PPAPI_RESOURCE_APIS(DECLARE_RESOURCE_CLASS)
74 #undef DECLARE_RESOURCE_CLASS 78 #undef DECLARE_RESOURCE_CLASS
75 } // namespace thunk 79 } // namespace thunk
76 80
77 // Resources have slightly different registration behaviors when the're an 81 // Resources have slightly different registration behaviors when the're an
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // it's supported. Derived classes override the functions they support to 158 // it's supported. Derived classes override the functions they support to
155 // return the interface. 159 // return the interface.
156 #define DEFINE_TYPE_GETTER(RESOURCE) \ 160 #define DEFINE_TYPE_GETTER(RESOURCE) \
157 virtual thunk::RESOURCE* As##RESOURCE(); 161 virtual thunk::RESOURCE* As##RESOURCE();
158 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_TYPE_GETTER) 162 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_TYPE_GETTER)
159 #undef DEFINE_TYPE_GETTER 163 #undef DEFINE_TYPE_GETTER
160 164
161 // Template-based dynamic casting. See specializations below. 165 // Template-based dynamic casting. See specializations below.
162 template <typename T> T* GetAs() { return NULL; } 166 template <typename T> T* GetAs() { return NULL; }
163 167
168 // Called when a PpapiPluginMsg_ResourceReply reply is received for a
169 // previous CallRenderer. The sequence number is the value returned the
170 // send function for the given request. The message is the nested reply
171 // message, which may be an empty message (depending on what the host
172 // sends).
173 //
174 // The default implementation will assert (if you send a request, you should
175 // override this function).
176 //
177 // (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
179 // distinguish the classes.)
180 virtual void OnReplyReceived(int sequence,
181 int32_t result,
182 const IPC::Message& msg);
183
164 protected: 184 protected:
165 // Logs a message to the console from this resource. 185 // Logs a message to the console from this resource.
166 void Log(PP_LogLevel_Dev level, const std::string& message); 186 void Log(PP_LogLevel_Dev level, const std::string& message);
167 187
168 private: 188 private:
169 // See the getters above. 189 // See the getters above.
170 PP_Resource pp_resource_; 190 PP_Resource pp_resource_;
171 HostResource host_resource_; 191 HostResource host_resource_;
172 192
173 DISALLOW_IMPLICIT_CONSTRUCTORS(Resource); 193 DISALLOW_IMPLICIT_CONSTRUCTORS(Resource);
174 }; 194 };
175 195
176 // Template-based dynamic casting. These specializations forward to the 196 // Template-based dynamic casting. These specializations forward to the
177 // AsXXX virtual functions to return whether the given type is supported. 197 // AsXXX virtual functions to return whether the given type is supported.
178 #define DEFINE_RESOURCE_CAST(RESOURCE) \ 198 #define DEFINE_RESOURCE_CAST(RESOURCE) \
179 template<> inline thunk::RESOURCE* Resource::GetAs() { \ 199 template<> inline thunk::RESOURCE* Resource::GetAs() { \
180 return As##RESOURCE(); \ 200 return As##RESOURCE(); \
181 } 201 }
182 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_RESOURCE_CAST) 202 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_RESOURCE_CAST)
183 #undef DEFINE_RESOURCE_CAST 203 #undef DEFINE_RESOURCE_CAST
184 204
185 } // namespace ppapi 205 } // namespace ppapi
186 206
187 #endif // PPAPI_SHARED_IMPL_RESOURCE_H_ 207 #endif // PPAPI_SHARED_IMPL_RESOURCE_H_
OLDNEW
« no previous file with comments | « ppapi/proxy/dispatcher.cc ('k') | ppapi/shared_impl/resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698