| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MOJO_APPS_JS_JS_APP_H_ | |
| 6 #define MOJO_APPS_JS_JS_APP_H_ | |
| 7 | |
| 8 #include "base/memory/ref_counted.h" | |
| 9 #include "base/threading/thread.h" | |
| 10 #include "gin/public/isolate_holder.h" | |
| 11 #include "gin/shell_runner.h" | |
| 12 #include "mojo/application/content_handler_factory.h" | |
| 13 #include "mojo/edk/js/mojo_runner_delegate.h" | |
| 14 #include "mojo/public/cpp/application/application_delegate.h" | |
| 15 #include "mojo/public/interfaces/application/application.mojom.h" | |
| 16 #include "mojo/public/interfaces/application/shell.mojom.h" | |
| 17 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" | |
| 18 | |
| 19 namespace mojo { | |
| 20 namespace apps { | |
| 21 | |
| 22 class JSApp; | |
| 23 class ApplicationDelegateImpl; | |
| 24 | |
| 25 // Each JavaScript app started by content handler runs on its own thread and | |
| 26 // in its own V8 isolate. This class represents one running JS app. | |
| 27 | |
| 28 class JSApp : public InterfaceImpl<Application>, | |
| 29 public ContentHandlerFactory::HandledApplicationHolder { | |
| 30 public: | |
| 31 JSApp(ShellPtr shell, URLResponsePtr response); | |
| 32 virtual ~JSApp(); | |
| 33 | |
| 34 // Called by the JS mojo module to quit this JS app. See mojo.js. | |
| 35 void Quit(); | |
| 36 | |
| 37 // Called by the JS mojo module to connect to a Mojo application. | |
| 38 MessagePipeHandle ConnectToApplication(const std::string& application_url); | |
| 39 | |
| 40 // Called by the JS mojo module to retrieve the ServiceProvider message | |
| 41 // pipe handle passed to the JS application's AcceptConnection() method. | |
| 42 MessagePipeHandle RequestorMessagePipeHandle(); | |
| 43 | |
| 44 private: | |
| 45 // Application methods: | |
| 46 void AcceptConnection(const String& requestor_url, | |
| 47 ServiceProviderPtr provider) override; | |
| 48 void Initialize(Array<String> args) override; | |
| 49 | |
| 50 void QuitInternal(); | |
| 51 | |
| 52 ShellPtr shell_; | |
| 53 js::MojoRunnerDelegate runner_delegate; | |
| 54 gin::IsolateHolder isolate_holder_; | |
| 55 scoped_ptr<gin::ShellRunner> shell_runner_; | |
| 56 std::string source_; | |
| 57 std::string file_name_; | |
| 58 ScopedMessagePipeHandle requestor_handle_; | |
| 59 | |
| 60 DISALLOW_COPY_AND_ASSIGN(JSApp); | |
| 61 }; | |
| 62 | |
| 63 } // namespace apps | |
| 64 } // namespace mojo | |
| 65 | |
| 66 #endif // MOJO_APPS_JS_JS_APP_H_ | |
| OLD | NEW |