Home | History | Annotate | Download | only in system
      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
      3 // found in the LICENSE file.
      4 
      5 #include "mojo/system/platform_channel.h"
      6 
      7 #include "base/logging.h"
      8 
      9 namespace mojo {
     10 namespace system {
     11 
     12 PlatformChannel::~PlatformChannel() {
     13   handle_.CloseIfNecessary();
     14 }
     15 
     16 PlatformChannelHandle PlatformChannel::PassHandle() {
     17   DCHECK(is_valid());
     18   PlatformChannelHandle rv = handle_;
     19   handle_ = PlatformChannelHandle();
     20   return rv;
     21 }
     22 
     23 PlatformChannel::PlatformChannel() {
     24 }
     25 
     26 PlatformServerChannel::PlatformServerChannel(const std::string& name)
     27     : name_(name) {
     28   DCHECK(!name_.empty());
     29 }
     30 
     31 // Static factory method.
     32 // static
     33 scoped_ptr<PlatformClientChannel> PlatformClientChannel::CreateFromHandle(
     34       const PlatformChannelHandle& handle) {
     35   DCHECK(handle.is_valid());
     36   scoped_ptr<PlatformClientChannel> rv(new PlatformClientChannel());
     37   *rv->mutable_handle() = handle;
     38   return rv.Pass();
     39 }
     40 
     41 }  // namespace system
     42 }  // namespace mojo
     43