| OLD | NEW |
| 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 { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 PlatformChannelHandle PlatformChannel::PassHandle() { | 25 PlatformChannelHandle PlatformChannel::PassHandle() { |
| 26 DCHECK(is_valid()); | 26 DCHECK(is_valid()); |
| 27 PlatformChannelHandle rv = handle_; | 27 PlatformChannelHandle rv = handle_; |
| 28 handle_ = PlatformChannelHandle(); | 28 handle_ = PlatformChannelHandle(); |
| 29 return rv; | 29 return rv; |
| 30 } | 30 } |
| 31 | 31 |
| 32 PlatformChannel::PlatformChannel() { | 32 PlatformChannel::PlatformChannel() { |
| 33 } | 33 } |
| 34 | 34 |
| 35 // ----------------------------------------------------------------------------- | |
| 36 | |
| 37 PlatformChannelPair::~PlatformChannelPair() { | |
| 38 server_handle_.CloseIfNecessary(); | |
| 39 client_handle_.CloseIfNecessary(); | |
| 40 } | |
| 41 | |
| 42 scoped_ptr<PlatformChannel> PlatformChannelPair::CreateServerChannel() { | |
| 43 if (!server_handle_.is_valid()) { | |
| 44 LOG(WARNING) << "Server handle invalid"; | |
| 45 return scoped_ptr<PlatformChannel>(); | |
| 46 } | |
| 47 | |
| 48 scoped_ptr<PlatformChannel> rv = | |
| 49 PlatformChannel::CreateFromHandle(server_handle_); | |
| 50 server_handle_ = PlatformChannelHandle(); | |
| 51 return rv.Pass(); | |
| 52 } | |
| 53 | |
| 54 scoped_ptr<PlatformChannel> PlatformChannelPair::CreateClientChannel() { | |
| 55 if (!client_handle_.is_valid()) { | |
| 56 LOG(WARNING) << "Client handle invalid"; | |
| 57 return scoped_ptr<PlatformChannel>(); | |
| 58 } | |
| 59 | |
| 60 scoped_ptr<PlatformChannel> rv = | |
| 61 PlatformChannel::CreateFromHandle(client_handle_); | |
| 62 client_handle_ = PlatformChannelHandle(); | |
| 63 return rv.Pass(); | |
| 64 } | |
| 65 | |
| 66 } // namespace system | 35 } // namespace system |
| 67 } // namespace mojo | 36 } // namespace mojo |
| OLD | NEW |