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/files/file_enumerator.h" | 8 #include "base/files/file_enumerator.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 // Skip flag file that indicates that cache is ready. | 414 // Skip flag file that indicates that cache is ready. |
415 if (basename == kCacheReadyFlagFileName) | 415 if (basename == kCacheReadyFlagFileName) |
416 continue; | 416 continue; |
417 | 417 |
418 // crx files in the cache are named | 418 // crx files in the cache are named |
419 // <extension-id>-<version>[-<expected_hash>].crx. | 419 // <extension-id>-<version>[-<expected_hash>].crx. |
420 std::string id; | 420 std::string id; |
421 std::string version; | 421 std::string version; |
422 std::string expected_hash; | 422 std::string expected_hash; |
423 if (base::EndsWith(basename, kCRXFileExtension, | 423 if (base::EndsWith(basename, kCRXFileExtension, |
424 false /* case-sensitive */)) { | 424 base::CompareCase::INSENSITIVE_ASCII)) { |
425 size_t n = basename.find('-'); | 425 size_t n = basename.find('-'); |
426 if (n != std::string::npos && n + 1 < basename.size() - 4) { | 426 if (n != std::string::npos && n + 1 < basename.size() - 4) { |
427 id = basename.substr(0, n); | 427 id = basename.substr(0, n); |
428 // Size of |version| = total size - "<id>" - "-" - ".crx" | 428 // Size of |version| = total size - "<id>" - "-" - ".crx" |
429 version = basename.substr(n + 1, basename.size() - 5 - id.size()); | 429 version = basename.substr(n + 1, basename.size() - 5 - id.size()); |
430 | 430 |
431 n = version.find('-'); | 431 n = version.find('-'); |
432 if (n != std::string::npos && n + 1 < version.size()) { | 432 if (n != std::string::npos && n + 1 < version.size()) { |
433 expected_hash = version.substr(n + 1, version.size() - n - 1); | 433 expected_hash = version.substr(n + 1, version.size() - n - 1); |
434 version.resize(n); | 434 version.resize(n); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 expected_hash(base::StringToLowerASCII(expected_hash)), | 615 expected_hash(base::StringToLowerASCII(expected_hash)), |
616 last_used(last_used), | 616 last_used(last_used), |
617 size(size), | 617 size(size), |
618 file_path(file_path) { | 618 file_path(file_path) { |
619 } | 619 } |
620 | 620 |
621 LocalExtensionCache::CacheItemInfo::~CacheItemInfo() { | 621 LocalExtensionCache::CacheItemInfo::~CacheItemInfo() { |
622 } | 622 } |
623 | 623 |
624 } // namespace extensions | 624 } // namespace extensions |
OLD | NEW |