Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Side by Side Diff: content/public/common/mojo_shell_connection.h

Issue 1882423004: Move shell service to toplevel shell namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/public/browser/content_browser_client.h ('k') | content/public/test/test_mojo_app.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_PUBLIC_COMMON_MOJO_SHELL_CONNECTION_H_ 5 #ifndef CONTENT_PUBLIC_COMMON_MOJO_SHELL_CONNECTION_H_
6 #define CONTENT_PUBLIC_COMMON_MOJO_SHELL_CONNECTION_H_ 6 #define CONTENT_PUBLIC_COMMON_MOJO_SHELL_CONNECTION_H_
7 7
8 #include "base/callback_forward.h" 8 #include "base/callback_forward.h"
9 #include "content/common/content_export.h" 9 #include "content/common/content_export.h"
10 #include "services/shell/public/interfaces/shell_client.mojom.h" 10 #include "services/shell/public/interfaces/shell_client.mojom.h"
11 11
12 namespace mojo { 12 namespace shell {
13 class Connection; 13 class Connection;
14 class Connector; 14 class Connector;
15 } 15 }
16 16
17 namespace content { 17 namespace content {
18 18
19 // Encapsulates a connection to a spawning external Mojo shell. 19 // Encapsulates a connection to a spawning external Mojo shell.
20 // Access an instance by calling Get(), on the thread the Shell connection is 20 // Access an instance by calling Get(), on the thread the Shell connection is
21 // bound. Clients can implement Listener, which allows them to register services 21 // bound. Clients can implement Listener, which allows them to register services
22 // to expose to inbound connections. Clients should call this any time after 22 // to expose to inbound connections. Clients should call this any time after
23 // the main message loop is created but not yet run (e.g. in the browser process 23 // the main message loop is created but not yet run (e.g. in the browser process
24 // this object is created in PreMainMessageLoopRun(), so the BrowserMainParts 24 // this object is created in PreMainMessageLoopRun(), so the BrowserMainParts
25 // impl can access this in its implementation of that same method. 25 // impl can access this in its implementation of that same method.
26 class CONTENT_EXPORT MojoShellConnection { 26 class CONTENT_EXPORT MojoShellConnection {
27 public: 27 public:
28 // Override to add additional services to inbound connections. 28 // Override to add additional services to inbound connections.
29 // TODO(beng): This should just be ShellClient. 29 // TODO(beng): This should just be ShellClient.
30 class Listener { 30 class Listener {
31 public: 31 public:
32 virtual bool AcceptConnection(mojo::Connection* connection) = 0; 32 virtual bool AcceptConnection(shell::Connection* connection) = 0;
33 33
34 virtual ~Listener() {} 34 virtual ~Listener() {}
35 }; 35 };
36 36
37 using Factory = base::Closure; 37 using Factory = base::Closure;
38 // Sets the factory used to create the MojoShellConnection. This must be 38 // Sets the factory used to create the MojoShellConnection. This must be
39 // called before the MojoShellConnection has been created. 39 // called before the MojoShellConnection has been created.
40 static void SetFactoryForTest(Factory* factory); 40 static void SetFactoryForTest(Factory* factory);
41 41
42 // Will return null if no connection has been established (either because it 42 // Will return null if no connection has been established (either because it
43 // hasn't happened yet or the application was not spawned from the external 43 // hasn't happened yet or the application was not spawned from the external
44 // Mojo shell. 44 // Mojo shell.
45 static MojoShellConnection* Get(); 45 static MojoShellConnection* Get();
46 46
47 // Destroys the connection. Must be called on the thread the connection was 47 // Destroys the connection. Must be called on the thread the connection was
48 // created on. 48 // created on.
49 static void Destroy(); 49 static void Destroy();
50 50
51 // Creates the appropriate MojoShellConnection from |request|. See 51 // Creates the appropriate MojoShellConnection from |request|. See
52 // UsingExternalShell() for details of |is_external|. 52 // UsingExternalShell() for details of |is_external|.
53 static void Create(mojo::shell::mojom::ShellClientRequest request, 53 static void Create(shell::mojom::ShellClientRequest request,
54 bool is_external); 54 bool is_external);
55 55
56 virtual mojo::Connector* GetConnector() = 0; 56 virtual shell::Connector* GetConnector() = 0;
57 57
58 // Indicates whether the shell connection is to an external shell (true) or 58 // Indicates whether the shell connection is to an external shell (true) or
59 // a shell embedded in the browser process (false). 59 // a shell embedded in the browser process (false).
60 virtual bool UsingExternalShell() const = 0; 60 virtual bool UsingExternalShell() const = 0;
61 61
62 // Sets a closure that is called when the connection is lost. 62 // Sets a closure that is called when the connection is lost.
63 virtual void SetConnectionLostClosure(const base::Closure& closure) = 0; 63 virtual void SetConnectionLostClosure(const base::Closure& closure) = 0;
64 64
65 // [De]Register an impl of Listener that will be consulted when the wrapped 65 // [De]Register an impl of Listener that will be consulted when the wrapped
66 // ShellConnection exposes services to inbound connections. 66 // ShellConnection exposes services to inbound connections.
67 // Registered listeners are owned by this MojoShellConnection. 67 // Registered listeners are owned by this MojoShellConnection.
68 virtual void AddListener(Listener* listener) = 0; 68 virtual void AddListener(Listener* listener) = 0;
69 virtual void RemoveListener(Listener* listener) = 0; 69 virtual void RemoveListener(Listener* listener) = 0;
70 70
71 protected: 71 protected:
72 virtual ~MojoShellConnection(); 72 virtual ~MojoShellConnection();
73 }; 73 };
74 74
75 } // namespace content 75 } // namespace content
76 76
77 #endif // CONTENT_PUBLIC_COMMON_MOJO_SHELL_CONNECTION_H_ 77 #endif // CONTENT_PUBLIC_COMMON_MOJO_SHELL_CONNECTION_H_
OLDNEW
« no previous file with comments | « content/public/browser/content_browser_client.h ('k') | content/public/test/test_mojo_app.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698