| OLD | NEW |
| 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/browser/renderer_host/pepper/browser_ppapi_host_impl.h" | 5 #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h" |
| 6 | 6 |
| 7 #include "base/metrics/sparse_histogram.h" | 7 #include "base/metrics/sparse_histogram.h" |
| 8 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" | 8 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" |
| 9 #include "content/browser/tracing/trace_message_filter.h" | 9 #include "content/browser/tracing/trace_message_filter.h" |
| 10 #include "content/common/pepper_renderer_instance_data.h" | 10 #include "content/common/pepper_renderer_instance_data.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 const base::FilePath& profile_directory) { | 25 const base::FilePath& profile_directory) { |
| 26 // The plugin name and path shouldn't be needed for external plugins. | 26 // The plugin name and path shouldn't be needed for external plugins. |
| 27 BrowserPpapiHostImpl* browser_ppapi_host = | 27 BrowserPpapiHostImpl* browser_ppapi_host = |
| 28 new BrowserPpapiHostImpl(sender, | 28 new BrowserPpapiHostImpl(sender, |
| 29 permissions, | 29 permissions, |
| 30 std::string(), | 30 std::string(), |
| 31 base::FilePath(), | 31 base::FilePath(), |
| 32 profile_directory, | 32 profile_directory, |
| 33 false /* in_process */, | 33 false /* in_process */, |
| 34 true /* external_plugin */); | 34 true /* external_plugin */); |
| 35 browser_ppapi_host->set_plugin_process_handle(plugin_child_process); | 35 browser_ppapi_host->set_plugin_process( |
| 36 base::Process::DeprecatedGetProcessFromHandle(plugin_child_process)); |
| 36 | 37 |
| 37 scoped_refptr<PepperMessageFilter> pepper_message_filter( | 38 scoped_refptr<PepperMessageFilter> pepper_message_filter( |
| 38 new PepperMessageFilter()); | 39 new PepperMessageFilter()); |
| 39 channel->AddFilter(pepper_message_filter->GetFilter()); | 40 channel->AddFilter(pepper_message_filter->GetFilter()); |
| 40 channel->AddFilter(browser_ppapi_host->message_filter().get()); | 41 channel->AddFilter(browser_ppapi_host->message_filter().get()); |
| 41 channel->AddFilter((new TraceMessageFilter())->GetFilter()); | 42 channel->AddFilter((new TraceMessageFilter())->GetFilter()); |
| 42 | 43 |
| 43 return browser_ppapi_host; | 44 return browser_ppapi_host; |
| 44 } | 45 } |
| 45 | 46 |
| 46 BrowserPpapiHostImpl::BrowserPpapiHostImpl( | 47 BrowserPpapiHostImpl::BrowserPpapiHostImpl( |
| 47 IPC::Sender* sender, | 48 IPC::Sender* sender, |
| 48 const ppapi::PpapiPermissions& permissions, | 49 const ppapi::PpapiPermissions& permissions, |
| 49 const std::string& plugin_name, | 50 const std::string& plugin_name, |
| 50 const base::FilePath& plugin_path, | 51 const base::FilePath& plugin_path, |
| 51 const base::FilePath& profile_data_directory, | 52 const base::FilePath& profile_data_directory, |
| 52 bool in_process, | 53 bool in_process, |
| 53 bool external_plugin) | 54 bool external_plugin) |
| 54 : ppapi_host_(new ppapi::host::PpapiHost(sender, permissions)), | 55 : ppapi_host_(new ppapi::host::PpapiHost(sender, permissions)), |
| 55 plugin_process_handle_(base::kNullProcessHandle), | |
| 56 plugin_name_(plugin_name), | 56 plugin_name_(plugin_name), |
| 57 plugin_path_(plugin_path), | 57 plugin_path_(plugin_path), |
| 58 profile_data_directory_(profile_data_directory), | 58 profile_data_directory_(profile_data_directory), |
| 59 in_process_(in_process), | 59 in_process_(in_process), |
| 60 external_plugin_(external_plugin), | 60 external_plugin_(external_plugin), |
| 61 ssl_context_helper_(new SSLContextHelper()) { | 61 ssl_context_helper_(new SSLContextHelper()) { |
| 62 message_filter_ = new HostMessageFilter(ppapi_host_.get(), this); | 62 message_filter_ = new HostMessageFilter(ppapi_host_.get(), this); |
| 63 ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( | 63 ppapi_host_->AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( |
| 64 new ContentBrowserPepperHostFactory(this))); | 64 new ContentBrowserPepperHostFactory(this))); |
| 65 } | 65 } |
| 66 | 66 |
| 67 BrowserPpapiHostImpl::~BrowserPpapiHostImpl() { | 67 BrowserPpapiHostImpl::~BrowserPpapiHostImpl() { |
| 68 // Notify the filter so it won't foward messages to us. | 68 // Notify the filter so it won't foward messages to us. |
| 69 message_filter_->OnHostDestroyed(); | 69 message_filter_->OnHostDestroyed(); |
| 70 | 70 |
| 71 // Delete the host explicitly first. This shutdown will destroy the | 71 // Delete the host explicitly first. This shutdown will destroy the |
| 72 // resources, which may want to do cleanup in their destructors and expect | 72 // resources, which may want to do cleanup in their destructors and expect |
| 73 // their pointers to us to be valid. | 73 // their pointers to us to be valid. |
| 74 ppapi_host_.reset(); | 74 ppapi_host_.reset(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 ppapi::host::PpapiHost* BrowserPpapiHostImpl::GetPpapiHost() { | 77 ppapi::host::PpapiHost* BrowserPpapiHostImpl::GetPpapiHost() { |
| 78 return ppapi_host_.get(); | 78 return ppapi_host_.get(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 base::ProcessHandle BrowserPpapiHostImpl::GetPluginProcessHandle() const { | 81 const base::Process& BrowserPpapiHostImpl::GetPluginProcess() const { |
| 82 // Handle should previously have been set before use. | 82 // Handle should previously have been set before use. |
| 83 DCHECK(in_process_ || plugin_process_handle_ != base::kNullProcessHandle); | 83 DCHECK(in_process_ || plugin_process_.IsValid()); |
| 84 return plugin_process_handle_; | 84 return plugin_process_; |
| 85 } | 85 } |
| 86 | 86 |
| 87 bool BrowserPpapiHostImpl::IsValidInstance(PP_Instance instance) const { | 87 bool BrowserPpapiHostImpl::IsValidInstance(PP_Instance instance) const { |
| 88 return instance_map_.find(instance) != instance_map_.end(); | 88 return instance_map_.find(instance) != instance_map_.end(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 bool BrowserPpapiHostImpl::GetRenderFrameIDsForInstance( | 91 bool BrowserPpapiHostImpl::GetRenderFrameIDsForInstance( |
| 92 PP_Instance instance, | 92 PP_Instance instance, |
| 93 int* render_process_id, | 93 int* render_process_id, |
| 94 int* render_frame_id) const { | 94 int* render_frame_id) const { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 instance_data[i].render_process_id = instance->second.render_process_id; | 212 instance_data[i].render_process_id = instance->second.render_process_id; |
| 213 instance_data[i].render_frame_id = instance->second.render_frame_id; | 213 instance_data[i].render_frame_id = instance->second.render_frame_id; |
| 214 instance_data[i].document_url = instance->second.document_url; | 214 instance_data[i].document_url = instance->second.document_url; |
| 215 ++instance; | 215 ++instance; |
| 216 ++i; | 216 ++i; |
| 217 } | 217 } |
| 218 on_keepalive_callback_.Run(instance_data, profile_data_directory_); | 218 on_keepalive_callback_.Run(instance_data, profile_data_directory_); |
| 219 } | 219 } |
| 220 | 220 |
| 221 } // namespace content | 221 } // namespace content |
| OLD | NEW |