| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 }; |
| OLD | NEW |