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

Side by Side Diff: content/common/service_manager/service_manager_connection_impl.h

Issue 2729733003: Change ServiceManagerConnectionImpl to run service request handlers on the IO thread. (Closed)
Patch Set: Fix startup race. Created 3 years, 9 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_SERVICE_MANAGER_SERVICE_MANAGER_CONNECTION_IMPL_H_ 5 #ifndef CONTENT_COMMON_SERVICE_MANAGER_SERVICE_MANAGER_CONNECTION_IMPL_H_
6 #define CONTENT_COMMON_SERVICE_MANAGER_SERVICE_MANAGER_CONNECTION_IMPL_H_ 6 #define CONTENT_COMMON_SERVICE_MANAGER_SERVICE_MANAGER_CONNECTION_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/sequenced_task_runner.h" 13 #include "base/sequenced_task_runner.h"
14 #include "content/common/content_export.h"
14 #include "content/public/common/service_manager_connection.h" 15 #include "content/public/common/service_manager_connection.h"
15 #include "mojo/public/cpp/system/message_pipe.h" 16 #include "mojo/public/cpp/system/message_pipe.h"
16 #include "services/service_manager/public/cpp/identity.h" 17 #include "services/service_manager/public/cpp/identity.h"
17 #include "services/service_manager/public/interfaces/service.mojom.h" 18 #include "services/service_manager/public/interfaces/service.mojom.h"
18 19
19 namespace service_manager { 20 namespace service_manager {
20 class Connector; 21 class Connector;
21 } 22 }
22 23
23 namespace content { 24 namespace content {
24 25
25 class EmbeddedServiceRunner; 26 class CONTENT_EXPORT ServiceManagerConnectionImpl
26 27 : public ServiceManagerConnection {
27 class ServiceManagerConnectionImpl : public ServiceManagerConnection {
28 public: 28 public:
29 explicit ServiceManagerConnectionImpl( 29 explicit ServiceManagerConnectionImpl(
30 service_manager::mojom::ServiceRequest request, 30 service_manager::mojom::ServiceRequest request,
31 scoped_refptr<base::SequencedTaskRunner> io_task_runner); 31 scoped_refptr<base::SequencedTaskRunner> io_task_runner);
32 ~ServiceManagerConnectionImpl() override; 32 ~ServiceManagerConnectionImpl() override;
33 33
34 private: 34 private:
35 class IOThreadContext; 35 class IOThreadContext;
36 36
37 // ServiceManagerConnection: 37 // ServiceManagerConnection:
(...skipping 11 matching lines...) Expand all
49 void AddServiceRequestHandler( 49 void AddServiceRequestHandler(
50 const std::string& name, 50 const std::string& name,
51 const ServiceRequestHandler& handler) override; 51 const ServiceRequestHandler& handler) override;
52 int AddOnConnectHandler(const OnConnectHandler& handler) override; 52 int AddOnConnectHandler(const OnConnectHandler& handler) override;
53 void RemoveOnConnectHandler(int id) override; 53 void RemoveOnConnectHandler(int id) override;
54 54
55 void OnContextInitialized(const service_manager::Identity& identity); 55 void OnContextInitialized(const service_manager::Identity& identity);
56 void OnConnectionLost(); 56 void OnConnectionLost();
57 void OnConnect(const service_manager::ServiceInfo& local_info, 57 void OnConnect(const service_manager::ServiceInfo& local_info,
58 const service_manager::ServiceInfo& remote_info); 58 const service_manager::ServiceInfo& remote_info);
59 void CreateService(service_manager::mojom::ServiceRequest request,
60 const std::string& name);
61 void GetInterface(service_manager::mojom::InterfaceProvider* provider, 59 void GetInterface(service_manager::mojom::InterfaceProvider* provider,
62 const std::string& interface_name, 60 const std::string& interface_name,
63 mojo::ScopedMessagePipeHandle request_handle); 61 mojo::ScopedMessagePipeHandle request_handle);
64 62
65 service_manager::Identity identity_; 63 service_manager::Identity identity_;
66 service_manager::ServiceInfo local_info_; 64 service_manager::ServiceInfo local_info_;
67 service_manager::ServiceInfo last_remote_info_; 65 service_manager::ServiceInfo last_remote_info_;
68 66
69 std::unique_ptr<service_manager::Connector> connector_; 67 std::unique_ptr<service_manager::Connector> connector_;
70 scoped_refptr<IOThreadContext> context_; 68 scoped_refptr<IOThreadContext> context_;
71 69
72 base::Closure connection_lost_handler_; 70 base::Closure connection_lost_handler_;
73 71
74 std::unordered_map<std::string, std::unique_ptr<EmbeddedServiceRunner>>
75 embedded_services_;
76 std::unordered_map<std::string, ServiceRequestHandler> request_handlers_;
77 int next_on_connect_handler_id_ = 0; 72 int next_on_connect_handler_id_ = 0;
78 std::map<int, OnConnectHandler> on_connect_handlers_; 73 std::map<int, OnConnectHandler> on_connect_handlers_;
79 74
80 base::WeakPtrFactory<ServiceManagerConnectionImpl> weak_factory_; 75 base::WeakPtrFactory<ServiceManagerConnectionImpl> weak_factory_;
81 76
82 DISALLOW_COPY_AND_ASSIGN(ServiceManagerConnectionImpl); 77 DISALLOW_COPY_AND_ASSIGN(ServiceManagerConnectionImpl);
83 }; 78 };
84 79
85 } // namespace content 80 } // namespace content
86 81
87 #endif // CONTENT_COMMON_SERVICE_MANAGER_SERVICE_MANAGER_CONNECTION_IMPL_H_ 82 #endif // CONTENT_COMMON_SERVICE_MANAGER_SERVICE_MANAGER_CONNECTION_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698