OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_PUBLIC_COMMON_MOJO_SHELL_CONNECTION_H_ |
| 6 #define CONTENT_PUBLIC_COMMON_MOJO_SHELL_CONNECTION_H_ |
| 7 |
| 8 namespace mojo { |
| 9 class ApplicationConnection; |
| 10 class ApplicationImpl; |
| 11 } |
| 12 |
| 13 namespace content { |
| 14 |
| 15 // Encapsulates a connection to a spawning external Mojo shell. |
| 16 // Access an instance by calling Get(), on the thread the Shell connection is |
| 17 // bound. Clients can implement Listener, which allows them to register services |
| 18 // to expose to inbound connections. Clients should call this any time after |
| 19 // the main message loop is created but not yet run (e.g. in the browser process |
| 20 // this object is created in PreMainMessageLoopRun(), so the BrowserMainParts |
| 21 // impl can access this in its implementation of that same method. |
| 22 class MojoShellConnection { |
| 23 public: |
| 24 // Override to add additional services to inbound connections. |
| 25 class Listener { |
| 26 public: |
| 27 virtual bool ConfigureIncomingConnection( |
| 28 mojo::ApplicationConnection* connection) = 0; |
| 29 |
| 30 protected: |
| 31 virtual ~Listener() {} |
| 32 }; |
| 33 |
| 34 // Will return null if no connection has been established (either because it |
| 35 // hasn't happened yet or the application was not spawned from the external |
| 36 // Mojo shell. |
| 37 static MojoShellConnection* Get(); |
| 38 |
| 39 // Destroys the connection. Must be called on the thread the connection was |
| 40 // created on. |
| 41 static void Destroy(); |
| 42 |
| 43 // Returns an Initialized() ApplicationImpl. |
| 44 virtual mojo::ApplicationImpl* GetApplication() = 0; |
| 45 |
| 46 // [De]Register an impl of Listener that will be consulted when the wrapped |
| 47 // ApplicationImpl exposes services to inbound connections. |
| 48 virtual void AddListener(Listener* listener) = 0; |
| 49 virtual void RemoveListener(Listener* listener) = 0; |
| 50 |
| 51 protected: |
| 52 virtual ~MojoShellConnection(); |
| 53 }; |
| 54 |
| 55 } // namespace content |
| 56 |
| 57 #endif // CONTENT_PUBLIC_COMMON_MOJO_SHELL_CONNECTION_H_ |
OLD | NEW |