Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / ipc / ipc_channel_factory.cc
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
3 // found in the LICENSE file.
4
5 #include "ipc/ipc_channel_factory.h"
6
7 namespace IPC {
8
9 namespace {
10
11 class PlatformChannelFactory : public ChannelFactory {
12  public:
13   PlatformChannelFactory(ChannelHandle handle,
14                          Channel::Mode mode)
15       : handle_(handle), mode_(mode) {
16   }
17
18   std::string GetName() const override {
19     return handle_.name;
20   }
21
22   scoped_ptr<Channel> BuildChannel(Listener* listener) override {
23     return Channel::Create(handle_, mode_, listener);
24   }
25
26  private:
27   ChannelHandle handle_;
28   Channel::Mode mode_;
29
30   DISALLOW_COPY_AND_ASSIGN(PlatformChannelFactory);
31 };
32
33 } // namespace
34
35 // static
36 scoped_ptr<ChannelFactory> ChannelFactory::Create(
37     const ChannelHandle& handle, Channel::Mode mode) {
38   return scoped_ptr<ChannelFactory>(new PlatformChannelFactory(handle, mode));
39 }
40
41 }  // namespace IPC