| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_PROXY_ENTER_PROXY_H_ | 5 #ifndef PPAPI_PROXY_ENTER_PROXY_H_ |
| 6 #define PPAPI_PROXY_ENTER_PROXY_H_ | 6 #define PPAPI_PROXY_ENTER_PROXY_H_ |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "ppapi/cpp/completion_callback.h" | 9 #include "ppapi/cpp/completion_callback.h" |
| 10 #include "ppapi/proxy/host_dispatcher.h" | 10 #include "ppapi/proxy/host_dispatcher.h" |
| 11 #include "ppapi/proxy/plugin_dispatcher.h" | 11 #include "ppapi/proxy/plugin_dispatcher.h" |
| 12 #include "ppapi/proxy/plugin_resource_tracker.h" | 12 #include "ppapi/proxy/plugin_resource_tracker.h" |
| 13 #include "ppapi/thunk/enter.h" | 13 #include "ppapi/thunk/enter.h" |
| 14 | 14 |
| 15 namespace ppapi { | 15 namespace ppapi { |
| 16 | |
| 17 namespace thunk { | |
| 18 class ResourceCreationAPI; | |
| 19 } | |
| 20 | |
| 21 namespace proxy { | 16 namespace proxy { |
| 22 | 17 |
| 23 // Wrapper around EnterResourceNoLock that takes a host resource. This is used | 18 // Wrapper around EnterResourceNoLock that takes a host resource. This is used |
| 24 // when handling messages in the plugin from the host and we need to convert to | 19 // when handling messages in the plugin from the host and we need to convert to |
| 25 // an object in the plugin side corresponding to that. | 20 // an object in the plugin side corresponding to that. |
| 26 // | 21 // |
| 27 // This never locks since we assume the host Resource is coming from IPC, and | 22 // This never locks since we assume the host Resource is coming from IPC, and |
| 28 // never logs errors since we assume the host is doing reasonable things. | 23 // never logs errors since we assume the host is doing reasonable things. |
| 29 template<typename ResourceT> | 24 template<typename ResourceT> |
| 30 class EnterPluginFromHostResource | 25 class EnterPluginFromHostResource |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 CallbackFactory& factory, | 108 CallbackFactory& factory, |
| 114 Method method, | 109 Method method, |
| 115 const A& a) | 110 const A& a) |
| 116 : EnterHostFromHostResource<ResourceT>(host_resource), | 111 : EnterHostFromHostResource<ResourceT>(host_resource), |
| 117 needs_running_(true), | 112 needs_running_(true), |
| 118 callback_(factory.NewOptionalCallback(method, a)) { | 113 callback_(factory.NewOptionalCallback(method, a)) { |
| 119 if (this->failed()) | 114 if (this->failed()) |
| 120 RunCallback(PP_ERROR_BADRESOURCE); | 115 RunCallback(PP_ERROR_BADRESOURCE); |
| 121 } | 116 } |
| 122 | 117 |
| 123 // For callbacks that take two extra parameters as a closure. | |
| 124 template<class CallbackFactory, typename Method, typename A, typename B> | |
| 125 EnterHostFromHostResourceForceCallback( | |
| 126 const HostResource& host_resource, | |
| 127 CallbackFactory& factory, | |
| 128 Method method, | |
| 129 const A& a, | |
| 130 const B& b) | |
| 131 : EnterHostFromHostResource<ResourceT>(host_resource), | |
| 132 needs_running_(true), | |
| 133 callback_(factory.NewOptionalCallback(method, a, b)) { | |
| 134 if (this->failed()) | |
| 135 RunCallback(PP_ERROR_BADRESOURCE); | |
| 136 } | |
| 137 | |
| 138 ~EnterHostFromHostResourceForceCallback() { | 118 ~EnterHostFromHostResourceForceCallback() { |
| 139 if (needs_running_) { | 119 if (needs_running_) { |
| 140 NOTREACHED() << "Should always call SetResult except in the " | 120 NOTREACHED() << "Should always call SetResult except in the " |
| 141 "initialization failed case."; | 121 "initialization failed case."; |
| 142 RunCallback(PP_ERROR_FAILED); | 122 RunCallback(PP_ERROR_FAILED); |
| 143 } | 123 } |
| 144 } | 124 } |
| 145 | 125 |
| 146 void SetResult(int32_t result) { | 126 void SetResult(int32_t result) { |
| 147 DCHECK(needs_running_) << "Don't call SetResult when there already is one."; | 127 DCHECK(needs_running_) << "Don't call SetResult when there already is one."; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 162 } | 142 } |
| 163 | 143 |
| 164 bool needs_running_; | 144 bool needs_running_; |
| 165 pp::CompletionCallback callback_; | 145 pp::CompletionCallback callback_; |
| 166 }; | 146 }; |
| 167 | 147 |
| 168 } // namespace proxy | 148 } // namespace proxy |
| 169 } // namespace ppapi | 149 } // namespace ppapi |
| 170 | 150 |
| 171 #endif // PPAPI_PROXY_ENTER_PROXY_H_ | 151 #endif // PPAPI_PROXY_ENTER_PROXY_H_ |
| OLD | NEW |