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

Side by Side Diff: content/plugin/plugin_channel.cc

Issue 1292263003: ipc: Use a global for the process's attachment broker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ipc_message2
Patch Set: Comments from avi. Created 5 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
« no previous file with comments | « content/plugin/plugin_channel.h ('k') | content/plugin/plugin_thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/plugin/plugin_channel.h" 5 #include "content/plugin/plugin_channel.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/process/process_handle.h" 9 #include "base/process/process_handle.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 }; 134 };
135 typedef std::map<int, WaitableEventWrapper> ModalDialogEventMap; 135 typedef std::map<int, WaitableEventWrapper> ModalDialogEventMap;
136 ModalDialogEventMap modal_dialog_event_map_; 136 ModalDialogEventMap modal_dialog_event_map_;
137 base::Lock modal_dialog_event_map_lock_; 137 base::Lock modal_dialog_event_map_lock_;
138 138
139 IPC::Sender* sender_; 139 IPC::Sender* sender_;
140 }; 140 };
141 141
142 PluginChannel* PluginChannel::GetPluginChannel( 142 PluginChannel* PluginChannel::GetPluginChannel(
143 int renderer_id, 143 int renderer_id,
144 base::SingleThreadTaskRunner* ipc_task_runner, 144 base::SingleThreadTaskRunner* ipc_task_runner) {
145 IPC::AttachmentBroker* broker) {
146 // Map renderer ID to a (single) channel to that process. 145 // Map renderer ID to a (single) channel to that process.
147 std::string channel_key = base::StringPrintf( 146 std::string channel_key = base::StringPrintf(
148 "%d.r%d", base::GetCurrentProcId(), renderer_id); 147 "%d.r%d", base::GetCurrentProcId(), renderer_id);
149 148
150 PluginChannel* channel = 149 PluginChannel* channel =
151 static_cast<PluginChannel*>(NPChannelBase::GetChannel( 150 static_cast<PluginChannel*>(NPChannelBase::GetChannel(
152 channel_key, IPC::Channel::MODE_SERVER, ClassFactory, ipc_task_runner, 151 channel_key, IPC::Channel::MODE_SERVER, ClassFactory, ipc_task_runner,
153 false, ChildProcess::current()->GetShutDownEvent(), broker)); 152 false, ChildProcess::current()->GetShutDownEvent()));
154 153
155 if (channel) 154 if (channel)
156 channel->renderer_id_ = renderer_id; 155 channel->renderer_id_ = renderer_id;
157 156
158 return channel; 157 return channel;
159 } 158 }
160 159
161 // static 160 // static
162 void PluginChannel::NotifyRenderersOfPendingShutdown() { 161 void PluginChannel::NotifyRenderersOfPendingShutdown() {
163 Broadcast(new PluginHostMsg_PluginShuttingDown()); 162 Broadcast(new PluginHostMsg_PluginShuttingDown());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 while (!plugin_stubs_.empty()) { 218 while (!plugin_stubs_.empty()) {
220 // Separate vector::erase and ~WebPluginDelegateStub. 219 // Separate vector::erase and ~WebPluginDelegateStub.
221 // See https://code.google.com/p/chromium/issues/detail?id=314088 220 // See https://code.google.com/p/chromium/issues/detail?id=314088
222 scoped_refptr<WebPluginDelegateStub> stub = plugin_stubs_[0]; 221 scoped_refptr<WebPluginDelegateStub> stub = plugin_stubs_[0];
223 plugin_stubs_.erase(plugin_stubs_.begin()); 222 plugin_stubs_.erase(plugin_stubs_.begin());
224 } 223 }
225 } 224 }
226 225
227 bool PluginChannel::Init(base::SingleThreadTaskRunner* ipc_task_runner, 226 bool PluginChannel::Init(base::SingleThreadTaskRunner* ipc_task_runner,
228 bool create_pipe_now, 227 bool create_pipe_now,
229 base::WaitableEvent* shutdown_event, 228 base::WaitableEvent* shutdown_event) {
230 IPC::AttachmentBroker* broker) { 229 if (!NPChannelBase::Init(ipc_task_runner, create_pipe_now, shutdown_event))
231 if (!NPChannelBase::Init(ipc_task_runner, create_pipe_now, shutdown_event,
232 broker)) {
233 return false; 230 return false;
234 }
235 231
236 channel_->AddFilter(filter_.get()); 232 channel_->AddFilter(filter_.get());
237 return true; 233 return true;
238 } 234 }
239 235
240 PluginChannel::PluginChannel() 236 PluginChannel::PluginChannel()
241 : renderer_id_(-1), 237 : renderer_id_(-1),
242 in_send_(0), 238 in_send_(0),
243 incognito_(false), 239 incognito_(false),
244 filter_(new MessageFilter()), 240 filter_(new MessageFilter()),
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 void PluginChannel::OnDidAbortLoading(int render_view_id) { 335 void PluginChannel::OnDidAbortLoading(int render_view_id) {
340 for (size_t i = 0; i < plugin_stubs_.size(); ++i) { 336 for (size_t i = 0; i < plugin_stubs_.size(); ++i) {
341 if (plugin_stubs_[i]->webplugin()->host_render_view_routing_id() == 337 if (plugin_stubs_[i]->webplugin()->host_render_view_routing_id() ==
342 render_view_id) { 338 render_view_id) {
343 plugin_stubs_[i]->delegate()->instance()->CloseStreams(); 339 plugin_stubs_[i]->delegate()->instance()->CloseStreams();
344 } 340 }
345 } 341 }
346 } 342 }
347 343
348 } // namespace content 344 } // namespace content
OLDNEW
« no previous file with comments | « content/plugin/plugin_channel.h ('k') | content/plugin/plugin_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698