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

Unified Diff: mojo/public/cpp/application/connection_context.h

Issue 1971613002: Abstract out connection information into ConnectionContext. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/cpp/application/BUILD.gn ('k') | mojo/public/cpp/application/lib/application_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/application/connection_context.h
diff --git a/mojo/public/cpp/application/connection_context.h b/mojo/public/cpp/application/connection_context.h
new file mode 100644
index 0000000000000000000000000000000000000000..59ce434505a5d1ec87570de3f4996d92d24f6b17
--- /dev/null
+++ b/mojo/public/cpp/application/connection_context.h
@@ -0,0 +1,59 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_PUBLIC_APPLICATION_CONNECTION_CONTEXT_H_
+#define MOJO_PUBLIC_APPLICATION_CONNECTION_CONTEXT_H_
+
+#include <string>
+
+namespace mojo {
+
+// A |ConnectionContext| is used to track context about a given message pipe
+// connection. It is usually associated to the "impl" side of an interface.
+//
+// |Application| (see //mojo/public/interfaces/application/application.mojom)
+// accepts a message that looks like:
+//
+// AcceptConnection(string requestor_url,
+// string resolved_url,
+// ServiceProvider& services);
+//
+// (TODO(vtl): I've jumped the gun: I've pre-removed |exposed_services|, made
+// |services| non-nullable, and reordered the parameters.)
+//
+// Upon handling |AcceptConnection()|, the |ServiceProvider| implementation
+// bound to |services| is given a |ConnectionContext| with |type =
+// Type::INCOMING|, |remote_url = requestor_url|, and |connection_url =
+// resolved_url|.
+//
+// The |ConnectionContext| is meant to be propagated: If the remote side uses
+// its |ServiceProviderPtr| to request a |Foo| (from the local side), then the
+// |Foo| implementation (again, on the local side) may be given (a copy of) the
+// |ConnectionContext| described above.
+struct ConnectionContext {
+ enum class Type {
+ UNKNOWN = 0,
+ INCOMING,
+ };
+
+ ConnectionContext() {}
+ ConnectionContext(Type type,
+ const std::string& remote_url,
+ const std::string& connection_url)
+ : type(type), remote_url(remote_url), connection_url(connection_url) {}
+
+ Type type = Type::UNKNOWN;
+
+ // The URL of the remote side of this connection (as provided by the |Shell|);
+ // if unknown/not applicable, this is empty.
+ std::string remote_url;
+
+ // The URL used by the remote side to establish "this" connection (or a parent
+ // thereof); if unknown/not applicable, this is empty.
+ std::string connection_url;
+};
+
+} // namespace mojo
+
+#endif // MOJO_PUBLIC_APPLICATION_CONNECTION_CONTEXT_H_
« no previous file with comments | « mojo/public/cpp/application/BUILD.gn ('k') | mojo/public/cpp/application/lib/application_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698