OLD | NEW |
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_SHELL_PUBLIC_CPP_CONNECTION_H_ | 5 #ifndef MOJO_SHELL_PUBLIC_CPP_CONNECTION_H_ |
6 #define MOJO_SHELL_PUBLIC_CPP_CONNECTION_H_ | 6 #define MOJO_SHELL_PUBLIC_CPP_CONNECTION_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 return SetInterfaceBinderForName( | 72 return SetInterfaceBinderForName( |
73 new internal::InterfaceFactoryBinder<Interface>(factory), | 73 new internal::InterfaceFactoryBinder<Interface>(factory), |
74 Interface::Name_); | 74 Interface::Name_); |
75 } | 75 } |
76 | 76 |
77 // Binds |ptr| to an implemention of Interface in the remote application. | 77 // Binds |ptr| to an implemention of Interface in the remote application. |
78 // |ptr| can immediately be used to start sending requests to the remote | 78 // |ptr| can immediately be used to start sending requests to the remote |
79 // interface. | 79 // interface. |
80 template <typename Interface> | 80 template <typename Interface> |
81 void GetInterface(InterfacePtr<Interface>* ptr) { | 81 void GetInterface(InterfacePtr<Interface>* ptr) { |
82 if (InterfaceProvider* ip = GetRemoteInterfaces()) { | 82 if (shell::mojom::InterfaceProvider* ip = GetRemoteInterfaces()) { |
83 MessagePipe pipe; | 83 MessagePipe pipe; |
84 ptr->Bind(InterfacePtrInfo<Interface>(std::move(pipe.handle0), 0u)); | 84 ptr->Bind(InterfacePtrInfo<Interface>(std::move(pipe.handle0), 0u)); |
85 ip->GetInterface(Interface::Name_, std::move(pipe.handle1)); | 85 ip->GetInterface(Interface::Name_, std::move(pipe.handle1)); |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 // Returns the URL that was used by the source application to establish a | 89 // Returns the URL that was used by the source application to establish a |
90 // connection to the destination application. | 90 // connection to the destination application. |
91 // | 91 // |
92 // When Connection is representing an incoming connection this can be | 92 // When Connection is representing an incoming connection this can be |
93 // different than the URL the application was initially loaded from, if the | 93 // different than the URL the application was initially loaded from, if the |
94 // application handles multiple URLs. Note that this is the URL after all | 94 // application handles multiple URLs. Note that this is the URL after all |
95 // URL rewriting and HTTP redirects have been performed. | 95 // URL rewriting and HTTP redirects have been performed. |
96 // | 96 // |
97 // When Connection is representing and outgoing connection, this will be the | 97 // When Connection is representing and outgoing connection, this will be the |
98 // same as the value returned by GetRemoveApplicationURL(). | 98 // same as the value returned by GetRemoveApplicationURL(). |
99 virtual const std::string& GetConnectionURL() = 0; | 99 virtual const std::string& GetConnectionURL() = 0; |
100 | 100 |
101 // Returns the URL identifying the remote application on this connection. | 101 // Returns the URL identifying the remote application on this connection. |
102 virtual const std::string& GetRemoteApplicationURL() = 0; | 102 virtual const std::string& GetRemoteApplicationURL() = 0; |
103 | 103 |
104 // Returns the raw proxy to the remote application's InterfaceProvider | 104 // Returns the raw proxy to the remote application's InterfaceProvider |
105 // interface. Most applications will just use GetInterface() instead. | 105 // interface. Most applications will just use GetInterface() instead. |
106 // Caller does not take ownership. | 106 // Caller does not take ownership. |
107 virtual InterfaceProvider* GetRemoteInterfaces() = 0; | 107 virtual shell::mojom::InterfaceProvider* GetRemoteInterfaces() = 0; |
108 | 108 |
109 // Returns the local application's InterfaceProvider interface. The return | 109 // Returns the local application's InterfaceProvider interface. The return |
110 // value is owned by this connection. | 110 // value is owned by this connection. |
111 virtual InterfaceProvider* GetLocalInterfaces() = 0; | 111 virtual shell::mojom::InterfaceProvider* GetLocalInterfaces() = 0; |
112 | 112 |
113 // Register a handler to receive an error notification on the pipe to the | 113 // Register a handler to receive an error notification on the pipe to the |
114 // remote application's InterfaceProvider. | 114 // remote application's InterfaceProvider. |
115 virtual void SetRemoteInterfaceProviderConnectionErrorHandler( | 115 virtual void SetRemoteInterfaceProviderConnectionErrorHandler( |
116 const Closure& handler) = 0; | 116 const Closure& handler) = 0; |
117 | 117 |
118 // Returns the id of the remote application. For Connections created via | 118 // Returns the id of the remote application. For Connections created via |
119 // Shell::Connect(), this will not be determined until Connect()'s callback is | 119 // Shell::Connect(), this will not be determined until Connect()'s callback is |
120 // run, and this function will return false. Use AddRemoteIDCallback() to | 120 // run, and this function will return false. Use AddRemoteIDCallback() to |
121 // schedule a callback to be run when the remote application id is available. | 121 // schedule a callback to be run when the remote application id is available. |
(...skipping 17 matching lines...) Expand all Loading... |
139 // some filtering policy preventing this interface from being exposed). | 139 // some filtering policy preventing this interface from being exposed). |
140 virtual bool SetInterfaceBinderForName(InterfaceBinder* binder, | 140 virtual bool SetInterfaceBinderForName(InterfaceBinder* binder, |
141 const std::string& name) = 0; | 141 const std::string& name) = 0; |
142 | 142 |
143 virtual base::WeakPtr<Connection> GetWeakPtr() = 0; | 143 virtual base::WeakPtr<Connection> GetWeakPtr() = 0; |
144 }; | 144 }; |
145 | 145 |
146 } // namespace mojo | 146 } // namespace mojo |
147 | 147 |
148 #endif // MOJO_SHELL_PUBLIC_CPP_CONNECTION_H_ | 148 #endif // MOJO_SHELL_PUBLIC_CPP_CONNECTION_H_ |
OLD | NEW |