OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // Namespace | 5 // Namespace |
6 var importer = importer || {}; | 6 var importer = importer || {}; |
7 | 7 |
8 /** | 8 /** |
9 * A duplicate finder for Google Drive. | 9 * A duplicate finder for Google Drive. |
10 * | 10 * |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 /** @private {!importer.HistoryLoader} */ | 193 /** @private {!importer.HistoryLoader} */ |
194 this.historyLoader_ = historyLoader; | 194 this.historyLoader_ = historyLoader; |
195 | 195 |
196 /** @private {!importer.DriveDuplicateFinder} */ | 196 /** @private {!importer.DriveDuplicateFinder} */ |
197 this.contentMatcher_ = contentMatcher; | 197 this.contentMatcher_ = contentMatcher; |
198 }; | 198 }; |
199 | 199 |
200 /** | 200 /** |
201 * @param {!FileEntry} entry | 201 * @param {!FileEntry} entry |
202 * @param {!importer.Destination} destination | 202 * @param {!importer.Destination} destination |
| 203 * @param {!importer.ScanMode} mode |
203 * @return {!Promise<!importer.Disposition>} | 204 * @return {!Promise<!importer.Disposition>} |
204 */ | 205 */ |
205 importer.DispositionChecker.prototype.getDisposition = | 206 importer.DispositionChecker.prototype.getDisposition = |
206 function(entry, destination) { | 207 function(entry, destination, mode) { |
207 if (destination !== importer.Destination.GOOGLE_DRIVE) { | 208 if (destination !== importer.Destination.GOOGLE_DRIVE) { |
208 return Promise.reject('Unsupported destination: ' + destination); | 209 return Promise.reject('Unsupported destination: ' + destination); |
209 } | 210 } |
210 | 211 |
211 return new Promise( | 212 return new Promise( |
212 /** @this {importer.DispositionChecker} */ | 213 /** @this {importer.DispositionChecker} */ |
213 function(resolve, reject) { | 214 function(resolve, reject) { |
214 this.hasHistoryDuplicate_(entry, destination) | 215 this.hasHistoryDuplicate_(entry, destination) |
215 .then( | 216 .then( |
216 /** | 217 /** |
217 * @param {boolean} duplicate | 218 * @param {boolean} duplicate |
218 * @this {importer.DispositionChecker} | 219 * @this {importer.DispositionChecker} |
219 */ | 220 */ |
220 function(duplicate) { | 221 function(duplicate) { |
221 if (duplicate) { | 222 if (duplicate) { |
222 resolve(importer.Disposition.HISTORY_DUPLICATE); | 223 resolve(importer.Disposition.HISTORY_DUPLICATE); |
223 } else { | 224 return; |
224 this.contentMatcher_.isDuplicate(entry) | 225 } |
225 .then( | 226 if (mode == importer.ScanMode.HISTORY) { |
226 /** @param {boolean} duplicate */ | 227 resolve(importer.Disposition.ORIGINAL); |
227 function(duplicate) { | 228 return; |
228 if (duplicate) { | 229 } |
229 resolve( | 230 this.contentMatcher_.isDuplicate(entry) |
230 importer.Disposition.CONTENT_DUPLICATE); | 231 .then( |
231 } else { | 232 /** @param {boolean} duplicate */ |
232 resolve(importer.Disposition.ORIGINAL); | 233 function(duplicate) { |
233 } | 234 if (duplicate) { |
234 }); | 235 resolve( |
235 } | 236 importer.Disposition.CONTENT_DUPLICATE); |
236 }.bind(this)); | 237 } else { |
| 238 resolve(importer.Disposition.ORIGINAL); |
| 239 } |
| 240 }); |
| 241 }.bind(this)); |
237 }.bind(this)); | 242 }.bind(this)); |
238 }; | 243 }; |
239 | 244 |
240 /** | 245 /** |
241 * @param {!FileEntry} entry | 246 * @param {!FileEntry} entry |
242 * @param {!importer.Destination} destination | 247 * @param {!importer.Destination} destination |
243 * @return {!Promise.<boolean>} True if there is a history-entry-duplicate | 248 * @return {!Promise.<boolean>} True if there is a history-entry-duplicate |
244 * for the file. | 249 * for the file. |
245 * @private | 250 * @private |
246 */ | 251 */ |
(...skipping 20 matching lines...) Expand all Loading... |
267 }); | 272 }); |
268 }.bind(this)); | 273 }.bind(this)); |
269 }; | 274 }; |
270 | 275 |
271 /** | 276 /** |
272 * Factory for a function that returns an entry's disposition. | 277 * Factory for a function that returns an entry's disposition. |
273 * | 278 * |
274 * @param {!importer.HistoryLoader} historyLoader | 279 * @param {!importer.HistoryLoader} historyLoader |
275 * @param {!analytics.Tracker} tracker | 280 * @param {!analytics.Tracker} tracker |
276 * | 281 * |
277 * @return {function(!FileEntry, !importer.Destination): | 282 * @return {function(!FileEntry, !importer.Destination, |
| 283 * !importer.ScanMode): |
278 * !Promise<!importer.Disposition>} | 284 * !Promise<!importer.Disposition>} |
279 */ | 285 */ |
280 importer.DispositionChecker.createChecker = | 286 importer.DispositionChecker.createChecker = |
281 function(historyLoader, tracker) { | 287 function(historyLoader, tracker) { |
282 var checker = new importer.DispositionChecker( | 288 var checker = new importer.DispositionChecker( |
283 historyLoader, | 289 historyLoader, |
284 new importer.DriveDuplicateFinder(tracker)); | 290 new importer.DriveDuplicateFinder(tracker)); |
285 return checker.getDisposition.bind(checker); | 291 return checker.getDisposition.bind(checker); |
286 }; | 292 }; |
OLD | NEW |