Index: content/public/browser/mojo_app_connection.h |
diff --git a/content/public/browser/mojo_app_connection.h b/content/public/browser/mojo_app_connection.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7b5e408042a94355de111655b742e65cb56f3558 |
--- /dev/null |
+++ b/content/public/browser/mojo_app_connection.h |
@@ -0,0 +1,48 @@ |
+// Copyright 2015 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 CONTENT_PUBLIC_BROWSER_MOJO_APP_CONNECTION_H_ |
+#define CONTENT_PUBLIC_BROWSER_MOJO_APP_CONNECTION_H_ |
+ |
+#include <string> |
+ |
+#include "base/macros.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "content/common/content_export.h" |
+#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_ptr.h" |
+#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h" |
+#include "third_party/mojo/src/mojo/public/cpp/system/message_pipe.h" |
+ |
+class GURL; |
+ |
+namespace content { |
+ |
+// This provides a way for arbitrary browser code to connect to Mojo |
+// applications through the global Mojo shell. These objects are not thread-safe |
jam
2015/05/27 16:05:36
nit: what does "global mojo shell" mean?
users of
Ken Rockot(use gerrit already)
2015/05/27 19:36:16
Removed the extra details.
|
+// but they can be constructed and used on any single thread. |
+class CONTENT_EXPORT MojoAppConnection { |
+ public: |
+ MojoAppConnection() {} |
+ virtual ~MojoAppConnection() {} |
jam
2015/05/27 16:05:36
nit: see content api wiki and other examples in co
Ken Rockot(use gerrit already)
2015/05/27 19:36:16
Done.
|
+ |
+ // Creates a new connection to the application at |url|. This may be called |
+ // from any thread. |
+ static scoped_ptr<MojoAppConnection> Create(const GURL& url); |
+ |
+ // Connects to a service within the application. |
+ template <typename Interface> |
+ void ConnectToService(mojo::InterfacePtr<Interface>* proxy) { |
+ ConnectToService(Interface::Name_, mojo::GetProxy(proxy).PassMessagePipe()); |
+ } |
+ |
+ virtual void ConnectToService(const std::string& service_name, |
+ mojo::ScopedMessagePipeHandle handle) = 0; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(MojoAppConnection); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_PUBLIC_BROWSER_MOJO_APP_CONNECTION_H_ |