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

Side by Side Diff: mojo/public/cpp/application/application_connection.h

Issue 1965053002: Remove ApplicationConnection::ConnectToService(). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 7 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 | mojo/public/cpp/application/application_impl.h » ('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 MOJO_PUBLIC_APPLICATION_APPLICATION_CONNECTION_H_ 5 #ifndef MOJO_PUBLIC_APPLICATION_APPLICATION_CONNECTION_H_
6 #define MOJO_PUBLIC_APPLICATION_APPLICATION_CONNECTION_H_ 6 #define MOJO_PUBLIC_APPLICATION_APPLICATION_CONNECTION_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "mojo/public/cpp/application/lib/interface_factory_connector.h" 10 #include "mojo/public/cpp/application/lib/interface_factory_connector.h"
(...skipping 29 matching lines...) Expand all
40 40
41 // Makes Interface available as a service to the remote application. 41 // Makes Interface available as a service to the remote application.
42 // |factory| will create implementations of Interface on demand. 42 // |factory| will create implementations of Interface on demand.
43 template <typename Interface> 43 template <typename Interface>
44 void AddService(InterfaceFactory<Interface>* factory) { 44 void AddService(InterfaceFactory<Interface>* factory) {
45 SetServiceConnectorForName( 45 SetServiceConnectorForName(
46 new internal::InterfaceFactoryConnector<Interface>(factory), 46 new internal::InterfaceFactoryConnector<Interface>(factory),
47 Interface::Name_); 47 Interface::Name_);
48 } 48 }
49 49
50 // Binds |ptr| to an implemention of Interface in the remote application.
51 // |ptr| can immediately be used to start sending requests to the remote
52 // service.
53 template <typename Interface>
54 void ConnectToService(InterfacePtr<Interface>* ptr) {
55 if (ServiceProvider* sp = GetServiceProvider()) {
56 MessagePipe pipe;
57 ptr->Bind(InterfaceHandle<Interface>(pipe.handle0.Pass(), 0u));
58 sp->ConnectToService(Interface::Name_, pipe.handle1.Pass());
59 }
60 }
61
62 // Returns the URL that was used by the source application to establish a 50 // Returns the URL that was used by the source application to establish a
63 // connection to the destination application. 51 // connection to the destination application.
64 // 52 //
65 // When ApplicationConnection is representing an incoming connection this can 53 // When ApplicationConnection is representing an incoming connection this can
66 // be different than the URL the application was initially loaded from, if the 54 // be different than the URL the application was initially loaded from, if the
67 // application handles multiple URLs. Note that this is the URL after all 55 // application handles multiple URLs. Note that this is the URL after all
68 // URL rewriting and HTTP redirects have been performed. 56 // URL rewriting and HTTP redirects have been performed.
69 // 57 //
70 // When ApplicationConnection is representing and outgoing connection, this 58 // When ApplicationConnection is representing and outgoing connection, this
71 // will be the same as the value returned by GetRemoveApplicationURL(). 59 // will be the same as the value returned by GetRemoveApplicationURL().
72 virtual const std::string& GetConnectionURL() = 0; 60 virtual const std::string& GetConnectionURL() = 0;
73 61
74 // Returns the URL identifying the remote application on this connection. 62 // Returns the URL identifying the remote application on this connection.
75 virtual const std::string& GetRemoteApplicationURL() = 0; 63 virtual const std::string& GetRemoteApplicationURL() = 0;
76 64
77 // Returns the raw proxy to the remote application's ServiceProvider 65 // Returns the raw proxy to the remote application's ServiceProvider
78 // interface. Most applications will just use ConnectToService() instead. 66 // interface. Most applications will just use ConnectToService() instead.
79 // Caller does not take ownership. 67 // Caller does not take ownership.
80 virtual ServiceProvider* GetServiceProvider() = 0; 68 virtual ServiceProvider* GetServiceProvider() = 0;
81 69
82 private: 70 private:
83 virtual void SetServiceConnectorForName(ServiceConnector* service_connector, 71 virtual void SetServiceConnectorForName(ServiceConnector* service_connector,
84 const std::string& name) = 0; 72 const std::string& name) = 0;
85 }; 73 };
86 74
87 } // namespace mojo 75 } // namespace mojo
88 76
89 #endif // MOJO_PUBLIC_APPLICATION_APPLICATION_CONNECTION_H_ 77 #endif // MOJO_PUBLIC_APPLICATION_APPLICATION_CONNECTION_H_
OLDNEW
« no previous file with comments | « no previous file | mojo/public/cpp/application/application_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698