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

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: address comment Created 6 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
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
(...skipping 29 matching lines...) Expand all
51 // Connect to an interface provided by the remote interface provider. 52 // Connect to an interface provided by the remote interface provider.
52 template <typename Interface> 53 template <typename Interface>
53 void GetRemoteInterface(mojo::InterfacePtr<Interface>* ptr) { 54 void GetRemoteInterface(mojo::InterfacePtr<Interface>* ptr) {
54 mojo::MessagePipe pipe; 55 mojo::MessagePipe pipe;
55 ptr->Bind(pipe.handle0.Pass()); 56 ptr->Bind(pipe.handle0.Pass());
56 GetRemoteInterface(Interface::Name_, pipe.handle1.Pass()); 57 GetRemoteInterface(Interface::Name_, pipe.handle1.Pass());
57 } 58 }
58 virtual void GetRemoteInterface(const base::StringPiece& name, 59 virtual void GetRemoteInterface(const base::StringPiece& name,
59 mojo::ScopedMessagePipeHandle handle) = 0; 60 mojo::ScopedMessagePipeHandle handle) = 0;
60 61
62 virtual base::WeakPtr<ServiceRegistry> GetWeakPtr() = 0;
darin (slow to review) 2014/06/28 21:10:38 hmm, it seems a bit uncommon to expose a WeakPtr t
Sam McNally 2014/06/30 01:26:14 Removed it.
63
61 private: 64 private:
62 template <typename Interface> 65 template <typename Interface>
63 static void ForwardToServiceFactory( 66 static void ForwardToServiceFactory(
64 const base::Callback<void(mojo::InterfaceRequest<Interface>)> 67 const base::Callback<void(mojo::InterfaceRequest<Interface>)>
65 service_factory, 68 service_factory,
66 mojo::ScopedMessagePipeHandle handle) { 69 mojo::ScopedMessagePipeHandle handle) {
67 service_factory.Run(mojo::MakeRequest<Interface>(handle.Pass())); 70 service_factory.Run(mojo::MakeRequest<Interface>(handle.Pass()));
68 } 71 }
69 }; 72 };
70 73
71 } // namespace content 74 } // namespace content
72 75
73 #endif // CONTENT_PUBLIC_COMMON_SERVICE_REGISTRY_H_ 76 #endif // CONTENT_PUBLIC_COMMON_SERVICE_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698