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

Side by Side Diff: content/browser/ppapi_plugin_process_host.cc

Issue 10909138: Convert the async device ID getter to a chrome resource host (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 3 months 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
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/ppapi_plugin_process_host.h" 5 #include "content/browser/ppapi_plugin_process_host.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 private: 65 private:
66 PpapiPluginProcessHost* const process_host_; 66 PpapiPluginProcessHost* const process_host_;
67 }; 67 };
68 68
69 PpapiPluginProcessHost::~PpapiPluginProcessHost() { 69 PpapiPluginProcessHost::~PpapiPluginProcessHost() {
70 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "") 70 DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "")
71 << "~PpapiPluginProcessHost()"; 71 << "~PpapiPluginProcessHost()";
72 CancelRequests(); 72 CancelRequests();
73 } 73 }
74 74
75 // static
75 PpapiPluginProcessHost* PpapiPluginProcessHost::CreatePluginHost( 76 PpapiPluginProcessHost* PpapiPluginProcessHost::CreatePluginHost(
76 const content::PepperPluginInfo& info, 77 const content::PepperPluginInfo& info,
77 const FilePath& profile_data_directory, 78 const FilePath& profile_data_directory,
78 net::HostResolver* host_resolver) { 79 net::HostResolver* host_resolver) {
79 PpapiPluginProcessHost* plugin_host = new PpapiPluginProcessHost( 80 PpapiPluginProcessHost* plugin_host = new PpapiPluginProcessHost(
80 info, profile_data_directory, host_resolver); 81 info, profile_data_directory, host_resolver);
81 if (plugin_host->Init(info)) 82 if (plugin_host->Init(info))
82 return plugin_host; 83 return plugin_host;
83 84
84 NOTREACHED(); // Init is not expected to fail. 85 NOTREACHED(); // Init is not expected to fail.
85 return NULL; 86 return NULL;
86 } 87 }
87 88
89 // static
88 PpapiPluginProcessHost* PpapiPluginProcessHost::CreateBrokerHost( 90 PpapiPluginProcessHost* PpapiPluginProcessHost::CreateBrokerHost(
89 const content::PepperPluginInfo& info) { 91 const content::PepperPluginInfo& info) {
90 PpapiPluginProcessHost* plugin_host = 92 PpapiPluginProcessHost* plugin_host =
91 new PpapiPluginProcessHost(); 93 new PpapiPluginProcessHost();
92 if (plugin_host->Init(info)) 94 if (plugin_host->Init(info))
93 return plugin_host; 95 return plugin_host;
94 96
95 NOTREACHED(); // Init is not expected to fail. 97 NOTREACHED(); // Init is not expected to fail.
96 return NULL; 98 return NULL;
97 } 99 }
98 100
101 // static
102 void PpapiPluginProcessHost::DidCreateOutOfProcessInstance(
103 int plugin_process_id,
104 int32 pp_instance,
105 int render_process_id,
106 int render_view_id) {
107 for (PpapiPluginProcessHostIterator iter; !iter.Done(); ++iter) {
108 if (iter->process_.get() &&
109 iter->process_->GetData().id == plugin_process_id) {
110 // Found the plugin.
111 iter->host_impl_->AddInstanceForView(pp_instance,
112 render_process_id, render_view_id);
113 return;
114 }
115 }
116 // We'll see this passed with a 0 process ID for the browser tag stuff that
117 // is currently in the process of being removed.
118 //
119 // TODO(brettw) When old browser tag impl is removed
120 // (PepperPluginDelegateImpl::CreateBrowserPluginModule passes a 0 plugin
121 // process ID) this should be converted to a NOTREACHED().
122 DCHECK(plugin_process_id == 0)
123 << "Renderer sent a bad plugin process host ID";
124 }
125
126 // static
127 void PpapiPluginProcessHost::DidDeleteOutOfProcessInstance(
128 int plugin_process_id,
129 int32 pp_instance) {
130 for (PpapiPluginProcessHostIterator iter; !iter.Done(); ++iter) {
131 if (iter->process_.get() &&
132 iter->process_->GetData().id == plugin_process_id) {
133 // Found the plugin.
134 iter->host_impl_->DeleteInstanceForView(pp_instance);
135 return;
136 }
137 }
138 // Note: It's possible that the plugin process has already been deleted by
139 // the time this message is received. For example, it could have crashed.
140 // That's OK, we can just ignore this message.
141 }
142
99 bool PpapiPluginProcessHost::Send(IPC::Message* message) { 143 bool PpapiPluginProcessHost::Send(IPC::Message* message) {
100 return process_->Send(message); 144 return process_->Send(message);
101 } 145 }
102 146
103 void PpapiPluginProcessHost::OpenChannelToPlugin(Client* client) { 147 void PpapiPluginProcessHost::OpenChannelToPlugin(Client* client) {
104 if (process_->GetHost()->IsChannelOpening()) { 148 if (process_->GetHost()->IsChannelOpening()) {
105 // The channel is already in the process of being opened. Put 149 // The channel is already in the process of being opened. Put
106 // this "open channel" request into a queue of requests that will 150 // this "open channel" request into a queue of requests that will
107 // be run once the channel is open. 151 // be run once the channel is open.
108 pending_requests_.push_back(client); 152 pending_requests_.push_back(client);
(...skipping 19 matching lines...) Expand all
128 172
129 ppapi::PpapiPermissions permissions(info.permissions); 173 ppapi::PpapiPermissions permissions(info.permissions);
130 host_impl_ = new content::BrowserPpapiHostImpl(this, permissions); 174 host_impl_ = new content::BrowserPpapiHostImpl(this, permissions);
131 175
132 file_filter_ = new PepperTrustedFileMessageFilter( 176 file_filter_ = new PepperTrustedFileMessageFilter(
133 process_->GetData().id, info.name, profile_data_directory); 177 process_->GetData().id, info.name, profile_data_directory);
134 178
135 process_->GetHost()->AddFilter(filter_.get()); 179 process_->GetHost()->AddFilter(filter_.get());
136 process_->GetHost()->AddFilter(file_filter_.get()); 180 process_->GetHost()->AddFilter(file_filter_.get());
137 process_->GetHost()->AddFilter(host_impl_.get()); 181 process_->GetHost()->AddFilter(host_impl_.get());
182
183 content::GetContentClient()->browser()->DidCreatePpapiPlugin(host_impl_);
138 } 184 }
139 185
140 PpapiPluginProcessHost::PpapiPluginProcessHost() 186 PpapiPluginProcessHost::PpapiPluginProcessHost()
141 : is_broker_(true) { 187 : is_broker_(true) {
142 process_.reset(new BrowserChildProcessHostImpl( 188 process_.reset(new BrowserChildProcessHostImpl(
143 content::PROCESS_TYPE_PPAPI_BROKER, this)); 189 content::PROCESS_TYPE_PPAPI_BROKER, this));
144 190
145 ppapi::PpapiPermissions permissions; // No permissions. 191 ppapi::PpapiPermissions permissions; // No permissions.
146 host_impl_ = new content::BrowserPpapiHostImpl(this, permissions); 192 host_impl_ = new content::BrowserPpapiHostImpl(this, permissions);
147 } 193 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 if (sent_requests_.empty()) 351 if (sent_requests_.empty())
306 return; 352 return;
307 353
308 // All requests should be processed FIFO, so the next item in the 354 // All requests should be processed FIFO, so the next item in the
309 // sent_requests_ queue should be the one that the plugin just created. 355 // sent_requests_ queue should be the one that the plugin just created.
310 Client* client = sent_requests_.front(); 356 Client* client = sent_requests_.front();
311 sent_requests_.pop(); 357 sent_requests_.pop();
312 358
313 client->OnPpapiChannelOpened(channel_handle, process_->GetData().id); 359 client->OnPpapiChannelOpened(channel_handle, process_->GetData().id);
314 } 360 }
OLDNEW
« no previous file with comments | « content/browser/ppapi_plugin_process_host.h ('k') | content/browser/renderer_host/pepper/browser_ppapi_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698