| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_ | 5 #ifndef CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_ |
| 6 #define CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_ | 6 #define CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 namespace content { | 22 namespace content { |
| 23 | 23 |
| 24 // Returns true for processes launched from an external mojo shell. | 24 // Returns true for processes launched from an external mojo shell. |
| 25 bool IsRunningInMojoShell(); | 25 bool IsRunningInMojoShell(); |
| 26 | 26 |
| 27 class MojoShellConnectionImpl : public MojoShellConnection, | 27 class MojoShellConnectionImpl : public MojoShellConnection, |
| 28 public mojo::ApplicationDelegate { | 28 public mojo::ApplicationDelegate { |
| 29 public: | 29 public: |
| 30 // Creates an instance of this class and stuffs it in TLS on the calling | 30 // Creates an instance of this class and stuffs it in TLS on the calling |
| 31 // thread. Retrieve it using MojoShellConnection::Get(). Blocks the calling | 31 // thread. Retrieve it using MojoShellConnection::Get(). |
| 32 // thread until calling GetApplication() will return an Initialized() | |
| 33 // application with a bound ShellPtr. | |
| 34 static void Create(); | 32 static void Create(); |
| 35 // Same as Create(), but receives a handle instead of looking for one on the | 33 |
| 36 // command line. | 34 // Will return null if no connection has been established (either because it |
| 37 static void CreateWithMessagePipe(mojo::ScopedMessagePipeHandle handle); | 35 // hasn't happened yet or the application was not spawned from the external |
| 36 // Mojo shell). |
| 37 static MojoShellConnectionImpl* Get(); |
| 38 |
| 39 // Blocks the calling thread until calling GetApplication() will return an |
| 40 // Initialized() application with a bound ShellPtr. This call is a no-op |
| 41 // if the connection has already been initialized. |
| 42 void BindToCommandLinePlatformChannel(); |
| 43 |
| 44 // Same as BindToCommandLinePlatformChannel(), but receives a |handle| instead |
| 45 // of looking for one on the command line. |
| 46 void BindToMessagePipe(mojo::ScopedMessagePipeHandle handle); |
| 38 | 47 |
| 39 private: | 48 private: |
| 40 MojoShellConnectionImpl(); | 49 MojoShellConnectionImpl(); |
| 41 ~MojoShellConnectionImpl() override; | 50 ~MojoShellConnectionImpl() override; |
| 42 | 51 |
| 43 // mojo::ApplicationDelegate: | 52 // mojo::ApplicationDelegate: |
| 44 void Initialize(mojo::ApplicationImpl* application) override; | 53 void Initialize(mojo::ApplicationImpl* application) override; |
| 45 bool ConfigureIncomingConnection( | 54 bool ConfigureIncomingConnection( |
| 46 mojo::ApplicationConnection* connection) override; | 55 mojo::ApplicationConnection* connection) override; |
| 47 | 56 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 59 scoped_ptr<mojo::runner::RunnerConnection> runner_connection_; | 68 scoped_ptr<mojo::runner::RunnerConnection> runner_connection_; |
| 60 scoped_ptr<mojo::ApplicationImpl> application_impl_; | 69 scoped_ptr<mojo::ApplicationImpl> application_impl_; |
| 61 std::vector<Listener*> listeners_; | 70 std::vector<Listener*> listeners_; |
| 62 | 71 |
| 63 DISALLOW_COPY_AND_ASSIGN(MojoShellConnectionImpl); | 72 DISALLOW_COPY_AND_ASSIGN(MojoShellConnectionImpl); |
| 64 }; | 73 }; |
| 65 | 74 |
| 66 } // namespace content | 75 } // namespace content |
| 67 | 76 |
| 68 #endif // CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_ | 77 #endif // CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_ |
| OLD | NEW |