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

Side by Side Diff: content/public/common/service_registry.h

Issue 302573002: Add a Javascript wrapper around ServiceRegistry and expose it to WebUI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@render-view-shell
Patch Set: 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
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_PUBLIC_COMMON_SERVICE_REGISTRY_H_ 5 #ifndef CONTENT_PUBLIC_COMMON_SERVICE_REGISTRY_H_
6 #define CONTENT_PUBLIC_COMMON_SERVICE_REGISTRY_H_ 6 #define CONTENT_PUBLIC_COMMON_SERVICE_REGISTRY_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/memory/weak_ptr.h"
12 #include "base/strings/string_piece.h" 13 #include "base/strings/string_piece.h"
13 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
14 #include "mojo/public/cpp/bindings/interface_ptr.h" 15 #include "mojo/public/cpp/bindings/interface_ptr.h"
15 #include "mojo/public/cpp/bindings/interface_request.h" 16 #include "mojo/public/cpp/bindings/interface_request.h"
16 #include "mojo/public/cpp/system/core.h" 17 #include "mojo/public/cpp/system/core.h"
17 18
18 namespace content { 19 namespace content {
19 20
20 // A ServiceRegistry exposes local services that have been added using 21 // A ServiceRegistry exposes local services that have been added using
21 // AddService to a paired remote ServiceRegistry and provides local access to 22 // AddService to a paired remote ServiceRegistry and provides local access to
22 // services exposed by the remote ServiceRegistry through GetInterface. 23 // services exposed by the remote ServiceRegistry through GetInterface.
23 class CONTENT_EXPORT ServiceRegistry { 24 class CONTENT_EXPORT ServiceRegistry
25 : public base::SupportsWeakPtr<ServiceRegistry> {
darin (slow to review) 2014/06/21 04:44:16 Please use WeakPtrFactory instead. There was a chr
Sam McNally 2014/06/24 08:45:01 Done.
24 public: 26 public:
25 virtual ~ServiceRegistry() {} 27 virtual ~ServiceRegistry() {}
26 28
27 // Make the service created by |service_factory| available to the remote 29 // Make the service created by |service_factory| available to the remote
28 // InterfaceProvider. In response to each request for a service, 30 // InterfaceProvider. In response to each request for a service,
29 // |service_factory| will be run with an InterfaceRequest<Interface> 31 // |service_factory| will be run with an InterfaceRequest<Interface>
30 // representing that request. 32 // representing that request.
31 template <typename Interface> 33 template <typename Interface>
32 void AddService(const base::Callback<void(mojo::InterfaceRequest<Interface>)> 34 void AddService(const base::Callback<void(mojo::InterfaceRequest<Interface>)>
33 service_factory) { 35 service_factory) {
(...skipping 30 matching lines...) Expand all
64 const base::Callback<void(mojo::InterfaceRequest<Interface>)> 66 const base::Callback<void(mojo::InterfaceRequest<Interface>)>
65 service_factory, 67 service_factory,
66 mojo::ScopedMessagePipeHandle handle) { 68 mojo::ScopedMessagePipeHandle handle) {
67 service_factory.Run(mojo::MakeRequest<Interface>(handle.Pass())); 69 service_factory.Run(mojo::MakeRequest<Interface>(handle.Pass()));
68 } 70 }
69 }; 71 };
70 72
71 } // namespace content 73 } // namespace content
72 74
73 #endif // CONTENT_PUBLIC_COMMON_SERVICE_REGISTRY_H_ 75 #endif // CONTENT_PUBLIC_COMMON_SERVICE_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698