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 SERVICES_JS_JS_APP_H_ | 5 #ifndef SERVICES_JS_JS_APP_H_ |
6 #define SERVICES_JS_JS_APP_H_ | 6 #define SERVICES_JS_JS_APP_H_ |
7 | 7 |
8 #include "gin/public/isolate_holder.h" | 8 #include "gin/public/isolate_holder.h" |
9 #include "gin/shell_runner.h" | 9 #include "gin/shell_runner.h" |
10 #include "mojo/application/content_handler_factory.h" | 10 #include "mojo/application/content_handler_factory.h" |
11 #include "mojo/public/cpp/system/message_pipe.h" | 11 #include "mojo/public/cpp/system/message_pipe.h" |
12 #include "mojo/public/interfaces/application/application.mojom.h" | 12 #include "mojo/public/interfaces/application/application.mojom.h" |
13 #include "mojo/public/interfaces/application/shell.mojom.h" | 13 #include "mojo/public/interfaces/application/shell.mojom.h" |
14 #include "services/js/js_app_runner_delegate.h" | 14 #include "services/js/js_app_runner_delegate.h" |
15 #include "v8/include/v8.h" | 15 #include "v8/include/v8.h" |
16 | 16 |
17 namespace js { | 17 namespace js { |
18 | 18 |
19 class JSApp; | 19 class JSApp; |
20 class JSAppMessageLoopObservers; | 20 class JSAppMessageLoopObservers; |
21 class ApplicationDelegateImpl; | 21 class ApplicationDelegateImpl; |
22 | 22 |
23 // Each JavaScript app started by the content handler runs on its own thread | 23 // Each JavaScript app started by the content handler runs on its own thread |
24 // and in its own V8 isolate. This class represents one running JS app. | 24 // and in its own V8 isolate. This class represents one running JS app. |
25 | 25 |
26 class JSApp : public mojo::ContentHandlerFactory::HandledApplicationHolder { | 26 class JSApp : public mojo::ContentHandlerFactory::HandledApplicationHolder { |
27 public: | 27 public: |
28 JSApp(mojo::InterfaceRequest<mojo::Application> application_request, | 28 JSApp(mojo::InterfaceRequest<mojo::Application> application_request, |
29 mojo::URLResponsePtr response); | 29 mojo::URLResponsePtr response); |
30 virtual ~JSApp(); | 30 ~JSApp() override; |
31 | 31 |
32 private: | 32 private: |
33 static const char kMainModuleName[]; | 33 static const char kMainModuleName[]; |
34 | 34 |
35 void OnAppLoaded(std::string url, v8::Handle<v8::Value> module); | 35 void OnAppLoaded(std::string url, v8::Handle<v8::Value> module); |
36 | 36 |
37 mojo::InterfaceRequest<mojo::Application> application_request_; | 37 mojo::InterfaceRequest<mojo::Application> application_request_; |
38 JSAppRunnerDelegate runner_delegate_; | 38 JSAppRunnerDelegate runner_delegate_; |
39 gin::IsolateHolder isolate_holder_; | 39 gin::IsolateHolder isolate_holder_; |
40 scoped_ptr<gin::ShellRunner> shell_runner_; | 40 scoped_ptr<gin::ShellRunner> shell_runner_; |
41 v8::Persistent<v8::Object> app_instance_; | 41 v8::Persistent<v8::Object> app_instance_; |
42 scoped_ptr<JSAppMessageLoopObservers> message_loop_observers_; | 42 scoped_ptr<JSAppMessageLoopObservers> message_loop_observers_; |
43 | 43 |
44 DISALLOW_COPY_AND_ASSIGN(JSApp); | 44 DISALLOW_COPY_AND_ASSIGN(JSApp); |
45 }; | 45 }; |
46 | 46 |
47 } // namespace js | 47 } // namespace js |
48 | 48 |
49 #endif // SERVICES_JS_JS_APP_H_ | 49 #endif // SERVICES_JS_JS_APP_H_ |
OLD | NEW |