Chromium Code Reviews| 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 JS_APP_H_ | |
| 6 #define JS_APP_H_ | |
| 7 | |
| 8 #include "base/memory/ref_counted.h" | |
| 9 #include "base/single_thread_task_runner.h" | |
| 10 #include "base/threading/thread.h" | |
| 11 #include "gin/public/isolate_holder.h" | |
| 12 #include "gin/shell_runner.h" | |
| 13 #include "mojo/apps/js/mojo_runner_delegate.h" | |
| 14 #include "mojo/services/public/interfaces/content_handler/content_handler.mojom. h" | |
| 15 | |
| 16 namespace mojo { | |
| 17 namespace apps { | |
| 18 | |
| 19 class JSContentHandlerApp; | |
| 20 | |
| 21 class JSAppRunnerDelegate : public MojoRunnerDelegate { | |
| 22 public: | |
| 23 JSAppRunnerDelegate(); | |
| 24 }; | |
| 25 | |
| 26 class JSApp : public base::RefCountedThreadSafe<JSApp> { | |
|
Aaron Boodman
2014/09/10 02:22:09
In general it is preferred that every class have a
Aaron Boodman
2014/09/10 02:22:09
RefCounting can make understanding code harder bec
hansmuller
2014/09/11 00:26:17
OK
| |
| 27 public: | |
| 28 JSApp(JSContentHandlerApp* content_handler_app, | |
| 29 const std::string& url, | |
| 30 URLResponsePtr content); | |
| 31 | |
| 32 static JSApp* From(v8::Isolate* isolate); | |
| 33 | |
| 34 ScopedMessagePipeHandle ConnectToService( | |
| 35 const std::string& application_url, const std::string& interface_name); | |
| 36 | |
| 37 bool Start(); | |
| 38 void Quit(); | |
| 39 | |
| 40 private: | |
| 41 JSContentHandlerApp* content_handler_app_; | |
| 42 std::string url_; | |
| 43 URLResponsePtr content_; | |
| 44 base::Thread thread_; | |
| 45 scoped_refptr<base::SingleThreadTaskRunner> content_handler_task_runner_; | |
| 46 scoped_refptr<base::SingleThreadTaskRunner> js_app_task_runner_; | |
| 47 JSAppRunnerDelegate runner_delegate_; | |
| 48 scoped_ptr<gin::IsolateHolder> isolate_holder_; | |
| 49 scoped_ptr<gin::ShellRunner> shell_runner_; | |
| 50 | |
| 51 void Run(); | |
| 52 void Terminate(); | |
| 53 bool on_content_handler_thread() const; | |
| 54 bool on_js_app_thread() const; | |
| 55 | |
| 56 ~JSApp(); | |
| 57 friend class base::RefCountedThreadSafe<JSApp>; | |
|
Aaron Boodman
2014/09/10 02:22:09
decl order is incorrect -- see reference to styleg
hansmuller
2014/09/11 00:26:16
I've removed the RefCountedThreadSafe boilerplate
| |
| 58 DISALLOW_COPY_AND_ASSIGN(JSApp); | |
| 59 }; | |
| 60 | |
| 61 } // namespace apps | |
| 62 } // namespace mojo | |
| 63 | |
| 64 #endif // JS_APP_H_ | |
| OLD | NEW |