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

Side by Side Diff: ipc/ipc_channel_proxy.cc

Issue 1185133006: IPC: Make ChannelReader inherit from SupportsAttachmentBrokering. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from tsepez. Created 5 years, 6 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 | « ipc/ipc_channel_proxy.h ('k') | ipc/ipc_channel_proxy_unittest.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 "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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 if (channel_send_thread_safe_) { 340 if (channel_send_thread_safe_) {
341 SendFromThisThread(message); 341 SendFromThisThread(message);
342 return; 342 return;
343 } 343 }
344 344
345 ipc_task_runner()->PostTask( 345 ipc_task_runner()->PostTask(
346 FROM_HERE, base::Bind(&ChannelProxy::Context::OnSendMessage, this, 346 FROM_HERE, base::Bind(&ChannelProxy::Context::OnSendMessage, this,
347 base::Passed(scoped_ptr<Message>(message)))); 347 base::Passed(scoped_ptr<Message>(message))));
348 } 348 }
349 349
350
351 //----------------------------------------------------------------------------- 350 //-----------------------------------------------------------------------------
352 351
353 // static 352 // static
354 scoped_ptr<ChannelProxy> ChannelProxy::Create( 353 scoped_ptr<ChannelProxy> ChannelProxy::Create(
355 const IPC::ChannelHandle& channel_handle, 354 const IPC::ChannelHandle& channel_handle,
356 Channel::Mode mode, 355 Channel::Mode mode,
357 Listener* listener, 356 Listener* listener,
358 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) { 357 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
358 AttachmentBroker* broker) {
359 scoped_ptr<ChannelProxy> channel(new ChannelProxy(listener, ipc_task_runner)); 359 scoped_ptr<ChannelProxy> channel(new ChannelProxy(listener, ipc_task_runner));
360 channel->Init(channel_handle, mode, true); 360 channel->Init(channel_handle, mode, true, broker);
361 return channel.Pass(); 361 return channel.Pass();
362 } 362 }
363 363
364 // static 364 // static
365 scoped_ptr<ChannelProxy> ChannelProxy::Create( 365 scoped_ptr<ChannelProxy> ChannelProxy::Create(
366 scoped_ptr<ChannelFactory> factory, 366 scoped_ptr<ChannelFactory> factory,
367 Listener* listener, 367 Listener* listener,
368 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) { 368 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner) {
369 scoped_ptr<ChannelProxy> channel(new ChannelProxy(listener, ipc_task_runner)); 369 scoped_ptr<ChannelProxy> channel(new ChannelProxy(listener, ipc_task_runner));
370 channel->Init(factory.Pass(), true); 370 channel->Init(factory.Pass(), true);
(...skipping 18 matching lines...) Expand all
389 } 389 }
390 390
391 ChannelProxy::~ChannelProxy() { 391 ChannelProxy::~ChannelProxy() {
392 DCHECK(CalledOnValidThread()); 392 DCHECK(CalledOnValidThread());
393 393
394 Close(); 394 Close();
395 } 395 }
396 396
397 void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle, 397 void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle,
398 Channel::Mode mode, 398 Channel::Mode mode,
399 bool create_pipe_now) { 399 bool create_pipe_now,
400 AttachmentBroker* broker) {
400 #if defined(OS_POSIX) 401 #if defined(OS_POSIX)
401 // When we are creating a server on POSIX, we need its file descriptor 402 // When we are creating a server on POSIX, we need its file descriptor
402 // to be created immediately so that it can be accessed and passed 403 // to be created immediately so that it can be accessed and passed
403 // to other processes. Forcing it to be created immediately avoids 404 // to other processes. Forcing it to be created immediately avoids
404 // race conditions that may otherwise arise. 405 // race conditions that may otherwise arise.
405 if (mode & Channel::MODE_SERVER_FLAG) { 406 if (mode & Channel::MODE_SERVER_FLAG) {
406 create_pipe_now = true; 407 create_pipe_now = true;
407 } 408 }
408 #endif // defined(OS_POSIX) 409 #endif // defined(OS_POSIX)
409 Init(ChannelFactory::Create(channel_handle, mode), 410 Init(ChannelFactory::Create(channel_handle, mode, broker), create_pipe_now);
410 create_pipe_now);
411 } 411 }
412 412
413 void ChannelProxy::Init(scoped_ptr<ChannelFactory> factory, 413 void ChannelProxy::Init(scoped_ptr<ChannelFactory> factory,
414 bool create_pipe_now) { 414 bool create_pipe_now) {
415 DCHECK(CalledOnValidThread()); 415 DCHECK(CalledOnValidThread());
416 DCHECK(!did_init_); 416 DCHECK(!did_init_);
417 417
418 if (create_pipe_now) { 418 if (create_pipe_now) {
419 // Create the channel immediately. This effectively sets up the 419 // Create the channel immediately. This effectively sets up the
420 // low-level pipe so that the client can connect. Without creating 420 // low-level pipe so that the client can connect. Without creating
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 Channel* channel = context_.get()->channel_.get(); 515 Channel* channel = context_.get()->channel_.get();
516 // Channel must have been created first. 516 // Channel must have been created first.
517 DCHECK(channel) << context_.get()->channel_id_; 517 DCHECK(channel) << context_.get()->channel_id_;
518 return channel->TakeClientFileDescriptor(); 518 return channel->TakeClientFileDescriptor();
519 } 519 }
520 #endif 520 #endif
521 521
522 //----------------------------------------------------------------------------- 522 //-----------------------------------------------------------------------------
523 523
524 } // namespace IPC 524 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_channel_proxy.h ('k') | ipc/ipc_channel_proxy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698