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

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 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 IPC::ChannelProxy* channel, 19 IPC::ChannelProxy* channel,
20 net::HostResolver* host_resolver, 20 net::HostResolver* host_resolver,
21 int render_process_id, 21 int render_process_id,
22 int render_view_id) { 22 int render_view_id) {
23 // TODO(raymes): Figure out how to plumb plugin_name and
24 // profile_data_directory through for NaCl. They are currently only needed for
25 // PPB_Flash_File interfaces so it doesn't matter.
26 std::string plugin_name;
27 FilePath profile_data_directory;
23 BrowserPpapiHostImpl* browser_ppapi_host = 28 BrowserPpapiHostImpl* browser_ppapi_host =
24 new BrowserPpapiHostImpl(sender, permissions); 29 new BrowserPpapiHostImpl(sender, permissions, plugin_name,
30 profile_data_directory);
25 browser_ppapi_host->set_plugin_process_handle(plugin_child_process); 31 browser_ppapi_host->set_plugin_process_handle(plugin_child_process);
26 32
27 channel->AddFilter( 33 channel->AddFilter(
28 new PepperMessageFilter(PepperMessageFilter::NACL, 34 new PepperMessageFilter(PepperMessageFilter::NACL,
29 permissions, 35 permissions,
30 host_resolver, 36 host_resolver,
31 render_process_id, 37 render_process_id,
32 render_view_id)); 38 render_view_id));
33 channel->AddFilter(browser_ppapi_host->message_filter()); 39 channel->AddFilter(browser_ppapi_host->message_filter());
34 40
35 return browser_ppapi_host; 41 return browser_ppapi_host;
36 } 42 }
37 43
38 BrowserPpapiHostImpl::BrowserPpapiHostImpl( 44 BrowserPpapiHostImpl::BrowserPpapiHostImpl(
39 IPC::Sender* sender, 45 IPC::Sender* sender,
40 const ppapi::PpapiPermissions& permissions) 46 const ppapi::PpapiPermissions& permissions,
47 const std::string& plugin_name,
48 const FilePath& profile_data_directory)
41 : ppapi_host_(sender, permissions), 49 : ppapi_host_(sender, permissions),
42 plugin_process_handle_(base::kNullProcessHandle) { 50 plugin_process_handle_(base::kNullProcessHandle),
51 plugin_name_(plugin_name),
52 profile_data_directory_(profile_data_directory) {
43 message_filter_ = new HostMessageFilter(&ppapi_host_); 53 message_filter_ = new HostMessageFilter(&ppapi_host_);
44 ppapi_host_.AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>( 54 ppapi_host_.AddHostFactoryFilter(scoped_ptr<ppapi::host::HostFactory>(
45 new ContentBrowserPepperHostFactory(this))); 55 new ContentBrowserPepperHostFactory(this)));
46 } 56 }
47 57
48 BrowserPpapiHostImpl::~BrowserPpapiHostImpl() { 58 BrowserPpapiHostImpl::~BrowserPpapiHostImpl() {
49 // Notify the filter so it won't foward messages to us. 59 // Notify the filter so it won't foward messages to us.
50 message_filter_->OnHostDestroyed(); 60 message_filter_->OnHostDestroyed();
51 } 61 }
52 62
(...skipping 20 matching lines...) Expand all
73 *render_process_id = 0; 83 *render_process_id = 0;
74 *render_view_id = 0; 84 *render_view_id = 0;
75 return false; 85 return false;
76 } 86 }
77 87
78 *render_process_id = found->second.process_id; 88 *render_process_id = found->second.process_id;
79 *render_view_id = found->second.view_id; 89 *render_view_id = found->second.view_id;
80 return true; 90 return true;
81 } 91 }
82 92
93 const std::string& BrowserPpapiHostImpl::GetPluginName() {
94 return plugin_name_;
95 }
96
97 const FilePath& BrowserPpapiHostImpl::GetProfileDataDirectory() {
98 return profile_data_directory_;
99 }
100
83 void BrowserPpapiHostImpl::AddInstanceForView(PP_Instance instance, 101 void BrowserPpapiHostImpl::AddInstanceForView(PP_Instance instance,
84 int render_process_id, 102 int render_process_id,
85 int render_view_id) { 103 int render_view_id) {
86 DCHECK(instance_to_view_.find(instance) == instance_to_view_.end()); 104 DCHECK(instance_to_view_.find(instance) == instance_to_view_.end());
87 105
88 RenderViewIDs ids; 106 RenderViewIDs ids;
89 ids.process_id = render_process_id; 107 ids.process_id = render_process_id;
90 ids.view_id = render_view_id; 108 ids.view_id = render_view_id;
91 instance_to_view_[instance] = ids; 109 instance_to_view_[instance] = ids;
92 } 110 }
(...skipping 23 matching lines...) Expand all
116 */ 134 */
117 return ppapi_host_->OnMessageReceived(msg); 135 return ppapi_host_->OnMessageReceived(msg);
118 } 136 }
119 137
120 void BrowserPpapiHostImpl::HostMessageFilter::OnHostDestroyed() { 138 void BrowserPpapiHostImpl::HostMessageFilter::OnHostDestroyed() {
121 DCHECK(ppapi_host_); 139 DCHECK(ppapi_host_);
122 ppapi_host_ = NULL; 140 ppapi_host_ = NULL;
123 } 141 }
124 142
125 } // namespace content 143 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698