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

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

Issue 1831173002: Scaffolding for Android implementation of PaymentRequest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo
Patch Set: Register PaymentRequest with render process Created 4 years, 8 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 2014 The Chromium Authors. All rights reserved. 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 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_SERVICE_REGISTRY_IMPL_H_ 5 #ifndef CONTENT_COMMON_MOJO_SERVICE_REGISTRY_IMPL_H_
6 #define CONTENT_COMMON_MOJO_SERVICE_REGISTRY_IMPL_H_ 6 #define CONTENT_COMMON_MOJO_SERVICE_REGISTRY_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <queue> 9 #include <queue>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "content/public/common/service_registry.h" 16 #include "content/public/common/service_registry.h"
17 #include "mojo/public/cpp/bindings/binding.h" 17 #include "mojo/public/cpp/bindings/binding.h"
18 #include "mojo/public/cpp/system/core.h" 18 #include "mojo/public/cpp/system/core.h"
19 #include "mojo/shell/public/interfaces/interface_provider.mojom.h" 19 #include "mojo/shell/public/interfaces/interface_provider.mojom.h"
20 20
21 namespace content { 21 namespace content {
22 22
23 class ServiceRegistryAndroid;
24
23 class CONTENT_EXPORT ServiceRegistryImpl 25 class CONTENT_EXPORT ServiceRegistryImpl
24 : public ServiceRegistry, 26 : public ServiceRegistry,
25 public NON_EXPORTED_BASE(mojo::shell::mojom::InterfaceProvider) { 27 public NON_EXPORTED_BASE(mojo::shell::mojom::InterfaceProvider) {
26 public: 28 public:
27 using ServiceFactory = base::Callback<void(mojo::ScopedMessagePipeHandle)>; 29 using ServiceFactory = base::Callback<void(mojo::ScopedMessagePipeHandle)>;
28 30
29 ServiceRegistryImpl(); 31 ServiceRegistryImpl();
30 ~ServiceRegistryImpl() override; 32 ~ServiceRegistryImpl() override;
31 33
32 // Binds this ServiceProvider implementation to a message pipe endpoint. 34 // Binds this ServiceProvider implementation to a message pipe endpoint.
33 void Bind(mojo::shell::mojom::InterfaceProviderRequest request); 35 void Bind(mojo::shell::mojom::InterfaceProviderRequest request);
34 36
35 // Binds to a remote ServiceProvider. This will expose added services to the 37 // Binds to a remote ServiceProvider. This will expose added services to the
36 // remote ServiceProvider with the corresponding handle and enable 38 // remote ServiceProvider with the corresponding handle and enable
37 // ConnectToRemoteService to provide access to services exposed by the remote 39 // ConnectToRemoteService to provide access to services exposed by the remote
38 // ServiceProvider. 40 // ServiceProvider.
39 void BindRemoteServiceProvider( 41 void BindRemoteServiceProvider(
40 mojo::shell::mojom::InterfaceProviderPtr service_provider); 42 mojo::shell::mojom::InterfaceProviderPtr service_provider);
41 43
42 // ServiceRegistry overrides. 44 // ServiceRegistry overrides.
43 void AddService(const std::string& service_name, 45 void AddService(const std::string& service_name,
44 const ServiceFactory service_factory) override; 46 const ServiceFactory service_factory) override;
45 void RemoveService(const std::string& service_name) override; 47 void RemoveService(const std::string& service_name) override;
46 void ConnectToRemoteService(const base::StringPiece& service_name, 48 void ConnectToRemoteService(const base::StringPiece& service_name,
47 mojo::ScopedMessagePipeHandle handle) override; 49 mojo::ScopedMessagePipeHandle handle) override;
48 void AddServiceOverrideForTesting( 50 void AddServiceOverrideForTesting(
49 const std::string& service_name, 51 const std::string& service_name,
50 const ServiceFactory& service_factory) override; 52 const ServiceFactory& service_factory) override;
51 void ClearServiceOverridesForTesting() override; 53 void ClearServiceOverridesForTesting() override;
54 #if defined(OS_ANDROID)
55 const base::android::ScopedJavaGlobalRef<jobject>& GetJavaObj() override;
56 #endif
52 57
53 bool IsBound() const; 58 bool IsBound() const;
54 59
55 base::WeakPtr<ServiceRegistry> GetWeakPtr(); 60 base::WeakPtr<ServiceRegistry> GetWeakPtr();
56 61
57 private: 62 private:
58 // mojo::InterfaceProvider overrides. 63 // mojo::InterfaceProvider overrides.
59 void GetInterface(const mojo::String& name, 64 void GetInterface(const mojo::String& name,
60 mojo::ScopedMessagePipeHandle client_handle) override; 65 mojo::ScopedMessagePipeHandle client_handle) override;
61 66
62 void OnConnectionError(); 67 void OnConnectionError();
63 68
64 mojo::Binding<mojo::shell::mojom::InterfaceProvider> binding_; 69 mojo::Binding<mojo::shell::mojom::InterfaceProvider> binding_;
65 mojo::shell::mojom::InterfaceProviderPtr remote_provider_; 70 mojo::shell::mojom::InterfaceProviderPtr remote_provider_;
66 71
67 std::map<std::string, ServiceFactory> service_factories_; 72 std::map<std::string, ServiceFactory> service_factories_;
68 std::queue<std::pair<std::string, mojo::MessagePipeHandle> > 73 std::queue<std::pair<std::string, mojo::MessagePipeHandle> >
69 pending_connects_; 74 pending_connects_;
70 75
71 std::map<std::string, ServiceFactory> service_overrides_; 76 std::map<std::string, ServiceFactory> service_overrides_;
72 77
78 #if defined(OS_ANDROID)
79 scoped_ptr<ServiceRegistryAndroid> android_impl_;
80 #endif
81
73 base::WeakPtrFactory<ServiceRegistry> weak_factory_; 82 base::WeakPtrFactory<ServiceRegistry> weak_factory_;
74 }; 83 };
75 84
76 } // namespace content 85 } // namespace content
77 86
78 #endif // CONTENT_COMMON_MOJO_SERVICE_REGISTRY_IMPL_H_ 87 #endif // CONTENT_COMMON_MOJO_SERVICE_REGISTRY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698