OLD | NEW |
1 // Copyright 2014 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_pair.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" | |
9 | 8 |
10 namespace mojo { | 9 namespace mojo { |
11 namespace system { | 10 namespace system { |
12 | 11 |
13 PlatformChannelPair::~PlatformChannelPair() { | 12 PlatformChannelPair::~PlatformChannelPair() { |
14 server_handle_.CloseIfNecessary(); | |
15 client_handle_.CloseIfNecessary(); | |
16 } | 13 } |
17 | 14 |
18 scoped_ptr<PlatformChannel> PlatformChannelPair::CreateServerChannel() { | 15 ScopedPlatformHandle PlatformChannelPair::PassServerHandle() { |
19 if (!server_handle_.is_valid()) { | 16 return server_handle_.Pass(); |
20 LOG(WARNING) << "Server handle invalid"; | |
21 return scoped_ptr<PlatformChannel>(); | |
22 } | |
23 | |
24 scoped_ptr<PlatformChannel> rv = | |
25 PlatformChannel::CreateFromHandle(server_handle_); | |
26 server_handle_ = PlatformChannelHandle(); | |
27 return rv.Pass(); | |
28 } | 17 } |
29 | 18 |
30 scoped_ptr<PlatformChannel> PlatformChannelPair::CreateClientChannel() { | 19 ScopedPlatformHandle PlatformChannelPair::PassClientHandle() { |
31 if (!client_handle_.is_valid()) { | 20 return client_handle_.Pass(); |
32 LOG(WARNING) << "Client handle invalid"; | |
33 return scoped_ptr<PlatformChannel>(); | |
34 } | |
35 | |
36 scoped_ptr<PlatformChannel> rv = | |
37 PlatformChannel::CreateFromHandle(client_handle_); | |
38 client_handle_ = PlatformChannelHandle(); | |
39 return rv.Pass(); | |
40 } | 21 } |
41 | 22 |
42 } // namespace system | 23 } // namespace system |
43 } // namespace mojo | 24 } // namespace mojo |
OLD | NEW |