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

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

Issue 2111353002: Move content's shell connections to the IO thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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>
10 9
11 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/sequenced_task_runner.h"
12 #include "content/public/common/mojo_shell_connection.h" 14 #include "content/public/common/mojo_shell_connection.h"
13 #include "mojo/public/cpp/bindings/binding_set.h" 15 #include "services/shell/public/cpp/identity.h"
14 #include "mojo/public/cpp/system/message_pipe.h" 16
15 #include "services/shell/public/cpp/shell_client.h" 17 namespace shell {
16 #include "services/shell/public/cpp/shell_connection.h" 18 class Connector;
17 #include "services/shell/public/interfaces/shell_client_factory.mojom.h" 19 }
18 20
19 namespace content { 21 namespace content {
20 22
21 class EmbeddedApplicationRunner; 23 class EmbeddedApplicationRunner;
22 24
23 class MojoShellConnectionImpl 25 class MojoShellConnectionImpl : public MojoShellConnection {
24 : public MojoShellConnection,
25 public shell::ShellClient,
26 public shell::InterfaceFactory<shell::mojom::ShellClientFactory>,
27 public shell::mojom::ShellClientFactory {
28
29 public: 26 public:
30 explicit MojoShellConnectionImpl(shell::mojom::ShellClientRequest request); 27 explicit MojoShellConnectionImpl(
28 shell::mojom::ShellClientRequest request,
29 scoped_refptr<base::SequencedTaskRunner> iotask_runner);
31 ~MojoShellConnectionImpl() override; 30 ~MojoShellConnectionImpl() override;
32 31
33 private: 32 private:
33 class IOThreadContext;
34
34 // MojoShellConnection: 35 // MojoShellConnection:
35 shell::ShellConnection* GetShellConnection() override; 36 void SetInitializeHandler(const base::Closure& handler) override;
36 shell::Connector* GetConnector() override; 37 shell::Connector* GetConnector() override;
37 const shell::Identity& GetIdentity() const override; 38 const shell::Identity& GetIdentity() const override;
38 void SetConnectionLostClosure(const base::Closure& closure) override; 39 void SetConnectionLostClosure(const base::Closure& closure) override;
39 void AddEmbeddedShellClient( 40 void AddConnectionFilter(const ConnectionFilter& filter) override;
40 std::unique_ptr<shell::ShellClient> shell_client) override;
41 void AddEmbeddedShellClient(shell::ShellClient* shell_client) override;
42 void AddEmbeddedService(const std::string& name, 41 void AddEmbeddedService(const std::string& name,
43 const MojoApplicationInfo& info) override; 42 const MojoApplicationInfo& info) override;
44 void AddShellClientRequestHandler( 43 void AddShellClientRequestHandler(
45 const std::string& name, 44 const std::string& name,
46 const ShellClientRequestHandler& handler) override; 45 const ShellClientRequestHandler& handler) override;
47 46
48 // shell::ShellClient: 47 void OnContextInitialized();
49 void Initialize(shell::Connector* connector, 48 void OnConnectionLost();
50 const shell::Identity& identity, 49 void CreateShellClient(shell::mojom::ShellClientRequest request,
51 uint32_t id) override; 50 const mojo::String& name);
52 bool AcceptConnection(shell::Connection* connection) override;
53 shell::InterfaceRegistry* GetInterfaceRegistryForConnection() override;
54 shell::InterfaceProvider* GetInterfaceProviderForConnection() override;
55 51
56 // shell::InterfaceFactory<shell::mojom::ShellClientFactory>: 52 shell::Identity identity_;
57 void Create(shell::Connection* connection,
58 shell::mojom::ShellClientFactoryRequest request) override;
59 53
60 // shell::mojom::ShellClientFactory: 54 std::unique_ptr<shell::Connector> connector_;
61 void CreateShellClient(shell::mojom::ShellClientRequest request, 55 scoped_refptr<IOThreadContext> context_;
62 const mojo::String& name) override;
63 56
64 std::unique_ptr<shell::ShellConnection> shell_connection_; 57 base::Closure initialize_handler_;
65 mojo::BindingSet<shell::mojom::ShellClientFactory> factory_bindings_; 58 base::Closure connection_lost_handler_;
66 std::vector<shell::ShellClient*> embedded_shell_clients_; 59
67 std::vector<std::unique_ptr<shell::ShellClient>> owned_shell_clients_;
68 std::unordered_map<std::string, std::unique_ptr<EmbeddedApplicationRunner>> 60 std::unordered_map<std::string, std::unique_ptr<EmbeddedApplicationRunner>>
69 embedded_apps_; 61 embedded_apps_;
70 std::unordered_map<std::string, ShellClientRequestHandler> request_handlers_; 62 std::unordered_map<std::string, ShellClientRequestHandler> request_handlers_;
71 63
64 base::WeakPtrFactory<MojoShellConnectionImpl> weak_factory_;
65
72 DISALLOW_COPY_AND_ASSIGN(MojoShellConnectionImpl); 66 DISALLOW_COPY_AND_ASSIGN(MojoShellConnectionImpl);
73 }; 67 };
74 68
75 } // namespace content 69 } // namespace content
76 70
77 #endif // CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_ 71 #endif // CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698