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

Side by Side Diff: content/common/mojo/mojo_shell_connection_impl.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
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_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 <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "content/public/common/mojo_shell_connection.h" 12 #include "content/public/common/mojo_shell_connection.h"
13 #include "mojo/public/cpp/system/message_pipe.h" 13 #include "mojo/public/cpp/system/message_pipe.h"
14 #include "services/shell/public/cpp/shell.h"
15 #include "services/shell/public/cpp/shell_client.h" 14 #include "services/shell/public/cpp/shell_client.h"
16 #include "services/shell/public/cpp/shell_connection.h" 15 #include "services/shell/public/cpp/shell_connection.h"
17 16
18 namespace content { 17 namespace content {
19 18
20 // Returns true for processes launched from an external mojo shell. 19 // Returns true for processes launched from an external mojo shell.
21 bool IsRunningInMojoShell(); 20 bool IsRunningInMojoShell();
22 21
23 class MojoShellConnectionImpl : public MojoShellConnection, 22 class MojoShellConnectionImpl : public MojoShellConnection,
24 public mojo::ShellClient { 23 public shell::ShellClient {
25 public: 24 public:
26 // Creates the MojoShellConnection using MojoShellConnection::Factory. Returns 25 // Creates the MojoShellConnection using MojoShellConnection::Factory. Returns
27 // true if a factory was set and the connection was created, false otherwise. 26 // true if a factory was set and the connection was created, false otherwise.
28 static bool CreateUsingFactory(); 27 static bool CreateUsingFactory();
29 28
30 // Creates an instance of this class and stuffs it in TLS on the calling 29 // Creates an instance of this class and stuffs it in TLS on the calling
31 // thread. Retrieve it using MojoShellConnection::Get(). 30 // thread. Retrieve it using MojoShellConnection::Get().
32 static void Create(); 31 static void Create();
33 32
34 // Will return null if no connection has been established (either because it 33 // 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 34 // hasn't happened yet or the application was not spawned from the external
36 // Mojo shell). 35 // Mojo shell).
37 static MojoShellConnectionImpl* Get(); 36 static MojoShellConnectionImpl* Get();
38 37
39 // Binds the shell connection to a ShellClientFactory request pipe from the 38 // Binds the shell connection to a ShellClientFactory request pipe from the
40 // command line. This must only be called once. 39 // command line. This must only be called once.
41 void BindToRequestFromCommandLine(); 40 void BindToRequestFromCommandLine();
42 41
43 private: 42 private:
44 friend class MojoShellConnection; 43 friend class MojoShellConnection;
45 44
46 explicit MojoShellConnectionImpl(bool external); 45 explicit MojoShellConnectionImpl(bool external);
47 ~MojoShellConnectionImpl() override; 46 ~MojoShellConnectionImpl() override;
48 47
49 void WaitForShellIfNecessary(); 48 void WaitForShellIfNecessary();
50 49
51 // mojo::ShellClient: 50 // shell::ShellClient:
52 void Initialize(mojo::Connector* connector, 51 void Initialize(shell::Connector* connector,
53 const mojo::Identity& identity, 52 const shell::Identity& identity,
54 uint32_t id) override; 53 uint32_t id) override;
55 bool AcceptConnection(mojo::Connection* connection) override; 54 bool AcceptConnection(shell::Connection* connection) override;
56 55
57 // MojoShellConnection: 56 // MojoShellConnection:
58 mojo::Connector* GetConnector() override; 57 shell::Connector* GetConnector() override;
59 bool UsingExternalShell() const override; 58 bool UsingExternalShell() const override;
60 void SetConnectionLostClosure(const base::Closure& closure) override; 59 void SetConnectionLostClosure(const base::Closure& closure) override;
61 void AddListener(Listener* listener) override; 60 void AddListener(Listener* listener) override;
62 void RemoveListener(Listener* listener) override; 61 void RemoveListener(Listener* listener) override;
63 62
64 const bool external_; 63 const bool external_;
65 std::unique_ptr<mojo::ShellConnection> shell_connection_; 64 std::unique_ptr<shell::ShellConnection> shell_connection_;
66 std::vector<Listener*> listeners_; 65 std::vector<Listener*> listeners_;
67 66
68 DISALLOW_COPY_AND_ASSIGN(MojoShellConnectionImpl); 67 DISALLOW_COPY_AND_ASSIGN(MojoShellConnectionImpl);
69 }; 68 };
70 69
71 } // namespace content 70 } // namespace content
72 71
73 #endif // CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_ 72 #endif // CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_
OLDNEW
« no previous file with comments | « content/common/mojo/embedded_application_runner.cc ('k') | content/common/mojo/mojo_shell_connection_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698