Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(504)

Side by Side Diff: content/renderer/pepper/renderer_ppapi_host_impl.cc

Issue 11053003: Migrate Graphics2D to new design. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" 5 #include "content/renderer/pepper/renderer_ppapi_host_impl.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "content/renderer/pepper/pepper_graphics_2d_host.h"
9 #include "content/renderer/pepper/pepper_in_process_resource_creation.h" 10 #include "content/renderer/pepper/pepper_in_process_resource_creation.h"
10 #include "content/renderer/pepper/pepper_in_process_router.h" 11 #include "content/renderer/pepper/pepper_in_process_router.h"
11 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h" 12 #include "content/renderer/pepper/pepper_plugin_delegate_impl.h"
12 #include "content/renderer/render_view_impl.h" 13 #include "content/renderer/render_view_impl.h"
14 #include "ppapi/host/ppapi_host.h"
13 #include "ppapi/proxy/host_dispatcher.h" 15 #include "ppapi/proxy/host_dispatcher.h"
14 #include "webkit/plugins/ppapi/host_globals.h" 16 #include "webkit/plugins/ppapi/host_globals.h"
17 #include "webkit/plugins/ppapi/plugin_delegate.h"
15 #include "webkit/plugins/ppapi/plugin_module.h" 18 #include "webkit/plugins/ppapi/plugin_module.h"
16 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
17 20
18 using webkit::ppapi::HostGlobals; 21 using webkit::ppapi::HostGlobals;
19 using webkit::ppapi::PluginInstance; 22 using webkit::ppapi::PluginInstance;
20 using webkit::ppapi::PluginModule; 23 using webkit::ppapi::PluginModule;
21 24
22 namespace content { 25 namespace content {
23 26
24 // static 27 // static
(...skipping 28 matching lines...) Expand all
53 ppapi::proxy::HostDispatcher* dispatcher, 56 ppapi::proxy::HostDispatcher* dispatcher,
54 const ppapi::PpapiPermissions& permissions) 57 const ppapi::PpapiPermissions& permissions)
55 : module_(module), 58 : module_(module),
56 dispatcher_(dispatcher) { 59 dispatcher_(dispatcher) {
57 // Hook the PpapiHost up to the dispatcher for out-of-process communication. 60 // Hook the PpapiHost up to the dispatcher for out-of-process communication.
58 ppapi_host_.reset( 61 ppapi_host_.reset(
59 new ppapi::host::PpapiHost(dispatcher, permissions)); 62 new ppapi::host::PpapiHost(dispatcher, permissions));
60 ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( 63 ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>(
61 new ContentRendererPepperHostFactory(this))); 64 new ContentRendererPepperHostFactory(this)));
62 dispatcher->AddFilter(ppapi_host_.get()); 65 dispatcher->AddFilter(ppapi_host_.get());
66 is_running_in_process_ = false;
63 } 67 }
64 68
65 // In-process constructor. 69 // In-process constructor.
66 RendererPpapiHostImpl::RendererPpapiHostImpl( 70 RendererPpapiHostImpl::RendererPpapiHostImpl(
67 PluginModule* module, 71 PluginModule* module,
68 const ppapi::PpapiPermissions& permissions) 72 const ppapi::PpapiPermissions& permissions)
69 : module_(module), 73 : module_(module),
70 dispatcher_(NULL) { 74 dispatcher_(NULL) {
71 // Hook the host up to the in-process router. 75 // Hook the host up to the in-process router.
72 in_process_router_.reset(new PepperInProcessRouter(this)); 76 in_process_router_.reset(new PepperInProcessRouter(this));
73 ppapi_host_.reset(new ppapi::host::PpapiHost( 77 ppapi_host_.reset(new ppapi::host::PpapiHost(
74 in_process_router_->GetRendererToPluginSender(), permissions)); 78 in_process_router_->GetRendererToPluginSender(), permissions));
75 ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( 79 ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>(
76 new ContentRendererPepperHostFactory(this))); 80 new ContentRendererPepperHostFactory(this)));
81 is_running_in_process_ = true;
77 } 82 }
78 83
79 RendererPpapiHostImpl::~RendererPpapiHostImpl() { 84 RendererPpapiHostImpl::~RendererPpapiHostImpl() {
80 } 85 }
81 86
82 // static 87 // static
83 RendererPpapiHostImpl* RendererPpapiHostImpl::CreateOnModuleForOutOfProcess( 88 RendererPpapiHostImpl* RendererPpapiHostImpl::CreateOnModuleForOutOfProcess(
84 PluginModule* module, 89 PluginModule* module,
85 ppapi::proxy::HostDispatcher* dispatcher, 90 ppapi::proxy::HostDispatcher* dispatcher,
86 const ppapi::PpapiPermissions& permissions) { 91 const ppapi::PpapiPermissions& permissions) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 PluginInstance* instance_object = GetAndValidateInstance(instance); 144 PluginInstance* instance_object = GetAndValidateInstance(instance);
140 if (!instance_object) 145 if (!instance_object)
141 return NULL; 146 return NULL;
142 147
143 // Since we're the embedder, we can make assumptions about the delegate on 148 // Since we're the embedder, we can make assumptions about the delegate on
144 // the instance and get back to our RenderView. 149 // the instance and get back to our RenderView.
145 return static_cast<PepperPluginDelegateImpl*>( 150 return static_cast<PepperPluginDelegateImpl*>(
146 instance_object->delegate())->render_view(); 151 instance_object->delegate())->render_view();
147 } 152 }
148 153
154 webkit::ppapi::PluginDelegate::PlatformGraphics2D*
155 RendererPpapiHostImpl::GetPlatformGraphics2D(
156 PP_Resource resource) {
157 ppapi::host::ResourceHost* resource_host =
158 GetPpapiHost()->GetResourceHost(resource);
159 if (!resource_host || !resource_host->IsGraphics2DHost()) {
160 DLOG(ERROR) << "Resource is not Graphics2D";
161 return NULL;
162 }
163 return static_cast<PepperGraphics2DHost*>(resource_host);
164 }
165
149 bool RendererPpapiHostImpl::IsValidInstance( 166 bool RendererPpapiHostImpl::IsValidInstance(
150 PP_Instance instance) const { 167 PP_Instance instance) const {
151 return !!GetAndValidateInstance(instance); 168 return !!GetAndValidateInstance(instance);
152 } 169 }
153 170
154 webkit::ppapi::PluginInstance* RendererPpapiHostImpl::GetPluginInstance( 171 webkit::ppapi::PluginInstance* RendererPpapiHostImpl::GetPluginInstance(
155 PP_Instance instance) const { 172 PP_Instance instance) const {
156 return GetAndValidateInstance(instance); 173 return GetAndValidateInstance(instance);
157 } 174 }
158 175
(...skipping 20 matching lines...) Expand all
179 base::PlatformFile handle, 196 base::PlatformFile handle,
180 bool should_close_source) { 197 bool should_close_source) {
181 if (!dispatcher_) { 198 if (!dispatcher_) {
182 if (should_close_source) 199 if (should_close_source)
183 base::ClosePlatformFile(handle); 200 base::ClosePlatformFile(handle);
184 return IPC::InvalidPlatformFileForTransit(); 201 return IPC::InvalidPlatformFileForTransit();
185 } 202 }
186 return dispatcher_->ShareHandleWithRemote(handle, should_close_source); 203 return dispatcher_->ShareHandleWithRemote(handle, should_close_source);
187 } 204 }
188 205
206 bool RendererPpapiHostImpl::IsRunningInProcess() const {
207 return is_running_in_process_;
208 }
209
189 PluginInstance* RendererPpapiHostImpl::GetAndValidateInstance( 210 PluginInstance* RendererPpapiHostImpl::GetAndValidateInstance(
190 PP_Instance pp_instance) const { 211 PP_Instance pp_instance) const {
191 PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance); 212 PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance);
192 if (!instance) 213 if (!instance)
193 return NULL; 214 return NULL;
194 if (instance->module() != module_) 215 if (instance->module() != module_)
195 return NULL; 216 return NULL;
196 return instance; 217 return instance;
197 } 218 }
198 219
199 } // namespace content 220 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698