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

Unified Diff: chrome/renderer/resources/require.js

Issue 9386001: Implement a module system for the extension bindings JS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 9 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
« no previous file with comments | « chrome/renderer/resources/extensions/webstore.js ('k') | chrome/test/base/chrome_render_view_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/resources/require.js
diff --git a/chrome/renderer/resources/require.js b/chrome/renderer/resources/require.js
deleted file mode 100644
index 34f3543a432fe5bcd2348aaf24c2e3b270b0eff9..0000000000000000000000000000000000000000
--- a/chrome/renderer/resources/require.js
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (c) 2012 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.
-
-// This file should define a function that returns a require() method that can
-// be used to load JS modules.
-//
-// A module works the same as modules in node.js - JS script that populates
-// an exports object, which is what require()ers get returned. The JS in a
-// module will be run at most once as the exports result is cached.
-//
-// Modules have access to the require() function which can be used to load
-// other JS dependencies, and requireNative() which returns objects that
-// define native handlers.
-//
-// |bootstrap| contains the following fields:
-// - GetSource(module): returns the source code for |module|
-// - Run(source): runs the string os JS |source|
-// - GetNative(nativeName): returns the named native object
-(function(bootstrap) {
-
-function wrap(source) {
- return "(function(require, requireNative, exports) {" + source +
- "\n})";
-}
-
-function ModuleLoader() {
- this.cache_ = {};
-};
-
-ModuleLoader.prototype.run = function(id) {
- var source = bootstrap.GetSource(id);
- if (!source) {
- return null;
- }
- var wrappedSource = wrap(source);
- var f = bootstrap.Run(wrappedSource);
- var exports = {};
- f(require, requireNative, exports);
- return exports;
-};
-
-ModuleLoader.prototype.load = function(id) {
- var exports = this.cache_[id];
- if (exports) {
- return exports;
- }
- exports = this.run(id);
- this.cache_[id] = exports;
- return exports;
-};
-
-var moduleLoader = new ModuleLoader();
-
-function requireNative(nativeName) {
- return bootstrap.GetNative(nativeName);
-}
-
-function require(moduleId) {
- return moduleLoader.load(moduleId);
-}
-
-return require;
-});
« no previous file with comments | « chrome/renderer/resources/extensions/webstore.js ('k') | chrome/test/base/chrome_render_view_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698