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

Side by Side Diff: mojo/system/platform_channel.cc

Issue 103113002: Mojo: (POSIX) Pass channel handle to child. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years 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 | « mojo/mojo.gyp ('k') | mojo/system/platform_channel_handle.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "mojo/system/platform_channel.h" 5 #include "mojo/system/platform_channel.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace mojo { 9 namespace mojo {
10 namespace system { 10 namespace system {
11 11
12 PlatformChannel::~PlatformChannel() { 12 PlatformChannel::~PlatformChannel() {
13 // Implementations must close the handle if necessary (e.g., if no one else 13 handle_.CloseIfNecessary();
14 // has taken ownership).
15 DCHECK(!is_valid());
16 } 14 }
17 15
18 PlatformChannelHandle PlatformChannel::PassHandle() { 16 PlatformChannelHandle PlatformChannel::PassHandle() {
19 DCHECK(is_valid()); 17 DCHECK(is_valid());
20 PlatformChannelHandle rv = handle_; 18 PlatformChannelHandle rv = handle_;
21 handle_ = PlatformChannelHandle(); 19 handle_ = PlatformChannelHandle();
22 return rv; 20 return rv;
23 } 21 }
24 22
25 PlatformChannel::PlatformChannel() { 23 PlatformChannel::PlatformChannel() {
26 } 24 }
27 25
28 PlatformServerChannel::PlatformServerChannel(const std::string& name) 26 PlatformServerChannel::PlatformServerChannel(const std::string& name)
29 : name_(name) { 27 : name_(name) {
30 DCHECK(!name_.empty()); 28 DCHECK(!name_.empty());
31 } 29 }
32 30
33 // Static factory method. 31 // Static factory method.
34 // static 32 // static
35 scoped_ptr<PlatformClientChannel> PlatformClientChannel::CreateFromHandle( 33 scoped_ptr<PlatformClientChannel> PlatformClientChannel::CreateFromHandle(
36 const PlatformChannelHandle& handle) { 34 const PlatformChannelHandle& handle) {
35 DCHECK(handle.is_valid());
37 scoped_ptr<PlatformClientChannel> rv(new PlatformClientChannel()); 36 scoped_ptr<PlatformClientChannel> rv(new PlatformClientChannel());
38 *rv->mutable_handle() = handle; 37 *rv->mutable_handle() = handle;
39 return rv.Pass(); 38 return rv.Pass();
40 } 39 }
41 40
42 } // namespace system 41 } // namespace system
43 } // namespace mojo 42 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/mojo.gyp ('k') | mojo/system/platform_channel_handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698