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_globals.h" | 12 #include "ppapi/proxy/plugin_globals.h" |
13 #include "ppapi/proxy/plugin_resource_tracker.h" | 13 #include "ppapi/proxy/plugin_resource_tracker.h" |
14 #include "ppapi/thunk/enter.h" | 14 #include "ppapi/thunk/enter.h" |
15 | 15 |
16 namespace ppapi { | 16 namespace ppapi { |
17 | 17 |
18 namespace thunk { | |
19 class ResourceCreationAPI; | |
20 } | |
21 | |
22 namespace proxy { | 18 namespace proxy { |
23 | 19 |
24 // Wrapper around EnterResourceNoLock that takes a host resource. This is used | 20 // Wrapper around EnterResourceNoLock that takes a host resource. This is used |
25 // when handling messages in the plugin from the host and we need to convert to | 21 // when handling messages in the plugin from the host and we need to convert to |
26 // an object in the plugin side corresponding to that. | 22 // an object in the plugin side corresponding to that. |
27 // | 23 // |
28 // This never locks since we assume the host Resource is coming from IPC, and | 24 // This never locks since we assume the host Resource is coming from IPC, and |
29 // never logs errors since we assume the host is doing reasonable things. | 25 // never logs errors since we assume the host is doing reasonable things. |
30 template<typename ResourceT> | 26 template<typename ResourceT> |
31 class EnterPluginFromHostResource | 27 class EnterPluginFromHostResource |
32 : public thunk::EnterResourceNoLock<ResourceT> { | 28 : public thunk::EnterResourceNoLock<ResourceT> { |
33 public: | 29 public: |
34 EnterPluginFromHostResource(const HostResource& host_resource) | 30 explicit EnterPluginFromHostResource(const HostResource& host_resource) |
35 : thunk::EnterResourceNoLock<ResourceT>( | 31 : thunk::EnterResourceNoLock<ResourceT>( |
36 PluginGlobals::Get()->plugin_resource_tracker()-> | 32 PluginGlobals::Get()->plugin_resource_tracker()-> |
37 PluginResourceForHostResource(host_resource), | 33 PluginResourceForHostResource(host_resource), |
38 false) { | 34 false) { |
39 // Validate that we're in the plugin rather than the host. Otherwise this | 35 // Validate that we're in the plugin rather than the host. Otherwise this |
40 // object will do the wrong thing. In the plugin, the instance should have | 36 // object will do the wrong thing. In the plugin, the instance should have |
41 // a corresponding plugin dispatcher (assuming the resource is valid). | 37 // a corresponding plugin dispatcher (assuming the resource is valid). |
42 DCHECK(this->failed() || | 38 DCHECK(this->failed() || |
43 PluginDispatcher::GetForInstance(host_resource.instance())); | 39 PluginDispatcher::GetForInstance(host_resource.instance())); |
44 } | 40 } |
45 }; | 41 }; |
46 | 42 |
47 template<typename ResourceT> | 43 template<typename ResourceT> |
48 class EnterHostFromHostResource | 44 class EnterHostFromHostResource |
49 : public thunk::EnterResourceNoLock<ResourceT> { | 45 : public thunk::EnterResourceNoLock<ResourceT> { |
50 public: | 46 public: |
51 EnterHostFromHostResource(const HostResource& host_resource) | 47 explicit EnterHostFromHostResource(const HostResource& host_resource) |
52 : thunk::EnterResourceNoLock<ResourceT>( | 48 : thunk::EnterResourceNoLock<ResourceT>( |
53 host_resource.host_resource(), false) { | 49 host_resource.host_resource(), false) { |
54 // Validate that we're in the host rather than the plugin. Otherwise this | 50 // Validate that we're in the host rather than the plugin. Otherwise this |
55 // object will do the wrong thing. In the host, the instance should have | 51 // object will do the wrong thing. In the host, the instance should have |
56 // a corresponding host disptacher (assuming the resource is valid). | 52 // a corresponding host disptacher (assuming the resource is valid). |
57 DCHECK(this->failed() || | 53 DCHECK(this->failed() || |
58 HostDispatcher::GetForInstance(host_resource.instance())); | 54 HostDispatcher::GetForInstance(host_resource.instance())); |
59 } | 55 } |
60 }; | 56 }; |
61 | 57 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 } | 235 } |
240 | 236 |
241 bool needs_running_; | 237 bool needs_running_; |
242 pp::CompletionCallback callback_; | 238 pp::CompletionCallback callback_; |
243 }; | 239 }; |
244 | 240 |
245 } // namespace proxy | 241 } // namespace proxy |
246 } // namespace ppapi | 242 } // namespace ppapi |
247 | 243 |
248 #endif // PPAPI_PROXY_ENTER_PROXY_H_ | 244 #endif // PPAPI_PROXY_ENTER_PROXY_H_ |
OLD | NEW |