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

Unified Diff: services/js/js_app.h

Issue 757703002: Creates a JavaScript Applicaiton (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Do not try to call undefined Application methods. Created 6 years, 1 month 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: services/js/js_app.h
diff --git a/services/js/js_app.h b/services/js/js_app.h
index 22c10d0d9c096a1032abbb1ceae4280212034419..3d1cb09c80323ec9595afccbca903f076794e950 100644
--- a/services/js/js_app.h
+++ b/services/js/js_app.h
@@ -2,19 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef MOJO_SERVICES_JS_JS_APP_H_
-#define MOJO_SERVICES_JS_JS_APP_H_
+#ifndef SERVICES_JS_JS_APP_H_
+#define SERVICES_JS_JS_APP_H_
-#include "base/memory/ref_counted.h"
-#include "base/threading/thread.h"
#include "gin/public/isolate_holder.h"
#include "gin/shell_runner.h"
#include "mojo/application/content_handler_factory.h"
-#include "mojo/edk/js/mojo_runner_delegate.h"
-#include "mojo/public/cpp/application/application_delegate.h"
+#include "mojo/public/cpp/system/message_pipe.h"
#include "mojo/public/interfaces/application/application.mojom.h"
#include "mojo/public/interfaces/application/shell.mojom.h"
-#include "mojo/services/public/interfaces/network/url_loader.mojom.h"
+#include "services/js/js_app_runner_delegate.h"
+#include "v8/include/v8.h"
namespace mojo {
namespace js {
@@ -22,8 +20,8 @@ namespace js {
class JSApp;
class ApplicationDelegateImpl;
-// 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.
+// Each JavaScript app started by the content handler runs on its own thread
+// and in its own V8 isolate. This class represents one running JS app.
class JSApp : public InterfaceImpl<Application>,
public ContentHandlerFactory::HandledApplicationHolder {
@@ -31,31 +29,32 @@ class JSApp : public InterfaceImpl<Application>,
JSApp(ShellPtr shell, URLResponsePtr response);
virtual ~JSApp();
- // Called by the JS mojo module to quit this JS app. See mojo.js.
+ // This method just delegates to shell_->ConnectToApplication().
+ void ConnectToApplication(const std::string& application_url,
+ ScopedMessagePipeHandle service_provider);
+
void Quit();
- // Called by the JS mojo module to connect to a Mojo application.
- MessagePipeHandle ConnectToApplication(const std::string& application_url);
+ private:
+ static const char kMainModuleName[];
- // Called by the JS mojo module to retrieve the ServiceProvider message
- // pipe handle passed to the JS application's AcceptConnection() method.
- MessagePipeHandle RequestorMessagePipeHandle();
+ void OnAppLoaded(std::string url, v8::Handle<v8::Value> module);
- private:
// Application methods:
void AcceptConnection(const String& requestor_url,
ServiceProviderPtr provider) override;
void Initialize(Array<String> args) override;
+ void CallAppInstanceMethod(
+ std::string name, int argc, v8::Handle<v8::Value> argv[]);
abarth-chromium 2014/11/24 23:47:24 const std::string&
hansmuller 2014/11/25 00:31:55 Done.
+
void QuitInternal();
ShellPtr shell_;
- js::MojoRunnerDelegate runner_delegate;
+ JSAppRunnerDelegate runner_delegate_;
gin::IsolateHolder isolate_holder_;
scoped_ptr<gin::ShellRunner> shell_runner_;
- std::string source_;
- std::string file_name_;
- ScopedMessagePipeHandle requestor_handle_;
+ v8::Persistent<v8::Object> app_instance_;
DISALLOW_COPY_AND_ASSIGN(JSApp);
};
@@ -63,4 +62,4 @@ class JSApp : public InterfaceImpl<Application>,
} // namespace js
} // namespace mojo
-#endif // MOJO_SERVICES_JS_JS_APP_H_
+#endif // SERVICES_JS_JS_APP_H_

Powered by Google App Engine
This is Rietveld 408576698