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

Side by Side Diff: ipc/ipc_channel_proxy.cc

Issue 3654001: Revert 61899 for breaking cookes on file:// URLs.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « chrome/service/service_process.cc ('k') | media/base/pipeline_impl.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/ref_counted.h" 6 #include "base/ref_counted.h"
7 #include "base/scoped_ptr.h" 7 #include "base/scoped_ptr.h"
8 #include "base/thread.h" 8 #include "base/thread.h"
9 #include "ipc/ipc_channel_proxy.h" 9 #include "ipc/ipc_channel_proxy.h"
10 #include "ipc/ipc_logging.h" 10 #include "ipc/ipc_logging.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 189 }
190 190
191 // Called on the IPC::Channel thread 191 // Called on the IPC::Channel thread
192 void ChannelProxy::Context::OnAddFilter(MessageFilter* filter) { 192 void ChannelProxy::Context::OnAddFilter(MessageFilter* filter) {
193 filters_.push_back(filter); 193 filters_.push_back(filter);
194 194
195 // If the channel has already been created, then we need to send this message 195 // If the channel has already been created, then we need to send this message
196 // so that the filter gets access to the Channel. 196 // so that the filter gets access to the Channel.
197 if (channel_) 197 if (channel_)
198 filter->OnFilterAdded(channel_); 198 filter->OnFilterAdded(channel_);
199
200 // Balances the AddRef in ChannelProxy::AddFilter.
201 filter->Release();
199 } 202 }
200 203
201 // Called on the IPC::Channel thread 204 // Called on the IPC::Channel thread
202 void ChannelProxy::Context::OnRemoveFilter(MessageFilter* filter) { 205 void ChannelProxy::Context::OnRemoveFilter(MessageFilter* filter) {
203 for (size_t i = 0; i < filters_.size(); ++i) { 206 for (size_t i = 0; i < filters_.size(); ++i) {
204 if (filters_[i].get() == filter) { 207 if (filters_[i].get() == filter) {
205 filter->OnFilterRemoved(); 208 filter->OnFilterRemoved();
206 filters_.erase(filters_.begin() + i); 209 filters_.erase(filters_.begin() + i);
207 return; 210 return;
208 } 211 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 #ifdef IPC_MESSAGE_LOG_ENABLED 310 #ifdef IPC_MESSAGE_LOG_ENABLED
308 Logging::current()->OnSendMessage(message, context_->channel_id()); 311 Logging::current()->OnSendMessage(message, context_->channel_id());
309 #endif 312 #endif
310 313
311 context_->ipc_message_loop()->PostTask(FROM_HERE, 314 context_->ipc_message_loop()->PostTask(FROM_HERE,
312 new SendTask(context_.get(), message)); 315 new SendTask(context_.get(), message));
313 return true; 316 return true;
314 } 317 }
315 318
316 void ChannelProxy::AddFilter(MessageFilter* filter) { 319 void ChannelProxy::AddFilter(MessageFilter* filter) {
317 context_->ipc_message_loop()->PostTask( 320 // We want to addref the filter to prevent it from
318 FROM_HERE, 321 // being destroyed before the OnAddFilter call is invoked.
319 NewRunnableMethod( 322 filter->AddRef();
320 context_.get(), 323 context_->ipc_message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
321 &Context::OnAddFilter, 324 context_.get(), &Context::OnAddFilter, filter));
322 make_scoped_refptr(filter)));
323 } 325 }
324 326
325 void ChannelProxy::RemoveFilter(MessageFilter* filter) { 327 void ChannelProxy::RemoveFilter(MessageFilter* filter) {
326 context_->ipc_message_loop()->PostTask( 328 context_->ipc_message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
327 FROM_HERE, NewRunnableMethod( 329 context_.get(), &Context::OnRemoveFilter, filter));
328 context_.get(),
329 &Context::OnRemoveFilter,
330 make_scoped_refptr(filter)));
331 } 330 }
332 331
333 void ChannelProxy::ClearIPCMessageLoop() { 332 void ChannelProxy::ClearIPCMessageLoop() {
334 context()->ClearIPCMessageLoop(); 333 context()->ClearIPCMessageLoop();
335 } 334 }
336 335
337 #if defined(OS_POSIX) 336 #if defined(OS_POSIX)
338 // See the TODO regarding lazy initialization of the channel in 337 // See the TODO regarding lazy initialization of the channel in
339 // ChannelProxy::Init(). 338 // ChannelProxy::Init().
340 // We assume that IPC::Channel::GetClientFileDescriptorMapping() is thread-safe. 339 // We assume that IPC::Channel::GetClientFileDescriptorMapping() is thread-safe.
341 int ChannelProxy::GetClientFileDescriptor() const { 340 int ChannelProxy::GetClientFileDescriptor() const {
342 Channel *channel = context_.get()->channel_; 341 Channel *channel = context_.get()->channel_;
343 DCHECK(channel); // Channel must have been created first. 342 DCHECK(channel); // Channel must have been created first.
344 return channel->GetClientFileDescriptor(); 343 return channel->GetClientFileDescriptor();
345 } 344 }
346 #endif 345 #endif
347 346
348 //----------------------------------------------------------------------------- 347 //-----------------------------------------------------------------------------
349 348
350 } // namespace IPC 349 } // namespace IPC
OLDNEW
« no previous file with comments | « chrome/service/service_process.cc ('k') | media/base/pipeline_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698