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

Side by Side Diff: chrome/browser/resources/task_manager/main.js

Issue 8873054: Revert 113772 - WebUI TaskManager: Optimize initialization taskmanager and loading scripts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** @constructor */ 5 /** @constructor */
6 function TaskManager() { } 6 function TaskManager() { }
7 7
8 cr.addSingletonGetter(TaskManager); 8 cr.addSingletonGetter(TaskManager);
9 9
10 /* 10 /*
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 * @public 138 * @public
139 */ 139 */
140 initialize: function (dialogDom, opt) { 140 initialize: function (dialogDom, opt) {
141 if (!dialogDom) { 141 if (!dialogDom) {
142 console.log('ERROR: dialogDom is not defined.'); 142 console.log('ERROR: dialogDom is not defined.');
143 return; 143 return;
144 } 144 }
145 145
146 this.opt_ = opt; 146 this.opt_ = opt;
147 147
148 this.initialized_ = true;
148 this.enableTaskManager(); 149 this.enableTaskManager();
149 150
150 this.dialogDom_ = dialogDom; 151 this.dialogDom_ = dialogDom;
151 this.document_ = dialogDom.ownerDocument; 152 this.document_ = dialogDom.ownerDocument;
152 153
153 var ary = this.dialogDom_.querySelectorAll('[visibleif]'); 154 $('close-window').addEventListener('click', this.close.bind(this));
154 for (var i = 0; i < ary.length; i++) { 155 $('kill-process').addEventListener('click', this.killProcess.bind(this));
155 var expr = ary[i].getAttribute('visibleif'); 156 $('about-memory-link').addEventListener('click',
156 if (!eval(expr)) 157 this.openAboutMemory.bind(this));
157 ary[i].hidden = true;
158 }
159 158
160 this.is_column_shown_ = []; 159 this.is_column_shown_ = [];
161 for (var i = 0; i < DEFAULT_COLUMNS.length; i++) { 160 for (var i = 0; i < DEFAULT_COLUMNS.length; i++) {
162 this.is_column_shown_[i] = DEFAULT_COLUMNS[i][3]; 161 this.is_column_shown_[i] = DEFAULT_COLUMNS[i][3];
163 } 162 }
164 163
165 this.localized_column_ = []; 164 this.localized_column_ = [];
166 for (var i = 0; i < DEFAULT_COLUMNS.length; i++) { 165 for (var i = 0; i < DEFAULT_COLUMNS.length; i++) {
167 var column_label_id = DEFAULT_COLUMNS[i][1]; 166 var column_label_id = DEFAULT_COLUMNS[i][1];
168 var localized_label = localStrings.getString(column_label_id); 167 var localized_label = localStrings.getString(column_label_id);
(...skipping 28 matching lines...) Expand all
197 var aValues = a[value_id]; 196 var aValues = a[value_id];
198 var bValues = b[value_id]; 197 var bValues = b[value_id];
199 var aValue = aValues && aValues[0] || 0; 198 var aValue = aValues && aValues[0] || 0;
200 var bvalue = bValues && bValues[0] || 0; 199 var bvalue = bValues && bValues[0] || 0;
201 return dm.defaultValuesCompareFunction(aValue, bvalue); 200 return dm.defaultValuesCompareFunction(aValue, bvalue);
202 }; 201 };
203 }(); 202 }();
204 dm.setCompareFunction(column_id, compare_func); 203 dm.setCompareFunction(column_id, compare_func);
205 } 204 }
206 205
206 var ary = this.dialogDom_.querySelectorAll('[visibleif]');
207 for (var i = 0; i < ary.length; i++) {
208 var expr = ary[i].getAttribute('visibleif');
209 if (!eval(expr))
210 ary[i].hidden = true;
211 }
212
207 this.initTable_(); 213 this.initTable_();
208 this.initialized_ = true;
209
210 loadDelayedIncludes(this);
211 },
212
213 /**
214 * Additional initialization of taskmanager. This function is called when
215 * the loading of delayed scripts finished.
216 * @public
217 */
218 delayedInitialize: function () {
219 $('close-window').addEventListener('click', this.close.bind(this));
220 $('kill-process').addEventListener('click', this.killProcess.bind(this));
221 $('about-memory-link').addEventListener('click',
222 this.openAboutMemory.bind(this));
223 this.initColumnMenu_(); 214 this.initColumnMenu_();
224 this.initTableMenu_(); 215 this.initTableMenu_();
225 216 this.table_.redraw();
226 if (this.delayedInitLabels_) {
227 while (this.delayedInitLabels_.length > 0)
228 this.delayedInitLabels_.pop().call();
229 }
230
231 this.isFinishedInitDelayed_ = true;
232 }, 217 },
233 218
234 initColumnModel_: function () { 219 initColumnModel_: function () {
235 var table_columns = new Array(); 220 var table_columns = new Array();
236 for (var i = 0; i < DEFAULT_COLUMNS.length; i++) { 221 for (var i = 0; i < DEFAULT_COLUMNS.length; i++) {
237 if (!this.is_column_shown_[i]) 222 if (!this.is_column_shown_[i])
238 continue; 223 continue;
239 224
240 var column = DEFAULT_COLUMNS[i]; 225 var column = DEFAULT_COLUMNS[i];
241 table_columns.push(new cr.ui.table.TableColumn(column[0], 226 table_columns.push(new cr.ui.table.TableColumn(column[0],
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 cm.getRenderFunction(i).call(null, dataItem, cm.getId(i), table)); 345 cm.getRenderFunction(i).call(null, dataItem, cm.getId(i), table));
361 346
362 listItem.appendChild(cell); 347 listItem.appendChild(cell);
363 } 348 }
364 listItem.data = dataItem; 349 listItem.data = dataItem;
365 350
366 return listItem; 351 return listItem;
367 }, 352 },
368 353
369 renderColumn_: function(entry, columnId, table) { 354 renderColumn_: function(entry, columnId, table) {
370 this.delayedInitLabels_ = [];
371
372 var container = this.document_.createElement('div'); 355 var container = this.document_.createElement('div');
373 container.className = 'detail-container-' + columnId; 356 container.className = 'detail-container-' + columnId;
374 357
375 if (entry && entry[columnId]) { 358 if (entry && entry[columnId]) {
376 container.id = 'detail-container-' + columnId + '-pid' + entry.processId; 359 container.id = 'detail-container-' + columnId + '-pid' + entry.processId;
377 360
378 for (var i = 0; i < entry[columnId].length; i++) { 361 for (var i = 0; i < entry[columnId].length; i++) {
379 var label = document.createElement('div'); 362 var label = document.createElement('div');
380 if (columnId == 'title') { 363 if (columnId == 'title') {
381 var image = this.document_.createElement('img'); 364 var image = this.document_.createElement('img');
382 image.className = 'detail-title-image'; 365 image.className = 'detail-title-image';
383 image.src = entry['icon'][i]; 366 image.src = entry['icon'][i];
384 label.appendChild(image); 367 label.appendChild(image);
385 var text = this.document_.createElement('div'); 368 var text = this.document_.createElement('div');
386 text.className = 'detail-title-text'; 369 text.className = 'detail-title-text';
387 text.textContent = entry['title'][i]; 370 text.textContent = entry['title'][i];
388 label.appendChild(text); 371 label.appendChild(text);
389 372
390 var addContextMenu = function() { 373 cr.ui.contextMenuHandler.addContextMenuProperty(label);
391 cr.ui.contextMenuHandler.addContextMenuProperty(label); 374 label.contextMenu = this.tableContextMenu_;
392 label.contextMenu = this.tableContextMenu_;
393 };
394
395 if (this.isFinishedInitDelayed_)
396 addContextMenu.call(this);
397 else
398 this.delayedInitLabels_.push(addContextMenu.bind(this));
399 375
400 label.addEventListener('dblclick', (function(uniqueId) { 376 label.addEventListener('dblclick', (function(uniqueId) {
401 this.activatePage(uniqueId); 377 this.activatePage(uniqueId);
402 }).bind(this, entry['uniqueId'][i])); 378 }).bind(this, entry['uniqueId'][i]));
403 379
404 label.data = entry; 380 label.data = entry;
405 label.index_in_group = i; 381 label.index_in_group = i;
406 } else { 382 } else {
407 label.textContent = entry[columnId][i]; 383 label.textContent = entry[columnId][i];
408 } 384 }
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 taskmanager.onTaskChange(start, length, tasks); 569 taskmanager.onTaskChange(start, length, tasks);
594 } 570 }
595 571
596 function taskRemoved(start, length) { 572 function taskRemoved(start, length) {
597 // Sometimes this can get called too early. 573 // Sometimes this can get called too early.
598 if (!taskmanager) 574 if (!taskmanager)
599 return; 575 return;
600 taskmanager.onTaskRemove(start, length); 576 taskmanager.onTaskRemove(start, length);
601 } 577 }
602 578
OLDNEW
« no previous file with comments | « chrome/browser/resources/task_manager/main.html ('k') | chrome/browser/ui/webui/chrome_url_data_manager_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698