OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 MOJO_APPS_JS_CONTENT_HANDLER_H_ | 5 #ifndef MOJO_APPS_JS_CONTENT_HANDLER_H_ |
6 #define MOJO_APPS_JS_CONTENT_HANDLER_H_ | 6 #define MOJO_APPS_JS_CONTENT_HANDLER_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "mojo/public/cpp/application/application_delegate.h" | 10 #include "mojo/public/cpp/application/application_delegate.h" |
| 11 #include "mojo/public/cpp/bindings/interface_request.h" |
11 #include "mojo/public/cpp/system/message_pipe.h" | 12 #include "mojo/public/cpp/system/message_pipe.h" |
| 13 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
12 | 14 |
13 namespace mojo { | 15 namespace mojo { |
14 | 16 |
15 class ApplcationImpl; | 17 class ApplcationImpl; |
16 | 18 |
17 namespace apps { | 19 namespace apps { |
18 | 20 |
19 class ApplicationDelegateImpl; | 21 class ApplicationDelegateImpl; |
20 class JSApp; | 22 class JSApp; |
21 | 23 |
22 // Manages the JSApps started by this content handler. This class owns the one | 24 // Manages the JSApps started by this content handler. This class owns the one |
23 // reference to the Mojo shell. JSApps post a task to the content handler's | 25 // reference to the Mojo shell. JSApps post a task to the content handler's |
24 // thread to connect to a service or to quit. | 26 // thread to connect to a service or to quit. |
25 // | 27 // |
26 // The lifetime each JSApp is defined by its entry in AppVector. When the entry | 28 // The lifetime each JSApp is defined by its entry in AppVector. When the entry |
27 // is removed ("erased") by QuitJSApp(), the JSApp is destroyed. | 29 // is removed ("erased") by QuitJSApp(), the JSApp is destroyed. |
28 | 30 |
29 class ApplicationDelegateImpl : public ApplicationDelegate { | 31 class ApplicationDelegateImpl : public ApplicationDelegate { |
30 public: | 32 public: |
31 ApplicationDelegateImpl(); | 33 ApplicationDelegateImpl(); |
32 ~ApplicationDelegateImpl() override; | 34 ~ApplicationDelegateImpl() override; |
33 | 35 |
34 // Add app to the AppVector and call its Start() method. | 36 // Add app to the AppVector and call its Start() method. |
35 void StartJSApp(scoped_ptr<JSApp> app); | 37 void StartJSApp(scoped_ptr<JSApp> app); |
36 | 38 |
37 // Remove app from the AppVector; destroys the app. | 39 // Remove app from the AppVector; destroys the app. |
38 void QuitJSApp(JSApp *app); | 40 void QuitJSApp(JSApp *app); |
39 | 41 |
40 void ConnectToService(ScopedMessagePipeHandle pipe_handle, | 42 // Use the shell to connect to a ServiceProvider for application_url. |
41 const std::string& application_url, | 43 void ConnectToApplication(const std::string& application_url, |
42 const std::string& interface_name); | 44 InterfaceRequest<ServiceProvider> request); |
43 | 45 |
44 protected: | 46 protected: |
45 // ApplicationDelegate: | 47 // ApplicationDelegate: |
46 void Initialize(ApplicationImpl* app) override; | 48 void Initialize(ApplicationImpl* app) override; |
47 | 49 |
48 private: | 50 private: |
49 typedef ScopedVector<JSApp> AppVector; | 51 typedef ScopedVector<JSApp> AppVector; |
50 ApplicationImpl* application_impl_; | 52 ApplicationImpl* application_impl_; // Owns the shell used by all JSApps. |
51 AppVector app_vector_; | 53 AppVector app_vector_; |
52 }; | 54 }; |
53 | 55 |
54 } // namespace apps | 56 } // namespace apps |
55 } // namespace mojo | 57 } // namespace mojo |
56 | 58 |
57 #endif // MOJO_APPS_JS_CONTENT_HANDLER_H_ | 59 #endif // MOJO_APPS_JS_CONTENT_HANDLER_H_ |
OLD | NEW |