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

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 NOTREACHED() << "Renderer sent a bad plugin process host ID";
117 }
118
119 // static
120 void PpapiPluginProcessHost::DidDeleteOutOfProcessInstance(
121 int plugin_process_id,
122 int32 pp_instance) {
123 for (PpapiPluginProcessHostIterator iter; !iter.Done(); ++iter) {
124 if (iter->process_.get() &&
125 iter->process_->GetData().id == plugin_process_id) {
126 // Found the plugin.
127 iter->host_impl_->DeleteInstanceForView(pp_instance);
128 return;
129 }
130 }
131 // Note: It's possible that the plugin process has already been deleted by
132 // the time this message is received. For example, it could have crashed.
133 // That's OK, we can just ignore this message.
134 }
135
99 bool PpapiPluginProcessHost::Send(IPC::Message* message) { 136 bool PpapiPluginProcessHost::Send(IPC::Message* message) {
100 return process_->Send(message); 137 return process_->Send(message);
101 } 138 }
102 139
103 void PpapiPluginProcessHost::OpenChannelToPlugin(Client* client) { 140 void PpapiPluginProcessHost::OpenChannelToPlugin(Client* client) {
104 if (process_->GetHost()->IsChannelOpening()) { 141 if (process_->GetHost()->IsChannelOpening()) {
105 // The channel is already in the process of being opened. Put 142 // The channel is already in the process of being opened. Put
106 // this "open channel" request into a queue of requests that will 143 // this "open channel" request into a queue of requests that will
107 // be run once the channel is open. 144 // be run once the channel is open.
108 pending_requests_.push_back(client); 145 pending_requests_.push_back(client);
(...skipping 19 matching lines...) Expand all
128 165
129 ppapi::PpapiPermissions permissions(info.permissions); 166 ppapi::PpapiPermissions permissions(info.permissions);
130 host_impl_ = new content::BrowserPpapiHostImpl(this, permissions); 167 host_impl_ = new content::BrowserPpapiHostImpl(this, permissions);
131 168
132 file_filter_ = new PepperTrustedFileMessageFilter( 169 file_filter_ = new PepperTrustedFileMessageFilter(
133 process_->GetData().id, info.name, profile_data_directory); 170 process_->GetData().id, info.name, profile_data_directory);
134 171
135 process_->GetHost()->AddFilter(filter_.get()); 172 process_->GetHost()->AddFilter(filter_.get());
136 process_->GetHost()->AddFilter(file_filter_.get()); 173 process_->GetHost()->AddFilter(file_filter_.get());
137 process_->GetHost()->AddFilter(host_impl_.get()); 174 process_->GetHost()->AddFilter(host_impl_.get());
175
176 content::GetContentClient()->browser()->DidCreatePpapiPlugin(host_impl_);
138 } 177 }
139 178
140 PpapiPluginProcessHost::PpapiPluginProcessHost() 179 PpapiPluginProcessHost::PpapiPluginProcessHost()
141 : is_broker_(true) { 180 : is_broker_(true) {
142 process_.reset(new BrowserChildProcessHostImpl( 181 process_.reset(new BrowserChildProcessHostImpl(
143 content::PROCESS_TYPE_PPAPI_BROKER, this)); 182 content::PROCESS_TYPE_PPAPI_BROKER, this));
144 183
145 ppapi::PpapiPermissions permissions; // No permissions. 184 ppapi::PpapiPermissions permissions; // No permissions.
146 host_impl_ = new content::BrowserPpapiHostImpl(this, permissions); 185 host_impl_ = new content::BrowserPpapiHostImpl(this, permissions);
147 } 186 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 if (sent_requests_.empty()) 344 if (sent_requests_.empty())
306 return; 345 return;
307 346
308 // All requests should be processed FIFO, so the next item in the 347 // 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. 348 // sent_requests_ queue should be the one that the plugin just created.
310 Client* client = sent_requests_.front(); 349 Client* client = sent_requests_.front();
311 sent_requests_.pop(); 350 sent_requests_.pop();
312 351
313 client->OnPpapiChannelOpened(channel_handle, process_->GetData().id); 352 client->OnPpapiChannelOpened(channel_handle, process_->GetData().id);
314 } 353 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698