OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 MOJO_PUBLIC_APPLICATION_CONNECTION_CONTEXT_H_ |
| 6 #define MOJO_PUBLIC_APPLICATION_CONNECTION_CONTEXT_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 namespace mojo { |
| 11 |
| 12 // A |ConnectionContext| is used to track context about a given message pipe |
| 13 // connection. It is usually associated to the "impl" side of an interface. |
| 14 // |
| 15 // |Application| (see //mojo/public/interfaces/application/application.mojom) |
| 16 // accepts a message that looks like: |
| 17 // |
| 18 // AcceptConnection(string requestor_url, |
| 19 // string resolved_url, |
| 20 // ServiceProvider& services); |
| 21 // |
| 22 // (TODO(vtl): I've jumped the gun: I've pre-removed |exposed_services|, made |
| 23 // |services| non-nullable, and reordered the parameters.) |
| 24 // |
| 25 // Upon handling |AcceptConnection()|, the |ServiceProvider| implementation |
| 26 // bound to |services| is given a |ConnectionContext| with |type = |
| 27 // Type::INCOMING|, |remote_url = requestor_url|, and |connection_url = |
| 28 // resolved_url|. |
| 29 // |
| 30 // The |ConnectionContext| is meant to be propagated: If the remote side uses |
| 31 // its |ServiceProviderPtr| to request a |Foo| (from the local side), then the |
| 32 // |Foo| implementation (again, on the local side) may be given (a copy of) the |
| 33 // |ConnectionContext| described above. |
| 34 struct ConnectionContext { |
| 35 enum class Type { |
| 36 UNKNOWN = 0, |
| 37 INCOMING, |
| 38 }; |
| 39 |
| 40 ConnectionContext() {} |
| 41 ConnectionContext(Type type, |
| 42 const std::string& remote_url, |
| 43 const std::string& connection_url) |
| 44 : type(type), remote_url(remote_url), connection_url(connection_url) {} |
| 45 |
| 46 Type type = Type::UNKNOWN; |
| 47 |
| 48 // The URL of the remote side of this connection (as provided by the |Shell|); |
| 49 // if unknown/not applicable, this is empty. |
| 50 std::string remote_url; |
| 51 |
| 52 // The URL used by the remote side to establish "this" connection (or a parent |
| 53 // thereof); if unknown/not applicable, this is empty. |
| 54 std::string connection_url; |
| 55 }; |
| 56 |
| 57 } // namespace mojo |
| 58 |
| 59 #endif // MOJO_PUBLIC_APPLICATION_CONNECTION_CONTEXT_H_ |
OLD | NEW |