| 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 #ifndef MOJO_SYSTEM_PLATFORM_CHANNEL_H_ | 5 #ifndef MOJO_SYSTEM_PLATFORM_CHANNEL_H_ |
| 6 #define MOJO_SYSTEM_PLATFORM_CHANNEL_H_ | 6 #define MOJO_SYSTEM_PLATFORM_CHANNEL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/process/launch.h" | 13 #include "base/process/launch.h" |
| 14 #include "mojo/public/system/system_export.h" | |
| 15 #include "mojo/system/platform_channel_handle.h" | 14 #include "mojo/system/platform_channel_handle.h" |
| 15 #include "mojo/system/system_impl_export.h" |
| 16 | 16 |
| 17 class CommandLine; | 17 class CommandLine; |
| 18 | 18 |
| 19 namespace mojo { | 19 namespace mojo { |
| 20 namespace system { | 20 namespace system { |
| 21 | 21 |
| 22 class MOJO_SYSTEM_EXPORT PlatformChannel { | 22 class MOJO_SYSTEM_IMPL_EXPORT PlatformChannel { |
| 23 public: | 23 public: |
| 24 virtual ~PlatformChannel(); | 24 virtual ~PlatformChannel(); |
| 25 | 25 |
| 26 // Returns the channel's handle, passing ownership. | 26 // Returns the channel's handle, passing ownership. |
| 27 PlatformChannelHandle PassHandle(); | 27 PlatformChannelHandle PassHandle(); |
| 28 | 28 |
| 29 bool is_valid() const { return handle_.is_valid(); } | 29 bool is_valid() const { return handle_.is_valid(); } |
| 30 | 30 |
| 31 protected: | 31 protected: |
| 32 PlatformChannel(); | 32 PlatformChannel(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 46 // for it) or fake. | 46 // for it) or fake. |
| 47 // - That client channel may then be used in-process (e.g., for single process | 47 // - That client channel may then be used in-process (e.g., for single process |
| 48 // tests) by getting a |PlatformClientChannel| using |CreateClientChannel()|. | 48 // tests) by getting a |PlatformClientChannel| using |CreateClientChannel()|. |
| 49 // - Or it may be "passed" to a new child process using | 49 // - Or it may be "passed" to a new child process using |
| 50 // |GetDataNeededToPassClientChannelToChildProcess()|, etc. (see below). The | 50 // |GetDataNeededToPassClientChannelToChildProcess()|, etc. (see below). The |
| 51 // child process would then get a |PlatformClientChannel| by using | 51 // child process would then get a |PlatformClientChannel| by using |
| 52 // |PlatformClientChannel::CreateFromParentProcess()|. | 52 // |PlatformClientChannel::CreateFromParentProcess()|. |
| 53 // - In both these cases, "ownership" of the client channel is transferred (to | 53 // - In both these cases, "ownership" of the client channel is transferred (to |
| 54 // the |PlatformClientChannel| or the child process). | 54 // the |PlatformClientChannel| or the child process). |
| 55 // TODO(vtl): Add ways of passing it to other existing processes. | 55 // TODO(vtl): Add ways of passing it to other existing processes. |
| 56 class MOJO_SYSTEM_EXPORT PlatformServerChannel : public PlatformChannel { | 56 class MOJO_SYSTEM_IMPL_EXPORT PlatformServerChannel : public PlatformChannel { |
| 57 public: | 57 public: |
| 58 virtual ~PlatformServerChannel() {} | 58 virtual ~PlatformServerChannel() {} |
| 59 | 59 |
| 60 static scoped_ptr<PlatformServerChannel> Create(const std::string& name); | 60 static scoped_ptr<PlatformServerChannel> Create(const std::string& name); |
| 61 | 61 |
| 62 // For in-process use, from a server channel you can make a corresponding | 62 // For in-process use, from a server channel you can make a corresponding |
| 63 // client channel. | 63 // client channel. |
| 64 virtual scoped_ptr<PlatformClientChannel> CreateClientChannel() = 0; | 64 virtual scoped_ptr<PlatformClientChannel> CreateClientChannel() = 0; |
| 65 | 65 |
| 66 // Prepares to pass the client channel to a new child process, to be launched | 66 // Prepares to pass the client channel to a new child process, to be launched |
| (...skipping 11 matching lines...) Expand all Loading... |
| 78 | 78 |
| 79 protected: | 79 protected: |
| 80 explicit PlatformServerChannel(const std::string& name); | 80 explicit PlatformServerChannel(const std::string& name); |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 const std::string name_; | 83 const std::string name_; |
| 84 | 84 |
| 85 DISALLOW_COPY_AND_ASSIGN(PlatformServerChannel); | 85 DISALLOW_COPY_AND_ASSIGN(PlatformServerChannel); |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 class MOJO_SYSTEM_EXPORT PlatformClientChannel : public PlatformChannel { | 88 class MOJO_SYSTEM_IMPL_EXPORT PlatformClientChannel : public PlatformChannel { |
| 89 public: | 89 public: |
| 90 virtual ~PlatformClientChannel() {} | 90 virtual ~PlatformClientChannel() {} |
| 91 | 91 |
| 92 // Creates a client channel if you already have the underlying handle for it. | 92 // Creates a client channel if you already have the underlying handle for it. |
| 93 // Note: This takes ownership of |handle|. | 93 // Note: This takes ownership of |handle|. |
| 94 static scoped_ptr<PlatformClientChannel> CreateFromHandle( | 94 static scoped_ptr<PlatformClientChannel> CreateFromHandle( |
| 95 const PlatformChannelHandle& handle); | 95 const PlatformChannelHandle& handle); |
| 96 | 96 |
| 97 // To be called to get a client channel passed from the parent process, using | 97 // To be called to get a client channel passed from the parent process, using |
| 98 // |PlatformServerChannel::GetDataNeededToPassClientChannelToChildProcess()|, | 98 // |PlatformServerChannel::GetDataNeededToPassClientChannelToChildProcess()|, |
| 99 // etc. Returns null on failure. | 99 // etc. Returns null on failure. |
| 100 static scoped_ptr<PlatformClientChannel> CreateFromParentProcess( | 100 static scoped_ptr<PlatformClientChannel> CreateFromParentProcess( |
| 101 const CommandLine& command_line); | 101 const CommandLine& command_line); |
| 102 | 102 |
| 103 private: | 103 private: |
| 104 PlatformClientChannel() {} | 104 PlatformClientChannel() {} |
| 105 | 105 |
| 106 DISALLOW_COPY_AND_ASSIGN(PlatformClientChannel); | 106 DISALLOW_COPY_AND_ASSIGN(PlatformClientChannel); |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 } // namespace system | 109 } // namespace system |
| 110 } // namespace mojo | 110 } // namespace mojo |
| 111 | 111 |
| 112 #endif // MOJO_SYSTEM_PLATFORM_CHANNEL_H_ | 112 #endif // MOJO_SYSTEM_PLATFORM_CHANNEL_H_ |
| OLD | NEW |