| 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_JS_APP_H_ | 5 #ifndef MOJO_APPS_JS_JS_APP_H_ |
| 6 #define MOJO_APPS_JS_JS_APP_H_ | 6 #define MOJO_APPS_JS_JS_APP_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
| 10 #include "gin/public/isolate_holder.h" | 10 #include "gin/public/isolate_holder.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 bool Start(); | 31 bool Start(); |
| 32 | 32 |
| 33 // Subclasses must return the JS source code for this app's main script and | 33 // Subclasses must return the JS source code for this app's main script and |
| 34 // the filename or URL that identifies the script's origin. This method will | 34 // the filename or URL that identifies the script's origin. This method will |
| 35 // be called from this app's thread. | 35 // be called from this app's thread. |
| 36 virtual bool Load(std::string* source, std::string* file_name) = 0; | 36 virtual bool Load(std::string* source, std::string* file_name) = 0; |
| 37 | 37 |
| 38 // Called by the JS mojo module to quit this JS app. See mojo.js. | 38 // Called by the JS mojo module to quit this JS app. See mojo.js. |
| 39 void Quit(); | 39 void Quit(); |
| 40 | 40 |
| 41 // Called by the JS mojo module to connect to a Mojo service. | 41 // Called by the JS mojo module to connect to a Mojo application. |
| 42 Handle ConnectToService(const std::string& application_url, | 42 MessagePipeHandle ConnectToApplication(const std::string& application_url); |
| 43 const std::string& interface_name); | 43 |
| 44 // Called by the JS mojo module to retrieve the ServiceProvider message |
| 45 // pipe handle passed to the JS content handler's OnConnect() method. |
| 46 // If this app was not launched by the content handler then return an |
| 47 // invalid Mojo handle. |
| 48 virtual MessagePipeHandle RequestorMessagePipeHandle() = 0; |
| 44 | 49 |
| 45 private: | 50 private: |
| 46 void Run(); | 51 void Run(); |
| 47 void Terminate(); | 52 void Terminate(); |
| 48 | 53 |
| 49 // Used to CHECK that we're running on the correct thread. | 54 // Used to CHECK that we're running on the correct thread. |
| 50 bool on_app_delegate_impl_thread() const; | 55 bool on_app_delegate_impl_thread() const; |
| 51 bool on_js_app_thread() const; | 56 bool on_js_app_thread() const; |
| 52 | 57 |
| 53 ApplicationDelegateImpl* app_delegate_impl_; | 58 ApplicationDelegateImpl* app_delegate_impl_; |
| 54 base::Thread thread_; | 59 base::Thread thread_; |
| 55 scoped_refptr<base::SingleThreadTaskRunner> app_delegate_impl_task_runner_; | 60 scoped_refptr<base::SingleThreadTaskRunner> app_delegate_impl_task_runner_; |
| 56 scoped_refptr<base::SingleThreadTaskRunner> js_app_task_runner_; | 61 scoped_refptr<base::SingleThreadTaskRunner> js_app_task_runner_; |
| 57 MojoRunnerDelegate runner_delegate_; | 62 MojoRunnerDelegate runner_delegate_; |
| 58 scoped_ptr<gin::IsolateHolder> isolate_holder_; | 63 scoped_ptr<gin::IsolateHolder> isolate_holder_; |
| 59 scoped_ptr<gin::ShellRunner> shell_runner_; | 64 scoped_ptr<gin::ShellRunner> shell_runner_; |
| 60 | 65 |
| 61 DISALLOW_COPY_AND_ASSIGN(JSApp); | 66 DISALLOW_COPY_AND_ASSIGN(JSApp); |
| 62 }; | 67 }; |
| 63 | 68 |
| 64 } // namespace apps | 69 } // namespace apps |
| 65 } // namespace mojo | 70 } // namespace mojo |
| 66 | 71 |
| 67 #endif // MOJO_APPS_JS_JS_APP_H_ | 72 #endif // MOJO_APPS_JS_JS_APP_H_ |
| OLD | NEW |