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

Side by Side Diff: content/browser/renderer_host/pepper/browser_ppapi_host_impl.cc

Issue 11359097: Refactored the PPB_Flash_File_ModuleLocal/FileRef to the new ppapi resource model (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/browser/renderer_host/pepper/browser_ppapi_host_impl.h" 5 #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h"
6
6 #include "content/browser/renderer_host/pepper/pepper_message_filter.h" 7 #include "content/browser/renderer_host/pepper/pepper_message_filter.h"
7
8 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
9 #include "content/public/browser/render_view_host.h" 9 #include "content/public/browser/render_view_host.h"
10 #include "ipc/ipc_message_macros.h" 10 #include "ipc/ipc_message_macros.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 // static 14 // static
15 BrowserPpapiHost* BrowserPpapiHost::CreateExternalPluginProcess( 15 BrowserPpapiHost* BrowserPpapiHost::CreateExternalPluginProcess(
16 IPC::Sender* sender, 16 IPC::Sender* sender,
17 ppapi::PpapiPermissions permissions, 17 ppapi::PpapiPermissions permissions,
18 base::ProcessHandle plugin_child_process, 18 base::ProcessHandle plugin_child_process,
19 int plugin_child_process_id,
19 IPC::ChannelProxy* channel, 20 IPC::ChannelProxy* channel,
20 net::HostResolver* host_resolver, 21 net::HostResolver* host_resolver,
21 int render_process_id, 22 int render_process_id,
22 int render_view_id) { 23 int render_view_id) {
24 // TODO(raymes): Figure out how to plumb plugin_name and
25 // profile_data_directory through for NaCl. They are currently only needed for
26 // PPB_Flash_File interfaces so it doesn't matter.
27 std::string plugin_name;
28 FilePath profile_data_directory;
23 BrowserPpapiHostImpl* browser_ppapi_host = 29 BrowserPpapiHostImpl* browser_ppapi_host =
24 new BrowserPpapiHostImpl(sender, permissions); 30 new BrowserPpapiHostImpl(sender, permissions, plugin_name,
31 profile_data_directory, plugin_child_process_id);
25 browser_ppapi_host->set_plugin_process_handle(plugin_child_process); 32 browser_ppapi_host->set_plugin_process_handle(plugin_child_process);
26 33
27 channel->AddFilter( 34 channel->AddFilter(
28 new PepperMessageFilter(PepperMessageFilter::NACL, 35 new PepperMessageFilter(PepperMessageFilter::NACL,
29 permissions, 36 permissions,
30 host_resolver, 37 host_resolver,
31 render_process_id, 38 render_process_id,
32 render_view_id)); 39 render_view_id));
33 40
34 return browser_ppapi_host; 41 return browser_ppapi_host;
35 } 42 }
36 43
37 BrowserPpapiHostImpl::BrowserPpapiHostImpl( 44 BrowserPpapiHostImpl::BrowserPpapiHostImpl(
38 IPC::Sender* sender, 45 IPC::Sender* sender,
39 const ppapi::PpapiPermissions& permissions) 46 const ppapi::PpapiPermissions& permissions,
47 const std::string& plugin_name,
48 const FilePath& profile_data_directory,
49 int plugin_process_id)
40 : ppapi_host_(sender, permissions), 50 : ppapi_host_(sender, permissions),
41 plugin_process_handle_(base::kNullProcessHandle) { 51 plugin_process_handle_(base::kNullProcessHandle),
52 plugin_name_(plugin_name),
53 profile_data_directory_(profile_data_directory),
54 plugin_process_id_(plugin_process_id) {
42 message_filter_ = new HostMessageFilter(&ppapi_host_); 55 message_filter_ = new HostMessageFilter(&ppapi_host_);
43 ppapi_host_.AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( 56 ppapi_host_.AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>(
44 new ContentBrowserPepperHostFactory(this))); 57 new ContentBrowserPepperHostFactory(this)));
45 } 58 }
46 59
47 BrowserPpapiHostImpl::~BrowserPpapiHostImpl() { 60 BrowserPpapiHostImpl::~BrowserPpapiHostImpl() {
48 // Notify the filter so it won't foward messages to us. 61 // Notify the filter so it won't foward messages to us.
49 message_filter_->OnHostDestroyed(); 62 message_filter_->OnHostDestroyed();
50 } 63 }
51 64
(...skipping 20 matching lines...) Expand all
72 *render_process_id = 0; 85 *render_process_id = 0;
73 *render_view_id = 0; 86 *render_view_id = 0;
74 return false; 87 return false;
75 } 88 }
76 89
77 *render_process_id = found->second.process_id; 90 *render_process_id = found->second.process_id;
78 *render_view_id = found->second.view_id; 91 *render_view_id = found->second.view_id;
79 return true; 92 return true;
80 } 93 }
81 94
95 const std::string& BrowserPpapiHostImpl::GetPluginName() {
96 return plugin_name_;
97 }
98
99 const FilePath& BrowserPpapiHostImpl::GetProfileDataDirectory() {
100 return profile_data_directory_;
101 }
102
103 int BrowserPpapiHostImpl::GetPluginProcessID() {
104 return plugin_process_id_;
105 }
106
82 void BrowserPpapiHostImpl::AddInstanceForView(PP_Instance instance, 107 void BrowserPpapiHostImpl::AddInstanceForView(PP_Instance instance,
83 int render_process_id, 108 int render_process_id,
84 int render_view_id) { 109 int render_view_id) {
85 DCHECK(instance_to_view_.find(instance) == instance_to_view_.end()); 110 DCHECK(instance_to_view_.find(instance) == instance_to_view_.end());
86 111
87 RenderViewIDs ids; 112 RenderViewIDs ids;
88 ids.process_id = render_process_id; 113 ids.process_id = render_process_id;
89 ids.view_id = render_view_id; 114 ids.view_id = render_view_id;
90 instance_to_view_[instance] = ids; 115 instance_to_view_[instance] = ids;
91 } 116 }
(...skipping 23 matching lines...) Expand all
115 */ 140 */
116 return ppapi_host_->OnMessageReceived(msg); 141 return ppapi_host_->OnMessageReceived(msg);
117 } 142 }
118 143
119 void BrowserPpapiHostImpl::HostMessageFilter::OnHostDestroyed() { 144 void BrowserPpapiHostImpl::HostMessageFilter::OnHostDestroyed() {
120 DCHECK(ppapi_host_); 145 DCHECK(ppapi_host_);
121 ppapi_host_ = NULL; 146 ppapi_host_ = NULL;
122 } 147 }
123 148
124 } // namespace content 149 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698