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

Side by Side Diff: content/common/mojo/mojo_shell_connection_impl.h

Issue 1738663002: Hook embedded shell up to MojoShellConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 <vector> 8 #include <vector>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.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 "mojo/shell/public/cpp/shell.h"
14 #include "mojo/shell/public/cpp/shell_client.h" 15 #include "mojo/shell/public/cpp/shell_client.h"
15 #include "mojo/shell/public/cpp/shell_connection.h" 16 #include "mojo/shell/public/cpp/shell_connection.h"
16 17
17 namespace mojo { 18 namespace mojo {
18 namespace shell { 19 namespace shell {
19 class RunnerConnection; 20 class RunnerConnection;
20 } 21 }
21 } 22 }
22 23
23 namespace content { 24 namespace content {
24 25
25 // Returns true for processes launched from an external mojo shell. 26 // Returns true for processes launched from an external mojo shell.
26 bool IsRunningInMojoShell(); 27 bool IsRunningInMojoShell();
27 28
28 class MojoShellConnectionImpl : public MojoShellConnection, 29 class MojoShellConnectionImpl : public MojoShellConnection,
29 public mojo::ShellClient { 30 public mojo::ShellClient {
30 public: 31 public:
31 // Creates an instance of this class and stuffs it in TLS on the calling 32 // Creates an instance of this class and stuffs it in TLS on the calling
32 // thread. Retrieve it using MojoShellConnection::Get(). 33 // thread. Retrieve it using MojoShellConnection::Get().
33 static void Create(); 34 static void Create();
34 35
36 // Like above but for initializing a connection to an embedded in-process
37 // shell implementation. Binds to |request|.
38 static void Create(mojo::ShellClientRequest request);
39
35 // Will return null if no connection has been established (either because it 40 // Will return null if no connection has been established (either because it
36 // hasn't happened yet or the application was not spawned from the external 41 // hasn't happened yet or the application was not spawned from the external
37 // Mojo shell). 42 // Mojo shell).
38 static MojoShellConnectionImpl* Get(); 43 static MojoShellConnectionImpl* Get();
39 44
40 // Blocks the calling thread until calling GetApplication() will return an 45 // Blocks the calling thread until calling GetApplication() will return an
41 // Initialized() application with a bound ShellPtr. This call is a no-op 46 // Initialized() application with a bound ShellPtr. This call is a no-op
42 // if the connection has already been initialized. 47 // if the connection has already been initialized.
43 void BindToCommandLinePlatformChannel(); 48 void BindToCommandLinePlatformChannel();
44 49
45 // Same as BindToCommandLinePlatformChannel(), but receives a |handle| instead 50 // Same as BindToCommandLinePlatformChannel(), but receives a |handle| instead
46 // of looking for one on the command line. 51 // of looking for one on the command line.
47 void BindToMessagePipe(mojo::ScopedMessagePipeHandle handle); 52 void BindToMessagePipe(mojo::ScopedMessagePipeHandle handle);
48 53
49 private: 54 private:
50 MojoShellConnectionImpl(); 55 explicit MojoShellConnectionImpl(bool external);
51 ~MojoShellConnectionImpl() override; 56 ~MojoShellConnectionImpl() override;
52 57
53 // mojo::ShellClient: 58 // mojo::ShellClient:
54 void Initialize(mojo::Shell* shell, const std::string& url, 59 void Initialize(mojo::Shell* shell, const std::string& url,
55 uint32_t id, uint32_t user_id) override; 60 uint32_t id, uint32_t user_id) override;
56 bool AcceptConnection(mojo::Connection* connection) override; 61 bool AcceptConnection(mojo::Connection* connection) override;
57 62
58 // MojoShellConnection: 63 // MojoShellConnection:
59 mojo::Shell* GetShell() override; 64 mojo::Shell* GetShell() override;
60 bool UsingExternalShell() const override; 65 bool UsingExternalShell() const override;
61 void AddListener(Listener* listener) override; 66 void AddListener(Listener* listener) override;
62 void RemoveListener(Listener* listener) override; 67 void RemoveListener(Listener* listener) override;
63 68
64 // Blocks the calling thread until a connection to the spawning shell is 69 // Blocks the calling thread until a connection to the spawning shell is
65 // established, an Application request from it is bound, and the Initialize() 70 // established, an Application request from it is bound, and the Initialize()
66 // method on that application is called. 71 // method on that application is called.
67 void WaitForShell(mojo::ScopedMessagePipeHandle handle); 72 void WaitForShell(mojo::ScopedMessagePipeHandle handle);
68 73
74 bool external_;
69 bool initialized_; 75 bool initialized_;
70 scoped_ptr<mojo::shell::RunnerConnection> runner_connection_; 76 scoped_ptr<mojo::shell::RunnerConnection> runner_connection_;
71 scoped_ptr<mojo::ShellConnection> shell_connection_; 77 scoped_ptr<mojo::ShellConnection> shell_connection_;
72 std::vector<Listener*> listeners_; 78 std::vector<Listener*> listeners_;
73 79
74 DISALLOW_COPY_AND_ASSIGN(MojoShellConnectionImpl); 80 DISALLOW_COPY_AND_ASSIGN(MojoShellConnectionImpl);
75 }; 81 };
76 82
77 } // namespace content 83 } // namespace content
78 84
79 #endif // CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_ 85 #endif // CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698