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

Unified Diff: chrome/browser/resources/task_manager/includes.js

Issue 8713016: WebUI TaskManager: Optimize initialization taskmanager and loading scripts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge with master Created 9 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: chrome/browser/resources/task_manager/includes.js
diff --git a/chrome/browser/resources/task_manager/includes.js b/chrome/browser/resources/task_manager/includes.js
index 75708b12c5929a0de7e0b4302400072f983d8e16..99c6e25761ec39dbfa1596ad55f4f2459446ef9d 100644
--- a/chrome/browser/resources/task_manager/includes.js
+++ b/chrome/browser/resources/task_manager/includes.js
@@ -2,44 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// This script includes additional resources via document.write(). Hence, it
-// must be a separate script file loaded before other scripts which would
-// reference the resources.
-
-var css = [
- 'chrome_shared.css',
- 'list.css',
- 'table.css',
- 'menu.css',
- 'button.css',
-];
+// This script loads additional scripts after initialize of task manager.
var script = [
- 'local_strings.js',
- 'i18n_template.js',
-
- 'util.js',
- 'cr.js',
- 'cr/ui.js',
- 'cr/event_target.js',
- 'cr/ui/array_data_model.js',
- 'cr/ui/list_item.js',
- 'cr/ui/list_selection_model.js',
- 'cr/ui/list_single_selection_model.js',
- 'cr/ui/list_selection_controller.js',
- 'cr/ui/list.js',
-
- 'cr/ui/splitter.js',
- 'cr/ui/table/table_splitter.js',
-
- 'cr/ui/table/table_column.js',
- 'cr/ui/table/table_column_model.js',
- 'cr/ui/table/table_header.js',
- 'cr/ui/table/table_list.js',
- 'cr/ui/table.js',
-
- 'cr/ui/grid.js',
-
'cr/ui/command.js',
'cr/ui/position_util.js',
'cr/ui/menu_item.js',
@@ -47,6 +12,8 @@ var script = [
'cr/ui/context_menu_handler.js',
];
+var isLoading = script.length;
mazda 2011/11/30 12:05:54 It's better to rename the variable to something th
+
(function() {
// Switch to 'test harness' mode when loading from a file url.
var isHarness = document.location.protocol == 'file:';
@@ -54,13 +21,25 @@ var script = [
// In test harness mode we load resources from relative dirs.
var prefix = isHarness ? './shared/' : 'chrome://resources/';
- for (var i = 0; i < css.length; ++i) {
- document.write('<link href="' + prefix + 'css/' + css[i] +
- '" rel="stylesheet"></link>');
- }
-
- for (var i = 0; i < script.length; ++i) {
- document.write('<script src="' + prefix + 'js/' + script[i] +
- '"><\/script>');
- }
+ // Waits for initialize of task manager.
mazda 2011/11/30 12:05:54 initialize -> initialization Please add a comment
yoshiki 2011/12/01 16:18:25 Done.
+ var loadDelayedScripts = function() {
+ if (taskmanager !== undefined && taskmanager.initialized_) {
+ for (var i = 0; i < script.length; ++i) {
+ var src = prefix + 'js/' + script[i];
mazda 2011/11/30 12:05:54 It's better to assign the value directly to s.src
+ var s = document.createElement('script');
+ s.onLoad = function(e) {
+ isLoading--; if(isLoading == 0) taskmanager.delayedInitialize();
mazda 2011/11/30 12:05:54 Please add line breaks. Also need a space after 'i
+ console.log("aaa" + e.target.src);
mazda 2011/11/30 12:05:54 Remove this.
+ };
+ s.type = 'text/javascript';
+ s.src = src;
+ s.defer = 'defer';
+ document.body.appendChild(s);
+ console.log("hogehoge" + src);
mazda 2011/11/30 12:05:54 Remove this.
+ }
+ } else {
+ window.setTimeout(loadDelayedScripts, 100);
mazda 2011/11/30 12:05:54 Please make a constant variable for 100.
+ }
+ };
+ window.setTimeout(loadDelayedScripts, 100);
mazda 2011/11/30 12:05:54 Ditto.
})();

Powered by Google App Engine
This is Rietveld 408576698