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

Side by Side Diff: ipc/ipc_channel_proxy.cc

Issue 310853003: Add IPC::ChannelProxy::Create() and IPC::SyncChannel::Create() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 } 297 }
298 298
299 // Called on the listener's thread 299 // Called on the listener's thread
300 void ChannelProxy::Context::OnDispatchBadMessage(const Message& message) { 300 void ChannelProxy::Context::OnDispatchBadMessage(const Message& message) {
301 if (listener_) 301 if (listener_)
302 listener_->OnBadMessageReceived(message); 302 listener_->OnBadMessageReceived(message);
303 } 303 }
304 304
305 //----------------------------------------------------------------------------- 305 //-----------------------------------------------------------------------------
306 306
307 ChannelProxy::ChannelProxy(const IPC::ChannelHandle& channel_handle, 307 // static
308 Channel::Mode mode, 308 scoped_ptr<ChannelProxy> ChannelProxy::Create(
309 Listener* listener, 309 Listener* listener,
310 base::SingleThreadTaskRunner* ipc_task_runner) 310 base::SingleThreadTaskRunner* ipc_task_runner) {
311 : context_(new Context(listener, ipc_task_runner)), 311 return make_scoped_ptr(new ChannelProxy(listener, ipc_task_runner));
312 did_init_(false) { 312 }
313 Init(channel_handle, mode, true); 313
314 // static
315 scoped_ptr<ChannelProxy> ChannelProxy::Create(
316 const IPC::ChannelHandle& channel_handle,
317 Channel::Mode mode,
318 Listener* listener,
319 base::SingleThreadTaskRunner* ipc_task_runner) {
320 scoped_ptr<ChannelProxy> channel = Create(listener, ipc_task_runner);
321 channel->Init(channel_handle, mode, true);
322 return channel.Pass();
314 } 323 }
315 324
316 ChannelProxy::ChannelProxy(Context* context) 325 ChannelProxy::ChannelProxy(Context* context)
317 : context_(context), 326 : context_(context),
318 did_init_(false) { 327 did_init_(false) {
319 } 328 }
320 329
330 ChannelProxy::ChannelProxy(Listener* listener,
331 base::SingleThreadTaskRunner* ipc_task_runner)
332 : context_(new Context(listener, ipc_task_runner)), did_init_(false) {
333 }
334
321 ChannelProxy::~ChannelProxy() { 335 ChannelProxy::~ChannelProxy() {
322 DCHECK(CalledOnValidThread()); 336 DCHECK(CalledOnValidThread());
323 337
324 Close(); 338 Close();
325 } 339 }
326 340
327 void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle, 341 void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle,
328 Channel::Mode mode, 342 Channel::Mode mode,
329 bool create_pipe_now) { 343 bool create_pipe_now) {
330 DCHECK(CalledOnValidThread()); 344 DCHECK(CalledOnValidThread());
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 Channel* channel = context_.get()->channel_.get(); 450 Channel* channel = context_.get()->channel_.get();
437 // Channel must have been created first. 451 // Channel must have been created first.
438 DCHECK(channel) << context_.get()->channel_id_; 452 DCHECK(channel) << context_.get()->channel_id_;
439 return channel->GetPeerEuid(peer_euid); 453 return channel->GetPeerEuid(peer_euid);
440 } 454 }
441 #endif 455 #endif
442 456
443 //----------------------------------------------------------------------------- 457 //-----------------------------------------------------------------------------
444 458
445 } // namespace IPC 459 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698