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

Issue 62333018: Implement Asynchronous Module Definition API for Mojo (Closed)

Created:
7 years, 1 month ago by abarth-chromium
Modified:
7 years, 1 month ago
CC:
chromium-reviews, darin (slow to review), slightlyoff
Visibility:
Public.

Description

This CL implements the Asynchronous Module Definition (AMD) API, which we plan to use for JavaScript in Mojo. We don't yet implement every feature in the AMD spec <https://github.com/amdjs/amdjs-api/wiki/AMD>;, but we implement the basic framework, which will let us get started writing and testing JavaScript modules in Mojo. The two other leading choices for a modules system are CommonJS and ES6 modules. We decided not to use CommonJS, despite its popularity, because it implies the ability to load modules synchronously. That works well in server environments like node.js, but it won't work well for Mojo where modules might be loaded across a network. I would really like to have used ES6 modules, but the spec isn't finalized yet and V8 doesn't yet implement them. It's likely that we'll replace this AMD module system with ES6 modules once ES6 modules are ready. Structurally, I've implemented AMD in the ModuleRegistry class in a new "modules" directory in Gin. Nothing else in Gin (except the tests) depends on ModuleRegistry, which means folks are free to use Gin without AMD. At the Mojo layer, I've added a dependency on AMD. BUG=317398 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=235543

Patch Set 1 #

Patch Set 2 : Add missing files #

Patch Set 3 : Almost compiles, leaks memory #

Patch Set 4 : Works!! #

Patch Set 5 : Moar testing #

Total comments: 11

Patch Set 6 : Address Aaron's comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+827 lines, -263 lines) Patch
M gin/arguments.h View 1 chunk +2 lines, -0 lines 0 comments Download
M gin/arguments.cc View 1 chunk +6 lines, -0 lines 0 comments Download
A gin/context_holder.h View 1 2 3 1 chunk +36 lines, -0 lines 0 comments Download
A gin/context_holder.cc View 1 2 3 1 chunk +34 lines, -0 lines 0 comments Download
M gin/converter.h View 1 2 3 4 5 1 chunk +16 lines, -0 lines 0 comments Download
M gin/converter.cc View 1 2 3 4 5 2 chunks +25 lines, -0 lines 0 comments Download
M gin/gin.gyp View 1 2 3 3 chunks +9 lines, -0 lines 0 comments Download
A gin/modules/module_registry.h View 1 2 3 4 5 1 chunk +65 lines, -0 lines 0 comments Download
A gin/modules/module_registry.cc View 1 2 3 4 5 1 chunk +188 lines, -0 lines 0 comments Download
A gin/modules/module_registry_unittests.js View 1 2 3 4 1 chunk +30 lines, -0 lines 0 comments Download
A gin/per_context_data.h View 1 2 3 1 chunk +48 lines, -0 lines 0 comments Download
A gin/per_context_data.cc View 1 2 3 1 chunk +49 lines, -0 lines 0 comments Download
M gin/per_isolate_data.h View 1 2 1 chunk +6 lines, -0 lines 0 comments Download
M gin/per_isolate_data.cc View 1 2 3 chunks +14 lines, -0 lines 0 comments Download
M gin/runner.h View 1 2 3 3 chunks +10 lines, -17 lines 0 comments Download
M gin/runner.cc View 1 2 3 1 chunk +24 lines, -27 lines 0 comments Download
M gin/runner_unittest.cc View 1 2 3 1 chunk +4 lines, -24 lines 0 comments Download
A gin/test/file_runner.h View 1 2 3 1 chunk +30 lines, -0 lines 0 comments Download
A gin/test/file_runner.cc View 1 2 3 4 1 chunk +64 lines, -0 lines 0 comments Download
A gin/test/gtest_unittests.js View 1 2 3 4 1 chunk +11 lines, -0 lines 0 comments Download
A gin/test/run_js_tests.cc View 1 2 3 4 1 chunk +37 lines, -0 lines 0 comments Download
M mojo/mojo.gyp View 1 2 3 4 5 2 chunks +3 lines, -3 lines 0 comments Download
M mojo/public/bindings/js/core_unittests.js View 1 2 3 4 1 chunk +41 lines, -40 lines 0 comments Download
A + mojo/public/bindings/js/global.h View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
A + mojo/public/bindings/js/global.cc View 1 2 3 1 chunk +7 lines, -8 lines 0 comments Download
D mojo/public/bindings/js/mojo.h View 1 2 3 1 chunk +0 lines, -18 lines 0 comments Download
D mojo/public/bindings/js/mojo.cc View 1 2 3 1 chunk +0 lines, -34 lines 0 comments Download
D mojo/public/bindings/js/mojo_unittests.js View 1 2 3 1 chunk +0 lines, -8 lines 0 comments Download
M mojo/public/bindings/js/runner_delegate.h View 1 2 3 1 chunk +3 lines, -1 line 0 comments Download
M mojo/public/bindings/js/runner_delegate.cc View 1 2 3 2 chunks +15 lines, -3 lines 0 comments Download
D mojo/public/bindings/js/test/harness.cc View 1 2 3 1 chunk +0 lines, -79 lines 0 comments Download
A mojo/public/bindings/js/test/run_js_tests.cc View 1 2 3 4 1 chunk +49 lines, -0 lines 0 comments Download

Messages

Total messages: 14 (0 generated)
abarth-chromium
This CL is just a work in progress. I haven't tried building it yet.
7 years, 1 month ago (2013-11-14 02:56:26 UTC) #1
abarth-chromium
This is ready for review, PTAL! Thanks.
7 years, 1 month ago (2013-11-14 23:32:54 UTC) #2
abarth-chromium
7 years, 1 month ago (2013-11-15 00:00:15 UTC) #3
arv (Not doing code reviews)
Nice. Do you also want to add a test that defines a module? define('my-module', ['core'], ...
7 years, 1 month ago (2013-11-15 00:36:46 UTC) #4
abarth-chromium
On 2013/11/15 00:36:46, arv wrote: > Do you also want to add a test that ...
7 years, 1 month ago (2013-11-15 00:37:13 UTC) #5
abarth-chromium
On 2013/11/15 00:37:13, abarth wrote: > On 2013/11/15 00:36:46, arv wrote: > > Do you ...
7 years, 1 month ago (2013-11-15 01:05:18 UTC) #6
Aaron Boodman
https://codereview.chromium.org/62333018/diff/30002/gin/modules/module_registry.cc File gin/modules/module_registry.cc (right): https://codereview.chromium.org/62333018/diff/30002/gin/modules/module_registry.cc#newcode46 gin/modules/module_registry.cc:46: if (!args.GetNext(&factory)) "Factory" seems like a weird name for ...
7 years, 1 month ago (2013-11-15 18:56:05 UTC) #7
Aaron Boodman
lgtm
7 years, 1 month ago (2013-11-15 19:00:59 UTC) #8
abarth-chromium
Thanks for the review. https://codereview.chromium.org/62333018/diff/30002/gin/modules/module_registry.cc File gin/modules/module_registry.cc (right): https://codereview.chromium.org/62333018/diff/30002/gin/modules/module_registry.cc#newcode46 gin/modules/module_registry.cc:46: if (!args.GetNext(&factory)) On 2013/11/15 18:56:06, ...
7 years, 1 month ago (2013-11-15 19:13:36 UTC) #9
Aaron Boodman
still lgtm. I wonder why the amd people chose the name 'factory', but whatevs. https://codereview.chromium.org/62333018/diff/30002/gin/modules/module_registry.h ...
7 years, 1 month ago (2013-11-15 19:54:30 UTC) #10
abarth-chromium
Done. I've left adding the base dependency for a followup CL.
7 years, 1 month ago (2013-11-15 21:26:43 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/abarth@chromium.org/62333018/340001
7 years, 1 month ago (2013-11-15 21:58:26 UTC) #12
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/abarth@chromium.org/62333018/340001
7 years, 1 month ago (2013-11-16 00:26:28 UTC) #13
commit-bot: I haz the power
7 years, 1 month ago (2013-11-17 17:46:10 UTC) #14
Message was sent while issue was closed.
Change committed as 235543

Powered by Google App Engine
This is Rietveld 408576698