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

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

Issue 2105653002: Delete content::ServiceRegistry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ew
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
(Empty)
1 // Copyright 2014 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_SERVICE_REGISTRY_IMPL_H_
6 #define CONTENT_COMMON_MOJO_SERVICE_REGISTRY_IMPL_H_
7
8 #include <map>
9 #include <queue>
10 #include <string>
11 #include <utility>
12
13 #include "base/callback.h"
14 #include "base/compiler_specific.h"
15 #include "base/memory/weak_ptr.h"
16 #include "content/public/common/service_registry.h"
17 #include "mojo/public/cpp/bindings/binding.h"
18 #include "mojo/public/cpp/system/core.h"
19
20 namespace content {
21
22 class CONTENT_EXPORT ServiceRegistryImpl
23 : public ServiceRegistry,
24 public NON_EXPORTED_BASE(shell::mojom::InterfaceProvider) {
25 public:
26 using ServiceFactory = base::Callback<void(mojo::ScopedMessagePipeHandle)>;
27
28 ServiceRegistryImpl();
29 ~ServiceRegistryImpl() override;
30
31 // ServiceRegistry overrides.
32 void Bind(shell::mojom::InterfaceProviderRequest request) override;
33 shell::mojom::InterfaceProviderRequest TakeRemoteRequest() override;
34 void AddService(
35 const std::string& service_name,
36 const ServiceFactory& service_factory,
37 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) override;
38 void RemoveService(const std::string& service_name) override;
39 void ConnectToRemoteService(base::StringPiece service_name,
40 mojo::ScopedMessagePipeHandle handle) override;
41 void AddServiceOverrideForTesting(
42 const std::string& service_name,
43 const ServiceFactory& service_factory) override;
44 void ClearServiceOverridesForTesting() override;
45
46 bool IsBound() const;
47
48 base::WeakPtr<ServiceRegistry> GetWeakPtr();
49
50 private:
51 // mojo::InterfaceProvider overrides.
52 void GetInterface(const mojo::String& name,
53 mojo::ScopedMessagePipeHandle client_handle) override;
54
55 static void RunServiceFactoryOnTaskRunner(
56 const ServiceFactory& factory,
57 mojo::ScopedMessagePipeHandle handle);
58
59 void OnConnectionError();
60
61 mojo::Binding<shell::mojom::InterfaceProvider> binding_;
62 shell::mojom::InterfaceProviderPtr remote_provider_;
63 shell::mojom::InterfaceProviderRequest remote_provider_request_;
64
65 std::map<
66 std::string,
67 std::pair<ServiceFactory, scoped_refptr<base::SingleThreadTaskRunner>>>
68 service_factories_;
69
70 std::map<std::string, ServiceFactory> service_overrides_;
71
72 base::WeakPtrFactory<ServiceRegistry> weak_factory_;
73 };
74
75 } // namespace content
76
77 #endif // CONTENT_COMMON_MOJO_SERVICE_REGISTRY_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/wake_lock/wake_lock_service_context.cc ('k') | content/common/mojo/service_registry_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698