OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_PUBLIC_BROWSER_MOJO_APP_CONNECTION_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_MOJO_APP_CONNECTION_H_ |
6 #define CONTENT_PUBLIC_BROWSER_MOJO_APP_CONNECTION_H_ | 6 #define CONTENT_PUBLIC_BROWSER_MOJO_APP_CONNECTION_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 CONTENT_EXPORT extern const char kBrowserMojoAppUrl[]; | 21 CONTENT_EXPORT extern const char kBrowserMojoAppUrl[]; |
22 | 22 |
23 // This provides a way for arbitrary browser code to connect to Mojo apps. These | 23 // This provides a way for arbitrary browser code to connect to Mojo apps. These |
24 // objects are not thread-safe but may be constructed and used on any single | 24 // objects are not thread-safe but may be constructed and used on any single |
25 // thread. | 25 // thread. |
26 class CONTENT_EXPORT MojoAppConnection { | 26 class CONTENT_EXPORT MojoAppConnection { |
27 public: | 27 public: |
28 virtual ~MojoAppConnection() {} | 28 virtual ~MojoAppConnection() {} |
29 | 29 |
30 // Creates a new connection to the application at |name| using | 30 // Creates a new connection to the application at |name| using |
31 // |requestor_name| to identify the requestor upon connection. This may be | 31 // |requestor_name| to identify the requestor and |context|'s mojo userid to |
32 // called from any thread. | 32 // specify a profile specific application instantiation. This may be called |
| 33 // from any thread. |
33 static scoped_ptr<MojoAppConnection> Create( | 34 static scoped_ptr<MojoAppConnection> Create( |
| 35 const std::string& user_id, |
34 const std::string& name, | 36 const std::string& name, |
35 const std::string& requestor_name); | 37 const std::string& requestor_name); |
36 | 38 |
37 // Connects to a service within the application. | 39 // Connects to a service within the application. |
38 template <typename Interface> | 40 template <typename Interface> |
39 void GetInterface(mojo::InterfacePtr<Interface>* proxy) { | 41 void GetInterface(mojo::InterfacePtr<Interface>* proxy) { |
40 GetInterface(Interface::Name_, mojo::GetProxy(proxy).PassMessagePipe()); | 42 GetInterface(Interface::Name_, mojo::GetProxy(proxy).PassMessagePipe()); |
41 } | 43 } |
42 | 44 |
43 virtual void GetInterface(const std::string& interface_name, | 45 virtual void GetInterface(const std::string& interface_name, |
44 mojo::ScopedMessagePipeHandle handle) = 0; | 46 mojo::ScopedMessagePipeHandle handle) = 0; |
45 }; | 47 }; |
46 | 48 |
47 } // namespace content | 49 } // namespace content |
48 | 50 |
49 #endif // CONTENT_PUBLIC_BROWSER_MOJO_APP_CONNECTION_H_ | 51 #endif // CONTENT_PUBLIC_BROWSER_MOJO_APP_CONNECTION_H_ |
OLD | NEW |