OLD | NEW |
---|---|
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 "ipc/ipc_channel_proxy.h" | 5 #include "ipc/ipc_channel_proxy.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 scoped_ptr<ChannelProxy> ChannelProxy::Create( | 328 scoped_ptr<ChannelProxy> ChannelProxy::Create( |
329 scoped_ptr<ChannelFactory> factory, | 329 scoped_ptr<ChannelFactory> factory, |
330 Listener* listener, | 330 Listener* listener, |
331 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) { | 331 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) { |
332 scoped_ptr<ChannelProxy> channel(new ChannelProxy(listener, ipc_task_runner)); | 332 scoped_ptr<ChannelProxy> channel(new ChannelProxy(listener, ipc_task_runner)); |
333 channel->Init(factory.Pass(), true); | 333 channel->Init(factory.Pass(), true); |
334 return channel.Pass(); | 334 return channel.Pass(); |
335 } | 335 } |
336 | 336 |
337 ChannelProxy::ChannelProxy(Context* context) | 337 ChannelProxy::ChannelProxy(Context* context) |
338 : context_(context), | 338 : context_(context), did_init_(false), outgoing_message_filter_(NULL) { |
inferno
2015/03/05 18:46:48
each var on its own line.
inferno
2015/03/05 18:46:48
why not put this var inside ifdef, regular builds
| |
339 did_init_(false) { | |
340 } | 339 } |
341 | 340 |
342 ChannelProxy::ChannelProxy( | 341 ChannelProxy::ChannelProxy( |
343 Listener* listener, | 342 Listener* listener, |
344 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) | 343 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) |
345 : context_(new Context(listener, ipc_task_runner)), did_init_(false) { | 344 : context_(new Context(listener, ipc_task_runner)), |
345 did_init_(false), | |
346 outgoing_message_filter_(NULL) { | |
346 } | 347 } |
347 | 348 |
348 ChannelProxy::~ChannelProxy() { | 349 ChannelProxy::~ChannelProxy() { |
349 DCHECK(CalledOnValidThread()); | 350 DCHECK(CalledOnValidThread()); |
350 | 351 |
351 Close(); | 352 Close(); |
352 } | 353 } |
353 | 354 |
354 void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle, | 355 void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle, |
355 Channel::Mode mode, | 356 Channel::Mode mode, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
404 FROM_HERE, base::Bind(&Context::OnChannelClosed, context_.get())); | 405 FROM_HERE, base::Bind(&Context::OnChannelClosed, context_.get())); |
405 } | 406 } |
406 } | 407 } |
407 | 408 |
408 bool ChannelProxy::Send(Message* message) { | 409 bool ChannelProxy::Send(Message* message) { |
409 DCHECK(did_init_); | 410 DCHECK(did_init_); |
410 | 411 |
411 // TODO(alexeypa): add DCHECK(CalledOnValidThread()) here. Currently there are | 412 // TODO(alexeypa): add DCHECK(CalledOnValidThread()) here. Currently there are |
412 // tests that call Send() from a wrong thread. See http://crbug.com/163523. | 413 // tests that call Send() from a wrong thread. See http://crbug.com/163523. |
413 | 414 |
415 if (outgoing_message_filter()) | |
inferno
2015/03/05 18:46:47
Please add a comment explaining what its purpose i
| |
416 message = outgoing_message_filter()->Rewrite(message); | |
417 | |
414 #ifdef IPC_MESSAGE_LOG_ENABLED | 418 #ifdef IPC_MESSAGE_LOG_ENABLED |
415 Logging::GetInstance()->OnSendMessage(message, context_->channel_id()); | 419 Logging::GetInstance()->OnSendMessage(message, context_->channel_id()); |
416 #endif | 420 #endif |
417 | 421 |
418 context_->ipc_task_runner()->PostTask( | 422 context_->ipc_task_runner()->PostTask( |
419 FROM_HERE, | 423 FROM_HERE, |
420 base::Bind(&ChannelProxy::Context::OnSendMessage, | 424 base::Bind(&ChannelProxy::Context::OnSendMessage, |
421 context_, base::Passed(scoped_ptr<Message>(message)))); | 425 context_, base::Passed(scoped_ptr<Message>(message)))); |
422 return true; | 426 return true; |
423 } | 427 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
467 Channel* channel = context_.get()->channel_.get(); | 471 Channel* channel = context_.get()->channel_.get(); |
468 // Channel must have been created first. | 472 // Channel must have been created first. |
469 DCHECK(channel) << context_.get()->channel_id_; | 473 DCHECK(channel) << context_.get()->channel_id_; |
470 return channel->TakeClientFileDescriptor(); | 474 return channel->TakeClientFileDescriptor(); |
471 } | 475 } |
472 #endif | 476 #endif |
473 | 477 |
474 //----------------------------------------------------------------------------- | 478 //----------------------------------------------------------------------------- |
475 | 479 |
476 } // namespace IPC | 480 } // namespace IPC |
OLD | NEW |