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 285333003: Support exposing Mojo services between render frames, render threads, and their respective hosts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix gn Created 6 years, 6 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 "content/public/common/service_registry.h"
15 #include "mojo/public/cpp/bindings/interface_impl.h"
16 #include "mojo/public/cpp/system/core.h"
17 #include "mojo/public/interfaces/interface_provider/interface_provider.mojom.h"
18
19 namespace content {
20
21 class ServiceRegistryImpl
22 : public ServiceRegistry,
23 public mojo::InterfaceImpl<mojo::IInterfaceProvider> {
24 public:
25 ServiceRegistryImpl();
26 explicit ServiceRegistryImpl(mojo::ScopedMessagePipeHandle shell_handle);
27 virtual ~ServiceRegistryImpl();
28
29 // Binds to a remote Shell. This will expose added services to the remote
30 // shell with the corresponding handle and enable ConnectTo to provide access
31 // to services exposed by the remote Shell.
32 void Bind(mojo::ScopedMessagePipeHandle handle);
33
34 // ServiceRegistry overrides.
35 virtual void AddService(
36 const std::string& service_name,
37 const base::Callback<void(mojo::ScopedMessagePipeHandle)> service_factory)
38 OVERRIDE;
39 virtual void RemoveService(const std::string& service_name) OVERRIDE;
40 virtual void GetInterface(const base::StringPiece& service_name,
41 mojo::ScopedMessagePipeHandle handle) OVERRIDE;
42
43 private:
44 // mojo::InterfaceImpl<mojo::IInterfaceProvider> overrides.
45 virtual void GetInterface(
46 const mojo::String& name,
47 mojo::ScopedMessagePipeHandle client_handle) OVERRIDE;
48 virtual void OnConnectionError() OVERRIDE;
49
50 std::map<std::string, base::Callback<void(mojo::ScopedMessagePipeHandle)> >
51 service_factories_;
52 std::queue<std::pair<std::string, mojo::MessagePipeHandle> >
53 pending_connects_;
54 bool bound_;
55 };
56
57 } // namespace content
58
59 #endif // CONTENT_COMMON_MOJO_SERVICE_REGISTRY_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698