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 #include "chrome/browser/extensions/updater/local_extension_cache.h" | 5 #include "chrome/browser/extensions/updater/local_extension_cache.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_enumerator.h" | 9 #include "base/files/file_enumerator.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 | 419 |
420 CacheMap::iterator it = cached_extensions_.find(id); | 420 CacheMap::iterator it = cached_extensions_.find(id); |
421 if (it != cached_extensions_.end()) { | 421 if (it != cached_extensions_.end()) { |
422 Version new_version(info.version); | 422 Version new_version(info.version); |
423 Version prev_version(it->second.version); | 423 Version prev_version(it->second.version); |
424 if (new_version.CompareTo(prev_version) <= 0) { | 424 if (new_version.CompareTo(prev_version) <= 0) { |
425 DCHECK(0) << "Cache contains newer or the same version"; | 425 DCHECK(0) << "Cache contains newer or the same version"; |
426 callback.Run(info.file_path, true); | 426 callback.Run(info.file_path, true); |
427 return; | 427 return; |
428 } | 428 } |
| 429 it->second = info; |
| 430 } else { |
| 431 it = cached_extensions_.insert(std::make_pair(id, info)).first; |
429 } | 432 } |
430 it = cached_extensions_.insert(std::make_pair(id, info)).first; | |
431 // Time from file system can have lower precision so use precise "now". | 433 // Time from file system can have lower precision so use precise "now". |
432 it->second.last_used = base::Time::Now(); | 434 it->second.last_used = base::Time::Now(); |
433 | 435 |
434 callback.Run(info.file_path, false); | 436 callback.Run(info.file_path, false); |
435 } | 437 } |
436 | 438 |
437 // static | 439 // static |
438 void LocalExtensionCache::BackendRemoveCacheEntry( | 440 void LocalExtensionCache::BackendRemoveCacheEntry( |
439 const base::FilePath& file_path) { | 441 const base::FilePath& file_path) { |
440 base::DeleteFile(file_path, true /* recursive */); | 442 base::DeleteFile(file_path, true /* recursive */); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 | 475 |
474 LocalExtensionCache::CacheItemInfo::CacheItemInfo( | 476 LocalExtensionCache::CacheItemInfo::CacheItemInfo( |
475 const std::string& version, | 477 const std::string& version, |
476 const base::Time& last_used, | 478 const base::Time& last_used, |
477 uint64 size, | 479 uint64 size, |
478 const base::FilePath& file_path) | 480 const base::FilePath& file_path) |
479 : version(version), last_used(last_used), size(size), file_path(file_path) { | 481 : version(version), last_used(last_used), size(size), file_path(file_path) { |
480 } | 482 } |
481 | 483 |
482 } // namespace extensions | 484 } // namespace extensions |
OLD | NEW |