Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(556)

Unified Diff: mojo/apps/js/js_app.h

Issue 467263006: JavaScript Content Handler Version 0.0 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes per review feedback. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/apps/js/js_app.h
diff --git a/mojo/apps/js/js_app.h b/mojo/apps/js/js_app.h
new file mode 100644
index 0000000000000000000000000000000000000000..4ad8fe52d2ed21ccb4e5e02428a882f4f7aa8db6
--- /dev/null
+++ b/mojo/apps/js/js_app.h
@@ -0,0 +1,72 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_APPS_JS_JS_APP_H_
+#define MOJO_APPS_JS_JS_APP_H_
+
+#include "base/memory/ref_counted.h"
+#include "base/single_thread_task_runner.h"
+#include "base/threading/thread.h"
+#include "gin/public/isolate_holder.h"
+#include "gin/shell_runner.h"
+#include "mojo/apps/js/mojo_runner_delegate.h"
+#include "mojo/services/public/interfaces/content_handler/content_handler.mojom.h"
+
+namespace mojo {
+namespace apps {
+
+class JSApp;
+class ApplicationDelegateImpl;
+
+// Adds the "mojo" builtin JS module. Most of the mojo module's methods
+// are defined by JSApp.
+
+class JSAppRunnerDelegate : public MojoRunnerDelegate {
Aaron Boodman 2014/09/11 05:24:53 Why subclass MojoRunnerDelegate? It looks like all
hansmuller 2014/09/11 16:44:44 Good point, I've eliminated the JSAppRunnerDelegat
+ public:
+ JSAppRunnerDelegate(JSApp* js_app);
+};
+
+// Each JavaScript app started by content handler runs on its own thread and
+// in its own V8 isolate. This class represents one running JS app.
+//
+// The lifetime of this class is defined by the content handler's internal
+// "app_vector" list.
+
+class JSApp {
+ public:
+ JSApp(ApplicationDelegateImpl* content_handler_app,
+ const std::string& url,
+ URLResponsePtr content);
+ ~JSApp();
+
+ bool Start();
+ void Quit();
+ Handle ConnectToService(const std::string& application_url,
+ const std::string& interface_name);
+
+ private:
+ void Run();
+ void Terminate();
+
+ // Used to CHECK that we're running on the correct thread.
+ bool on_content_handler_thread() const;
+ bool on_js_app_thread() const;
+
+ ApplicationDelegateImpl* content_handler_app_;
+ std::string url_;
+ URLResponsePtr content_;
+ base::Thread thread_;
+ scoped_refptr<base::SingleThreadTaskRunner> content_handler_task_runner_;
+ scoped_refptr<base::SingleThreadTaskRunner> js_app_task_runner_;
+ JSAppRunnerDelegate runner_delegate_;
+ scoped_ptr<gin::IsolateHolder> isolate_holder_;
+ scoped_ptr<gin::ShellRunner> shell_runner_;
+
+ DISALLOW_COPY_AND_ASSIGN(JSApp);
+};
+
+} // namespace apps
+} // namespace mojo
+
+#endif // MOJO_APPS_JS_JS_APP_H_

Powered by Google App Engine
This is Rietveld 408576698