| OLD | NEW |
| 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 Loading... |
| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 // send function for the given request. The message is the nested reply | 176 // 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 | 177 // message, which may be an empty message (depending on what the host |
| 172 // sends). | 178 // sends). |
| 173 // | 179 // |
| 174 // The default implementation will assert (if you send a request, you should | 180 // The default implementation will assert (if you send a request, you should |
| 175 // override this function). | 181 // override this function). |
| 176 // | 182 // |
| 177 // (This function would make more conceptual sense on PluginResource but we | 183 // (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 | 184 // need to call this function from general code that doesn't know how to |
| 179 // distinguish the classes.) | 185 // distinguish the classes.) |
| 180 virtual void OnReplyReceived(int sequence, | 186 virtual void OnReplyReceived(const proxy::ResourceMessageReplyParams& params, |
| 181 int32_t result, | |
| 182 const IPC::Message& msg); | 187 const IPC::Message& msg); |
| 183 | 188 |
| 184 protected: | 189 protected: |
| 185 // Logs a message to the console from this resource. | 190 // Logs a message to the console from this resource. |
| 186 void Log(PP_LogLevel_Dev level, const std::string& message); | 191 void Log(PP_LogLevel_Dev level, const std::string& message); |
| 187 | 192 |
| 188 private: | 193 private: |
| 189 // See the getters above. | 194 // See the getters above. |
| 190 PP_Resource pp_resource_; | 195 PP_Resource pp_resource_; |
| 191 HostResource host_resource_; | 196 HostResource host_resource_; |
| 192 | 197 |
| 193 DISALLOW_IMPLICIT_CONSTRUCTORS(Resource); | 198 DISALLOW_IMPLICIT_CONSTRUCTORS(Resource); |
| 194 }; | 199 }; |
| 195 | 200 |
| 196 // Template-based dynamic casting. These specializations forward to the | 201 // Template-based dynamic casting. These specializations forward to the |
| 197 // AsXXX virtual functions to return whether the given type is supported. | 202 // AsXXX virtual functions to return whether the given type is supported. |
| 198 #define DEFINE_RESOURCE_CAST(RESOURCE) \ | 203 #define DEFINE_RESOURCE_CAST(RESOURCE) \ |
| 199 template<> inline thunk::RESOURCE* Resource::GetAs() { \ | 204 template<> inline thunk::RESOURCE* Resource::GetAs() { \ |
| 200 return As##RESOURCE(); \ | 205 return As##RESOURCE(); \ |
| 201 } | 206 } |
| 202 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_RESOURCE_CAST) | 207 FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_RESOURCE_CAST) |
| 203 #undef DEFINE_RESOURCE_CAST | 208 #undef DEFINE_RESOURCE_CAST |
| 204 | 209 |
| 205 } // namespace ppapi | 210 } // namespace ppapi |
| 206 | 211 |
| 207 #endif // PPAPI_SHARED_IMPL_RESOURCE_H_ | 212 #endif // PPAPI_SHARED_IMPL_RESOURCE_H_ |
| OLD | NEW |