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

Side by Side Diff: ios/web/webui/resources/web_ui_module_load_notifier.js

Issue 1929783002: [ios Mojo] Supporting code for define WebUI function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo_require_js
Patch Set: Merged with require.js CL Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « ios/web/webui/resources/web_ui_bundle.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 goog.provide('__crWeb.webUIModuleLoadNotifier');
6
7 /**
8 * A holder class for require.js contexts whose load is pending.
9 * @constructor
10 */
11 var WebUIModuleLoadNotifier = function() {
12 this.lastUsedId_ = 0;
13 this.pendingContexts_ = {};
14 };
15
16 /**
17 * Adds the given context to the list of pending contexts.
18 * @param {string} name Name of the module that will be loaded.
19 * @param {Object} context Require.js context to hold.
20 * @return {String} Identifier for the added context, can be later used for
dpapad 2016/04/28 22:29:20 s/String/string/
Eugene But (OOO till 7-30) 2016/04/29 00:10:41 Done.
21 * {@code moduleLoadCompleted} and {@code moduleLoadFailed} arguments.
22 */
23 WebUIModuleLoadNotifier.prototype.addPendingContext = function(name, context) {
24 var loadId = this.lastUsedId_ + 1;
25 this.lastUsedId_ = loadId;
dpapad 2016/04/28 22:29:20 I am confused by lines 24-25, it seems that loadId
dpapad 2016/04/28 22:29:20 I am confused by lines 24-25, it seems that loadId
Eugene But (OOO till 7-30) 2016/04/29 00:10:41 Done.
26 var key = name + loadId;
27 this.pendingContexts_[key] = context;
28 return String(loadId);
29 }
dpapad 2016/04/28 22:29:20 Nit: Semicolon missing, here and elsewhere.
30
31 /**
32 * Signals that module has successfully loaded.
33 * @param {string} name Name of the module that has been loaded.
34 * @param {String} loadId Identifier returned from {@code addPendingContext}.
35 */
36 WebUIModuleLoadNotifier.prototype.moduleLoadCompleted = function(name, loadId) {
37 this.popContext_(name, loadId).completeLoad(name);
38 }
39
40 /**
41 * Signals that module has failed to load.
42 * @param {string} name Name of the module that has failed to load.
43 * @param {String} loadId Identifier returned from {@code addPendingContext}.
44 */
45 WebUIModuleLoadNotifier.prototype.moduleLoadFailed = function(name, loadId) {
46 this.popContext_(name, loadId).onScriptFailure(name);
47 }
48
49 WebUIModuleLoadNotifier.prototype.popContext_ = function(name, loadId) {
50 var key = name + loadId;
51 var context = this.pendingContexts_[key];
52 delete this.pendingContexts_[key];
53 return context;
54 }
OLDNEW
« no previous file with comments | « ios/web/webui/resources/web_ui_bundle.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698