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

Side by Side Diff: ui/file_manager/file_manager/common/js/importer_common.js

Issue 1045663002: Cancel scans when directory changed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also, cancel scans when window closes...and add test coverage. Created 5 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // Shared cloud importer namespace 5 // Shared cloud importer namespace
6 var importer = importer || {}; 6 var importer = importer || {};
7 7
8 /** @enum {string} */ 8 /** @enum {string} */
9 importer.ScanEvent = { 9 importer.ScanEvent = {
10 FINALIZED: 'finalized', 10 FINALIZED: 'finalized',
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 * relatively unique to this machine (among a users machines). 337 * relatively unique to this machine (among a users machines).
338 */ 338 */
339 importer.getMachineId = function() { 339 importer.getMachineId = function() {
340 var storage = importer.ChromeLocalStorage.getInstance(); 340 var storage = importer.ChromeLocalStorage.getInstance();
341 return storage.get(importer.Setting.MACHINE_ID) 341 return storage.get(importer.Setting.MACHINE_ID)
342 .then( 342 .then(
343 function(id) { 343 function(id) {
344 if (id) { 344 if (id) {
345 return id; 345 return id;
346 } 346 }
347 var id = importer.generateMachineId_(); 347 var id = importer.generateId();
348 return storage.set(importer.Setting.MACHINE_ID, id) 348 return storage.set(importer.Setting.MACHINE_ID, id)
349 .then( 349 .then(
350 function() { 350 function() {
351 return id; 351 return id;
352 }); 352 });
353 }); 353 });
354 }; 354 };
355 355
356 /** 356 /**
357 * @return {!Promise<string>} Resolves with the filename of this 357 * @return {!Promise<string>} Resolves with the filename of this
(...skipping 12 matching lines...) Expand all
370 * machines debug log file. 370 * machines debug log file.
371 */ 371 */
372 importer.getDebugLogFilename = function(logId) { 372 importer.getDebugLogFilename = function(logId) {
373 return importer.getMachineId().then( 373 return importer.getMachineId().then(
374 function(machineId) { 374 function(machineId) {
375 return machineId + '-import-debug-' + logId + '.log'; 375 return machineId + '-import-debug-' + logId + '.log';
376 }); 376 });
377 }; 377 };
378 378
379 /** 379 /**
380 * @return {number} A relatively unique six digit integer that is most likely 380 * @return {number} A relatively random six digit integer.
381 * unique to this machine among a user's machines. Used only to segregate
382 * log files on sync storage.
383 */ 381 */
384 importer.generateMachineId_ = function() { 382 importer.generateId = function() {
385 return Math.floor(Math.random() * 899999) + 100000; 383 return Math.floor(Math.random() * 899999) + 100000;
386 }; 384 };
387 385
388 /** 386 /**
389 * @param {number} machineId The machine id for *this* machine. All returned 387 * @param {number} machineId The machine id for *this* machine. All returned
390 * files will have machine ids NOT matching this. 388 * files will have machine ids NOT matching this.
391 * @return {!Promise<!FileEntry>} all history files not having 389 * @return {!Promise<!FileEntry>} all history files not having
392 * a machine id matching {@code machineId}. 390 * a machine id matching {@code machineId}.
393 * @private 391 * @private
394 */ 392 */
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 }); 1089 });
1092 }; 1090 };
1093 1091
1094 /** @private @const {!importer.ChromeLocalStorage} */ 1092 /** @private @const {!importer.ChromeLocalStorage} */
1095 importer.ChromeLocalStorage.INSTANCE_ = new importer.ChromeLocalStorage(); 1093 importer.ChromeLocalStorage.INSTANCE_ = new importer.ChromeLocalStorage();
1096 1094
1097 /** @return {!importer.ChromeLocalStorage} */ 1095 /** @return {!importer.ChromeLocalStorage} */
1098 importer.ChromeLocalStorage.getInstance = function() { 1096 importer.ChromeLocalStorage.getInstance = function() {
1099 return importer.ChromeLocalStorage.INSTANCE_; 1097 return importer.ChromeLocalStorage.INSTANCE_;
1100 }; 1098 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698