OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_ | |
6 #define CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_ | |
7 | |
8 #include <memory> | |
9 | |
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" | |
14 #include "content/public/common/mojo_shell_connection.h" | |
15 #include "mojo/public/cpp/bindings/string.h" | |
16 #include "mojo/public/cpp/system/message_pipe.h" | |
17 #include "services/shell/public/cpp/identity.h" | |
18 #include "services/shell/public/interfaces/service.mojom.h" | |
19 | |
20 namespace shell { | |
21 class Connector; | |
22 } | |
23 | |
24 namespace content { | |
25 | |
26 class EmbeddedApplicationRunner; | |
27 | |
28 class MojoShellConnectionImpl : public MojoShellConnection { | |
29 public: | |
30 explicit MojoShellConnectionImpl( | |
31 shell::mojom::ServiceRequest request, | |
32 scoped_refptr<base::SequencedTaskRunner> io_task_runner); | |
33 ~MojoShellConnectionImpl() override; | |
34 | |
35 private: | |
36 class IOThreadContext; | |
37 | |
38 // MojoShellConnection: | |
39 void Start() override; | |
40 void SetInitializeHandler(const base::Closure& handler) override; | |
41 shell::Connector* GetConnector() override; | |
42 const shell::Identity& GetIdentity() const override; | |
43 void SetConnectionLostClosure(const base::Closure& closure) override; | |
44 void SetupInterfaceRequestProxies( | |
45 shell::InterfaceRegistry* registry, | |
46 shell::InterfaceProvider* provider) override; | |
47 int AddConnectionFilter(std::unique_ptr<ConnectionFilter> filter) override; | |
48 void RemoveConnectionFilter(int filter_id) override; | |
49 void AddEmbeddedService(const std::string& name, | |
50 const MojoApplicationInfo& info) override; | |
51 void AddServiceRequestHandler( | |
52 const std::string& name, | |
53 const ServiceRequestHandler& handler) override; | |
54 | |
55 void OnContextInitialized(const shell::Identity& identity); | |
56 void OnConnectionLost(); | |
57 void CreateService(shell::mojom::ServiceRequest request, | |
58 const std::string& name); | |
59 void GetInterface(shell::mojom::InterfaceProvider* provider, | |
60 const std::string& interface_name, | |
61 mojo::ScopedMessagePipeHandle request_handle); | |
62 | |
63 shell::Identity identity_; | |
64 | |
65 std::unique_ptr<shell::Connector> connector_; | |
66 scoped_refptr<IOThreadContext> context_; | |
67 | |
68 base::Closure initialize_handler_; | |
69 base::Closure connection_lost_handler_; | |
70 | |
71 std::unordered_map<std::string, std::unique_ptr<EmbeddedApplicationRunner>> | |
72 embedded_apps_; | |
73 std::unordered_map<std::string, ServiceRequestHandler> request_handlers_; | |
74 | |
75 base::WeakPtrFactory<MojoShellConnectionImpl> weak_factory_; | |
76 | |
77 DISALLOW_COPY_AND_ASSIGN(MojoShellConnectionImpl); | |
78 }; | |
79 | |
80 } // namespace content | |
81 | |
82 #endif // CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_ | |
OLD | NEW |