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 // Upon handling |AcceptConnection()|, the |ServiceProvider| implementation | |
23 // bound to |services| is given a |ConnectionContext| with |type = | |
24 // Type::INCOMING|, |remote_url = requestor_url|, and |connection_url = | |
25 // resolved_url|. | |
26 // | |
27 // The |ConnectionContext| is meant to be propagated: If the remote side uses | |
28 // its |ServiceProviderPtr| to request a |Foo| (from the local side), then the | |
29 // |Foo| implementation (again, on the local side) may be given (a copy of) the | |
30 // |ConnectionContext| described above. | |
31 struct ConnectionContext { | |
32 enum class Type { | |
33 UNKNOWN = 0, | |
34 INCOMING, | |
35 }; | |
36 | |
37 ConnectionContext() {} | |
38 ConnectionContext(Type type, | |
39 const std::string& remote_url, | |
40 const std::string& connection_url) | |
41 : type(type), remote_url(remote_url), connection_url(connection_url) {} | |
42 | |
43 Type type = Type::UNKNOWN; | |
44 | |
45 // The URL of the remote side of this connection (as provided by the |Shell|); | |
46 // if unknown/not applicable, this is empty. | |
47 std::string remote_url; | |
48 | |
49 // The URL used by the remote side to establish "this" connection (or a parent | |
50 // thereof); if unknown/not applicable, this is empty. | |
51 std::string connection_url; | |
52 }; | |
53 | |
54 } // namespace mojo | |
55 | |
56 #endif // MOJO_PUBLIC_APPLICATION_CONNECTION_CONTEXT_H_ | |
OLD | NEW |