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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 if (EndsWith(basename, kCRXFileExtension, false /* case-sensitive */)) { | 298 if (EndsWith(basename, kCRXFileExtension, false /* case-sensitive */)) { |
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 = StringToLowerASCII(id); | 308 id = base::StringToLowerASCII(id); |
309 if (!extensions::Extension::IdIsValid(id)) { | 309 if (!extensions::Extension::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 |
(...skipping 165 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 |