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

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

Issue 1806843005: Promote {Add,Clear}ServiceOverrideForTesting to ServiceRegistry public interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nit. Created 4 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
« no previous file with comments | « no previous file | content/common/mojo/service_registry_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
(...skipping 21 matching lines...) Expand all
32 // Binds this ServiceProvider implementation to a message pipe endpoint. 32 // Binds this ServiceProvider implementation to a message pipe endpoint.
33 void Bind(mojo::shell::mojom::InterfaceProviderRequest request); 33 void Bind(mojo::shell::mojom::InterfaceProviderRequest request);
34 34
35 // Binds to a remote ServiceProvider. This will expose added services to the 35 // Binds to a remote ServiceProvider. This will expose added services to the
36 // remote ServiceProvider with the corresponding handle and enable 36 // remote ServiceProvider with the corresponding handle and enable
37 // ConnectToRemoteService to provide access to services exposed by the remote 37 // ConnectToRemoteService to provide access to services exposed by the remote
38 // ServiceProvider. 38 // ServiceProvider.
39 void BindRemoteServiceProvider( 39 void BindRemoteServiceProvider(
40 mojo::shell::mojom::InterfaceProviderPtr service_provider); 40 mojo::shell::mojom::InterfaceProviderPtr service_provider);
41 41
42 // Registers a local service factory to intercept ConnectToRemoteService
43 // requests instead of actually connecting to the remote registry. Used only
44 // for testing.
45 void AddServiceOverrideForTesting(const std::string& service_name,
46 const ServiceFactory& service_factory);
47 void ClearServiceOverridesForTesting();
48
49 // ServiceRegistry overrides. 42 // ServiceRegistry overrides.
50 void AddService(const std::string& service_name, 43 void AddService(const std::string& service_name,
51 const ServiceFactory service_factory) override; 44 const ServiceFactory service_factory) override;
52 void RemoveService(const std::string& service_name) override; 45 void RemoveService(const std::string& service_name) override;
53 void ConnectToRemoteService(const base::StringPiece& service_name, 46 void ConnectToRemoteService(const base::StringPiece& service_name,
54 mojo::ScopedMessagePipeHandle handle) override; 47 mojo::ScopedMessagePipeHandle handle) override;
48 void AddServiceOverrideForTesting(
49 const std::string& service_name,
50 const ServiceFactory& service_factory) override;
51 void ClearServiceOverridesForTesting() override;
55 52
56 bool IsBound() const; 53 bool IsBound() const;
57 54
58 base::WeakPtr<ServiceRegistry> GetWeakPtr(); 55 base::WeakPtr<ServiceRegistry> GetWeakPtr();
59 56
60 private: 57 private:
61 // mojo::InterfaceProvider overrides. 58 // mojo::InterfaceProvider overrides.
62 void GetInterface(const mojo::String& name, 59 void GetInterface(const mojo::String& name,
63 mojo::ScopedMessagePipeHandle client_handle) override; 60 mojo::ScopedMessagePipeHandle client_handle) override;
64 61
65 void OnConnectionError(); 62 void OnConnectionError();
66 63
67 mojo::Binding<mojo::shell::mojom::InterfaceProvider> binding_; 64 mojo::Binding<mojo::shell::mojom::InterfaceProvider> binding_;
68 mojo::shell::mojom::InterfaceProviderPtr remote_provider_; 65 mojo::shell::mojom::InterfaceProviderPtr remote_provider_;
69 66
70 std::map<std::string, ServiceFactory> service_factories_; 67 std::map<std::string, ServiceFactory> service_factories_;
71 std::queue<std::pair<std::string, mojo::MessagePipeHandle> > 68 std::queue<std::pair<std::string, mojo::MessagePipeHandle> >
72 pending_connects_; 69 pending_connects_;
73 70
74 std::map<std::string, ServiceFactory> service_overrides_; 71 std::map<std::string, ServiceFactory> service_overrides_;
75 72
76 base::WeakPtrFactory<ServiceRegistry> weak_factory_; 73 base::WeakPtrFactory<ServiceRegistry> weak_factory_;
77 }; 74 };
78 75
79 } // namespace content 76 } // namespace content
80 77
81 #endif // CONTENT_COMMON_MOJO_SERVICE_REGISTRY_IMPL_H_ 78 #endif // CONTENT_COMMON_MOJO_SERVICE_REGISTRY_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | content/common/mojo/service_registry_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698