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" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/sys_info.h" | 12 #include "base/sys_info.h" |
13 #include "base/version.h" | 13 #include "base/version.h" |
| 14 #include "components/crx_file/id_util.h" |
14 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
15 #include "extensions/common/extension.h" | |
16 | 16 |
17 namespace extensions { | 17 namespace extensions { |
18 namespace { | 18 namespace { |
19 | 19 |
20 // File name extension for CRX files (not case sensitive). | 20 // File name extension for CRX files (not case sensitive). |
21 const char kCRXFileExtension[] = ".crx"; | 21 const char kCRXFileExtension[] = ".crx"; |
22 | 22 |
23 // Delay between checks for flag file presence when waiting for the cache to | 23 // Delay between checks for flag file presence when waiting for the cache to |
24 // become ready. | 24 // become ready. |
25 const int64_t kCacheStatusPollingDelayMs = 1000; | 25 const int64_t kCacheStatusPollingDelayMs = 1000; |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 size_t n = basename.find('-'); | 299 size_t n = basename.find('-'); |
300 if (n != std::string::npos && n + 1 < basename.size() - 4) { | 300 if (n != std::string::npos && n + 1 < basename.size() - 4) { |
301 id = basename.substr(0, n); | 301 id = basename.substr(0, n); |
302 // Size of |version| = total size - "<id>" - "-" - ".crx" | 302 // Size of |version| = total size - "<id>" - "-" - ".crx" |
303 version = basename.substr(n + 1, basename.size() - 5 - id.size()); | 303 version = basename.substr(n + 1, basename.size() - 5 - id.size()); |
304 } | 304 } |
305 } | 305 } |
306 | 306 |
307 // Enforce a lower-case id. | 307 // Enforce a lower-case id. |
308 id = base::StringToLowerASCII(id); | 308 id = base::StringToLowerASCII(id); |
309 if (!extensions::Extension::IdIsValid(id)) { | 309 if (!crx_file::id_util::IdIsValid(id)) { |
310 LOG(ERROR) << "Bad extension id in cache: " << id; | 310 LOG(ERROR) << "Bad extension id in cache: " << id; |
311 id.clear(); | 311 id.clear(); |
312 } | 312 } |
313 | 313 |
314 if (!Version(version).IsValid()) { | 314 if (!Version(version).IsValid()) { |
315 LOG(ERROR) << "Bad extension version in cache: " << version; | 315 LOG(ERROR) << "Bad extension version in cache: " << version; |
316 version.clear(); | 316 version.clear(); |
317 } | 317 } |
318 | 318 |
319 if (id.empty() || version.empty()) { | 319 if (id.empty() || version.empty()) { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 | 484 |
485 LocalExtensionCache::CacheItemInfo::CacheItemInfo( | 485 LocalExtensionCache::CacheItemInfo::CacheItemInfo( |
486 const std::string& version, | 486 const std::string& version, |
487 const base::Time& last_used, | 487 const base::Time& last_used, |
488 uint64 size, | 488 uint64 size, |
489 const base::FilePath& file_path) | 489 const base::FilePath& file_path) |
490 : version(version), last_used(last_used), size(size), file_path(file_path) { | 490 : version(version), last_used(last_used), size(size), file_path(file_path) { |
491 } | 491 } |
492 | 492 |
493 } // namespace extensions | 493 } // namespace extensions |
OLD | NEW |