OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_pair.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "mojo/system/platform_channel.h" |
8 | 9 |
9 namespace mojo { | 10 namespace mojo { |
10 namespace system { | 11 namespace system { |
11 | 12 |
12 PlatformChannel::~PlatformChannel() { | |
13 handle_.CloseIfNecessary(); | |
14 } | |
15 | |
16 // static | |
17 scoped_ptr<PlatformChannel> PlatformChannel::CreateFromHandle( | |
18 const PlatformChannelHandle& handle) { | |
19 DCHECK(handle.is_valid()); | |
20 scoped_ptr<PlatformChannel> rv(new PlatformChannel()); | |
21 *rv->mutable_handle() = handle; | |
22 return rv.Pass(); | |
23 } | |
24 | |
25 PlatformChannelHandle PlatformChannel::PassHandle() { | |
26 DCHECK(is_valid()); | |
27 PlatformChannelHandle rv = handle_; | |
28 handle_ = PlatformChannelHandle(); | |
29 return rv; | |
30 } | |
31 | |
32 PlatformChannel::PlatformChannel() { | |
33 } | |
34 | |
35 // ----------------------------------------------------------------------------- | |
36 | |
37 PlatformChannelPair::~PlatformChannelPair() { | 13 PlatformChannelPair::~PlatformChannelPair() { |
38 server_handle_.CloseIfNecessary(); | 14 server_handle_.CloseIfNecessary(); |
39 client_handle_.CloseIfNecessary(); | 15 client_handle_.CloseIfNecessary(); |
40 } | 16 } |
41 | 17 |
42 scoped_ptr<PlatformChannel> PlatformChannelPair::CreateServerChannel() { | 18 scoped_ptr<PlatformChannel> PlatformChannelPair::CreateServerChannel() { |
43 if (!server_handle_.is_valid()) { | 19 if (!server_handle_.is_valid()) { |
44 LOG(WARNING) << "Server handle invalid"; | 20 LOG(WARNING) << "Server handle invalid"; |
45 return scoped_ptr<PlatformChannel>(); | 21 return scoped_ptr<PlatformChannel>(); |
46 } | 22 } |
(...skipping 11 matching lines...) Expand all Loading... |
58 } | 34 } |
59 | 35 |
60 scoped_ptr<PlatformChannel> rv = | 36 scoped_ptr<PlatformChannel> rv = |
61 PlatformChannel::CreateFromHandle(client_handle_); | 37 PlatformChannel::CreateFromHandle(client_handle_); |
62 client_handle_ = PlatformChannelHandle(); | 38 client_handle_ = PlatformChannelHandle(); |
63 return rv.Pass(); | 39 return rv.Pass(); |
64 } | 40 } |
65 | 41 |
66 } // namespace system | 42 } // namespace system |
67 } // namespace mojo | 43 } // namespace mojo |
OLD | NEW |