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

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: rebase Created 8 years 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
« no previous file with comments | « content/renderer/pepper/renderer_ppapi_host_impl.h ('k') | ppapi/cpp/graphics_2d.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
13 #include "content/renderer/render_widget_fullscreen_pepper.h" 14 #include "content/renderer/render_widget_fullscreen_pepper.h"
15 #include "ppapi/host/ppapi_host.h"
14 #include "ppapi/proxy/host_dispatcher.h" 16 #include "ppapi/proxy/host_dispatcher.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
16 #include "ui/gfx/point.h" 18 #include "ui/gfx/point.h"
17 #include "webkit/plugins/ppapi/fullscreen_container.h" 19 #include "webkit/plugins/ppapi/fullscreen_container.h"
18 #include "webkit/plugins/ppapi/host_globals.h" 20 #include "webkit/plugins/ppapi/host_globals.h"
21 #include "webkit/plugins/ppapi/plugin_delegate.h"
19 #include "webkit/plugins/ppapi/plugin_module.h" 22 #include "webkit/plugins/ppapi/plugin_module.h"
20 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 23 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
21 24
22 using webkit::ppapi::HostGlobals; 25 using webkit::ppapi::HostGlobals;
23 using webkit::ppapi::PluginInstance; 26 using webkit::ppapi::PluginInstance;
24 using webkit::ppapi::PluginModule; 27 using webkit::ppapi::PluginModule;
25 28
26 namespace content { 29 namespace content {
27 30
28 // static 31 // static
(...skipping 28 matching lines...) Expand all
57 ppapi::proxy::HostDispatcher* dispatcher, 60 ppapi::proxy::HostDispatcher* dispatcher,
58 const ppapi::PpapiPermissions& permissions) 61 const ppapi::PpapiPermissions& permissions)
59 : module_(module), 62 : module_(module),
60 dispatcher_(dispatcher) { 63 dispatcher_(dispatcher) {
61 // Hook the PpapiHost up to the dispatcher for out-of-process communication. 64 // Hook the PpapiHost up to the dispatcher for out-of-process communication.
62 ppapi_host_.reset( 65 ppapi_host_.reset(
63 new ppapi::host::PpapiHost(dispatcher, permissions)); 66 new ppapi::host::PpapiHost(dispatcher, permissions));
64 ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( 67 ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>(
65 new ContentRendererPepperHostFactory(this))); 68 new ContentRendererPepperHostFactory(this)));
66 dispatcher->AddFilter(ppapi_host_.get()); 69 dispatcher->AddFilter(ppapi_host_.get());
70 is_running_in_process_ = false;
67 } 71 }
68 72
69 // In-process constructor. 73 // In-process constructor.
70 RendererPpapiHostImpl::RendererPpapiHostImpl( 74 RendererPpapiHostImpl::RendererPpapiHostImpl(
71 PluginModule* module, 75 PluginModule* module,
72 const ppapi::PpapiPermissions& permissions) 76 const ppapi::PpapiPermissions& permissions)
73 : module_(module), 77 : module_(module),
74 dispatcher_(NULL) { 78 dispatcher_(NULL) {
75 // Hook the host up to the in-process router. 79 // Hook the host up to the in-process router.
76 in_process_router_.reset(new PepperInProcessRouter(this)); 80 in_process_router_.reset(new PepperInProcessRouter(this));
77 ppapi_host_.reset(new ppapi::host::PpapiHost( 81 ppapi_host_.reset(new ppapi::host::PpapiHost(
78 in_process_router_->GetRendererToPluginSender(), permissions)); 82 in_process_router_->GetRendererToPluginSender(), permissions));
79 ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( 83 ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>(
80 new ContentRendererPepperHostFactory(this))); 84 new ContentRendererPepperHostFactory(this)));
85 is_running_in_process_ = true;
81 } 86 }
82 87
83 RendererPpapiHostImpl::~RendererPpapiHostImpl() { 88 RendererPpapiHostImpl::~RendererPpapiHostImpl() {
84 } 89 }
85 90
86 // static 91 // static
87 RendererPpapiHostImpl* RendererPpapiHostImpl::CreateOnModuleForOutOfProcess( 92 RendererPpapiHostImpl* RendererPpapiHostImpl::CreateOnModuleForOutOfProcess(
88 PluginModule* module, 93 PluginModule* module,
89 ppapi::proxy::HostDispatcher* dispatcher, 94 ppapi::proxy::HostDispatcher* dispatcher,
90 const ppapi::PpapiPermissions& permissions) { 95 const ppapi::PpapiPermissions& permissions) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 PluginInstance* instance_object = GetAndValidateInstance(instance); 148 PluginInstance* instance_object = GetAndValidateInstance(instance);
144 if (!instance_object) 149 if (!instance_object)
145 return NULL; 150 return NULL;
146 151
147 // Since we're the embedder, we can make assumptions about the delegate on 152 // Since we're the embedder, we can make assumptions about the delegate on
148 // the instance and get back to our RenderView. 153 // the instance and get back to our RenderView.
149 return static_cast<PepperPluginDelegateImpl*>( 154 return static_cast<PepperPluginDelegateImpl*>(
150 instance_object->delegate())->render_view(); 155 instance_object->delegate())->render_view();
151 } 156 }
152 157
158 webkit::ppapi::PluginDelegate::PlatformGraphics2D*
159 RendererPpapiHostImpl::GetPlatformGraphics2D(
160 PP_Resource resource) {
161 ppapi::host::ResourceHost* resource_host =
162 GetPpapiHost()->GetResourceHost(resource);
163 if (!resource_host || !resource_host->IsGraphics2DHost()) {
164 DLOG(ERROR) << "Resource is not Graphics2D";
165 return NULL;
166 }
167 return static_cast<PepperGraphics2DHost*>(resource_host);
168 }
169
153 bool RendererPpapiHostImpl::IsValidInstance( 170 bool RendererPpapiHostImpl::IsValidInstance(
154 PP_Instance instance) const { 171 PP_Instance instance) const {
155 return !!GetAndValidateInstance(instance); 172 return !!GetAndValidateInstance(instance);
156 } 173 }
157 174
158 webkit::ppapi::PluginInstance* RendererPpapiHostImpl::GetPluginInstance( 175 webkit::ppapi::PluginInstance* RendererPpapiHostImpl::GetPluginInstance(
159 PP_Instance instance) const { 176 PP_Instance instance) const {
160 return GetAndValidateInstance(instance); 177 return GetAndValidateInstance(instance);
161 } 178 }
162 179
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 base::PlatformFile handle, 234 base::PlatformFile handle,
218 bool should_close_source) { 235 bool should_close_source) {
219 if (!dispatcher_) { 236 if (!dispatcher_) {
220 if (should_close_source) 237 if (should_close_source)
221 base::ClosePlatformFile(handle); 238 base::ClosePlatformFile(handle);
222 return IPC::InvalidPlatformFileForTransit(); 239 return IPC::InvalidPlatformFileForTransit();
223 } 240 }
224 return dispatcher_->ShareHandleWithRemote(handle, should_close_source); 241 return dispatcher_->ShareHandleWithRemote(handle, should_close_source);
225 } 242 }
226 243
244 bool RendererPpapiHostImpl::IsRunningInProcess() const {
245 return is_running_in_process_;
246 }
247
227 PluginInstance* RendererPpapiHostImpl::GetAndValidateInstance( 248 PluginInstance* RendererPpapiHostImpl::GetAndValidateInstance(
228 PP_Instance pp_instance) const { 249 PP_Instance pp_instance) const {
229 PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance); 250 PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance);
230 if (!instance) 251 if (!instance)
231 return NULL; 252 return NULL;
232 if (instance->module() != module_) 253 if (instance->module() != module_)
233 return NULL; 254 return NULL;
234 return instance; 255 return instance;
235 } 256 }
236 257
237 } // namespace content 258 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/renderer_ppapi_host_impl.h ('k') | ppapi/cpp/graphics_2d.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698