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_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" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 Method method, | 144 Method method, |
145 const A& a, | 145 const A& a, |
146 const B& b) | 146 const B& b) |
147 : EnterHostFromHostResource<ResourceT>(host_resource, | 147 : EnterHostFromHostResource<ResourceT>(host_resource, |
148 factory.NewOptionalCallback(method, a, b)), | 148 factory.NewOptionalCallback(method, a, b)), |
149 needs_running_(true) { | 149 needs_running_(true) { |
150 if (this->failed()) | 150 if (this->failed()) |
151 RunCallback(PP_ERROR_BADRESOURCE); | 151 RunCallback(PP_ERROR_BADRESOURCE); |
152 } | 152 } |
153 | 153 |
| 154 // For callbacks that take three extra parameters as a closure. |
| 155 template<class CallbackFactory, typename Method, typename A, typename B, |
| 156 typename C> |
| 157 EnterHostFromHostResourceForceCallback( |
| 158 const HostResource& host_resource, |
| 159 CallbackFactory& factory, |
| 160 Method method, |
| 161 const A& a, |
| 162 const B& b, |
| 163 const C& c) |
| 164 : EnterHostFromHostResource<ResourceT>(host_resource, |
| 165 factory.NewOptionalCallback(method, a, b, c)), |
| 166 needs_running_(true) { |
| 167 if (this->failed()) |
| 168 RunCallback(PP_ERROR_BADRESOURCE); |
| 169 } |
| 170 |
154 ~EnterHostFromHostResourceForceCallback() { | 171 ~EnterHostFromHostResourceForceCallback() { |
155 if (needs_running_) { | 172 if (needs_running_) { |
156 NOTREACHED() << "Should always call SetResult except in the " | 173 NOTREACHED() << "Should always call SetResult except in the " |
157 "initialization failed case."; | 174 "initialization failed case."; |
158 RunCallback(PP_ERROR_FAILED); | 175 RunCallback(PP_ERROR_FAILED); |
159 } | 176 } |
160 } | 177 } |
161 | 178 |
162 void SetResult(int32_t result) { | 179 void SetResult(int32_t result) { |
163 DCHECK(needs_running_) << "Don't call SetResult when there already is one."; | 180 DCHECK(needs_running_) << "Don't call SetResult when there already is one."; |
(...skipping 14 matching lines...) Expand all Loading... |
178 this->ClearCallback(); | 195 this->ClearCallback(); |
179 } | 196 } |
180 | 197 |
181 bool needs_running_; | 198 bool needs_running_; |
182 }; | 199 }; |
183 | 200 |
184 } // namespace proxy | 201 } // namespace proxy |
185 } // namespace ppapi | 202 } // namespace ppapi |
186 | 203 |
187 #endif // PPAPI_PROXY_ENTER_PROXY_H_ | 204 #endif // PPAPI_PROXY_ENTER_PROXY_H_ |
OLD | NEW |