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" | |
13 #include "ppapi/proxy/plugin_resource_tracker.h" | 12 #include "ppapi/proxy/plugin_resource_tracker.h" |
14 #include "ppapi/thunk/enter.h" | 13 #include "ppapi/thunk/enter.h" |
15 | 14 |
16 namespace ppapi { | 15 namespace ppapi { |
17 | 16 |
18 namespace thunk { | 17 namespace thunk { |
19 class ResourceCreationAPI; | 18 class ResourceCreationAPI; |
20 } | 19 } |
21 | 20 |
22 namespace proxy { | 21 namespace proxy { |
23 | 22 |
24 // Wrapper around EnterResourceNoLock that takes a host resource. This is used | 23 // 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 | 24 // 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. | 25 // an object in the plugin side corresponding to that. |
27 // | 26 // |
28 // This never locks since we assume the host Resource is coming from IPC, and | 27 // 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. | 28 // never logs errors since we assume the host is doing reasonable things. |
30 template<typename ResourceT> | 29 template<typename ResourceT> |
31 class EnterPluginFromHostResource | 30 class EnterPluginFromHostResource |
32 : public thunk::EnterResourceNoLock<ResourceT> { | 31 : public thunk::EnterResourceNoLock<ResourceT> { |
33 public: | 32 public: |
34 EnterPluginFromHostResource(const HostResource& host_resource) | 33 EnterPluginFromHostResource(const HostResource& host_resource) |
35 : thunk::EnterResourceNoLock<ResourceT>( | 34 : thunk::EnterResourceNoLock<ResourceT>( |
36 PluginGlobals::Get()->plugin_resource_tracker()-> | 35 PluginResourceTracker::GetInstance()->PluginResourceForHostResource( |
37 PluginResourceForHostResource(host_resource), | 36 host_resource), |
38 false) { | 37 false) { |
39 // Validate that we're in the plugin rather than the host. Otherwise this | 38 // 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 | 39 // object will do the wrong thing. In the plugin, the instance should have |
41 // a corresponding plugin dispatcher (assuming the resource is valid). | 40 // a corresponding plugin dispatcher (assuming the resource is valid). |
42 DCHECK(this->failed() || | 41 DCHECK(this->failed() || |
43 PluginDispatcher::GetForInstance(host_resource.instance())); | 42 PluginDispatcher::GetForInstance(host_resource.instance())); |
44 } | 43 } |
45 }; | 44 }; |
46 | 45 |
47 template<typename ResourceT> | 46 template<typename ResourceT> |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 } | 162 } |
164 | 163 |
165 bool needs_running_; | 164 bool needs_running_; |
166 pp::CompletionCallback callback_; | 165 pp::CompletionCallback callback_; |
167 }; | 166 }; |
168 | 167 |
169 } // namespace proxy | 168 } // namespace proxy |
170 } // namespace ppapi | 169 } // namespace ppapi |
171 | 170 |
172 #endif // PPAPI_PROXY_ENTER_PROXY_H_ | 171 #endif // PPAPI_PROXY_ENTER_PROXY_H_ |
OLD | NEW |