OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 CONTENT_PUBLIC_BROWSER_MOJO_APP_CONNECTION_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_MOJO_APP_CONNECTION_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "content/common/content_export.h" |
| 12 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_ptr.h" |
| 13 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h" |
| 14 #include "third_party/mojo/src/mojo/public/cpp/system/message_pipe.h" |
| 15 |
| 16 class GURL; |
| 17 |
| 18 namespace content { |
| 19 |
| 20 // This provides a way for arbitrary browser code to connect to Mojo apps. These |
| 21 // objects are not thread-safe but may be constructed and used on any single |
| 22 // thread. |
| 23 class CONTENT_EXPORT MojoAppConnection { |
| 24 public: |
| 25 virtual ~MojoAppConnection() {} |
| 26 |
| 27 // Creates a new connection to the application at |url|. This may be called |
| 28 // from any thread. |
| 29 static scoped_ptr<MojoAppConnection> Create(const GURL& url); |
| 30 |
| 31 // Connects to a service within the application. |
| 32 template <typename Interface> |
| 33 void ConnectToService(mojo::InterfacePtr<Interface>* proxy) { |
| 34 ConnectToService(Interface::Name_, mojo::GetProxy(proxy).PassMessagePipe()); |
| 35 } |
| 36 |
| 37 virtual void ConnectToService(const std::string& service_name, |
| 38 mojo::ScopedMessagePipeHandle handle) = 0; |
| 39 }; |
| 40 |
| 41 } // namespace content |
| 42 |
| 43 #endif // CONTENT_PUBLIC_BROWSER_MOJO_APP_CONNECTION_H_ |
OLD | NEW |