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

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

Issue 11366038: Rewrite PPB_AudioInput_Dev to use the new-style host/resource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 | Annotate | Revision Log
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_in_process_resource_creation.h" 9 #include "content/renderer/pepper/pepper_in_process_resource_creation.h"
10 #include "content/renderer/pepper/pepper_in_process_router.h" 10 #include "content/renderer/pepper/pepper_in_process_router.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 } 45 }
46 return renderer_ppapi_host; 46 return renderer_ppapi_host;
47 } 47 }
48 48
49 49
50 // Out-of-process constructor. 50 // Out-of-process constructor.
51 RendererPpapiHostImpl::RendererPpapiHostImpl( 51 RendererPpapiHostImpl::RendererPpapiHostImpl(
52 PluginModule* module, 52 PluginModule* module,
53 ppapi::proxy::HostDispatcher* dispatcher, 53 ppapi::proxy::HostDispatcher* dispatcher,
54 const ppapi::PpapiPermissions& permissions) 54 const ppapi::PpapiPermissions& permissions)
55 : module_(module) { 55 : module_(module),
56 dispatcher_(dispatcher) {
56 // Hook the PpapiHost up to the dispatcher for out-of-process communication. 57 // Hook the PpapiHost up to the dispatcher for out-of-process communication.
57 ppapi_host_.reset( 58 ppapi_host_.reset(
58 new ppapi::host::PpapiHost(dispatcher, permissions)); 59 new ppapi::host::PpapiHost(dispatcher, permissions));
59 ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( 60 ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>(
60 new ContentRendererPepperHostFactory(this))); 61 new ContentRendererPepperHostFactory(this)));
61 dispatcher->AddFilter(ppapi_host_.get()); 62 dispatcher->AddFilter(ppapi_host_.get());
62 } 63 }
63 64
64 // In-process constructor. 65 // In-process constructor.
65 RendererPpapiHostImpl::RendererPpapiHostImpl( 66 RendererPpapiHostImpl::RendererPpapiHostImpl(
66 PluginModule* module, 67 PluginModule* module,
67 const ppapi::PpapiPermissions& permissions) 68 const ppapi::PpapiPermissions& permissions)
68 : module_(module) { 69 : module_(module),
70 dispatcher_(NULL) {
69 // Hook the host up to the in-process router. 71 // Hook the host up to the in-process router.
70 in_process_router_.reset(new PepperInProcessRouter(this)); 72 in_process_router_.reset(new PepperInProcessRouter(this));
71 ppapi_host_.reset(new ppapi::host::PpapiHost( 73 ppapi_host_.reset(new ppapi::host::PpapiHost(
72 in_process_router_->GetRendererToPluginSender(), permissions)); 74 in_process_router_->GetRendererToPluginSender(), permissions));
73 ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( 75 ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>(
74 new ContentRendererPepperHostFactory(this))); 76 new ContentRendererPepperHostFactory(this)));
75 } 77 }
76 78
77 RendererPpapiHostImpl::~RendererPpapiHostImpl() { 79 RendererPpapiHostImpl::~RendererPpapiHostImpl() {
78 } 80 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // the instance and get back to our RenderView. 144 // the instance and get back to our RenderView.
143 return static_cast<PepperPluginDelegateImpl*>( 145 return static_cast<PepperPluginDelegateImpl*>(
144 instance_object->delegate())->render_view(); 146 instance_object->delegate())->render_view();
145 } 147 }
146 148
147 bool RendererPpapiHostImpl::IsValidInstance( 149 bool RendererPpapiHostImpl::IsValidInstance(
148 PP_Instance instance) const { 150 PP_Instance instance) const {
149 return !!GetAndValidateInstance(instance); 151 return !!GetAndValidateInstance(instance);
150 } 152 }
151 153
154 webkit::ppapi::PluginInstance* RendererPpapiHostImpl::GetPluginInstance(
155 PP_Instance instance) const {
156 return GetAndValidateInstance(instance);
157 }
158
152 WebKit::WebPluginContainer* RendererPpapiHostImpl::GetContainerForInstance( 159 WebKit::WebPluginContainer* RendererPpapiHostImpl::GetContainerForInstance(
153 PP_Instance instance) const { 160 PP_Instance instance) const {
154 PluginInstance* instance_object = GetAndValidateInstance(instance); 161 PluginInstance* instance_object = GetAndValidateInstance(instance);
155 if (!instance_object) 162 if (!instance_object)
156 return NULL; 163 return NULL;
157 return instance_object->container(); 164 return instance_object->container();
158 } 165 }
159 166
160 bool RendererPpapiHostImpl::HasUserGesture(PP_Instance instance) const { 167 bool RendererPpapiHostImpl::HasUserGesture(PP_Instance instance) const {
161 PluginInstance* instance_object = GetAndValidateInstance(instance); 168 PluginInstance* instance_object = GetAndValidateInstance(instance);
162 if (!instance_object) 169 if (!instance_object)
163 return false; 170 return false;
164 171
165 if (instance_object->module()->permissions().HasPermission( 172 if (instance_object->module()->permissions().HasPermission(
166 ppapi::PERMISSION_BYPASS_USER_GESTURE)) 173 ppapi::PERMISSION_BYPASS_USER_GESTURE))
167 return true; 174 return true;
168 return instance_object->IsProcessingUserGesture(); 175 return instance_object->IsProcessingUserGesture();
169 } 176 }
170 177
178 IPC::PlatformFileForTransit RendererPpapiHostImpl::ShareHandleWithRemote(
179 base::PlatformFile handle,
180 bool should_close_source) {
181 if (!dispatcher_) {
182 if (should_close_source)
183 base::ClosePlatformFile(handle);
184 return IPC::InvalidPlatformFileForTransit();
185 }
186 return dispatcher_->ShareHandleWithRemote(handle, should_close_source);
187 }
188
171 PluginInstance* RendererPpapiHostImpl::GetAndValidateInstance( 189 PluginInstance* RendererPpapiHostImpl::GetAndValidateInstance(
172 PP_Instance pp_instance) const { 190 PP_Instance pp_instance) const {
173 PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance); 191 PluginInstance* instance = HostGlobals::Get()->GetInstance(pp_instance);
174 if (!instance) 192 if (!instance)
175 return NULL; 193 return NULL;
176 if (instance->module() != module_) 194 if (instance->module() != module_)
177 return NULL; 195 return NULL;
178 return instance; 196 return instance;
179 } 197 }
180 198
181 } // namespace content 199 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/renderer_ppapi_host_impl.h ('k') | ppapi/api/dev/ppb_audio_input_dev.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698