OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/appcache/appcache_storage_impl.h" | 5 #include "webkit/appcache/appcache_storage_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 26 matching lines...) Expand all Loading... |
37 // Hard coded default when not using quota management. | 37 // Hard coded default when not using quota management. |
38 static const int kDefaultQuota = 5 * 1024 * 1024; | 38 static const int kDefaultQuota = 5 * 1024 * 1024; |
39 | 39 |
40 static const int kMaxDiskCacheSize = 250 * 1024 * 1024; | 40 static const int kMaxDiskCacheSize = 250 * 1024 * 1024; |
41 static const int kMaxMemDiskCacheSize = 10 * 1024 * 1024; | 41 static const int kMaxMemDiskCacheSize = 10 * 1024 * 1024; |
42 static const FilePath::CharType kDiskCacheDirectoryName[] = | 42 static const FilePath::CharType kDiskCacheDirectoryName[] = |
43 FILE_PATH_LITERAL("Cache"); | 43 FILE_PATH_LITERAL("Cache"); |
44 | 44 |
45 namespace { | 45 namespace { |
46 | 46 |
47 // Helper with no return value for use with base::Bind. | |
48 // TODO(jhawkins): Figure out why base::IgnoreResult does not work for | |
49 // file_util::Delete on Windows. | |
50 void DeleteDirectory(const FilePath& path) { | |
51 file_util::Delete(path, true); | |
52 } | |
53 | |
54 // Helpers for clearing data from the AppCacheDatabase. | 47 // Helpers for clearing data from the AppCacheDatabase. |
55 bool DeleteGroupAndRelatedRecords(AppCacheDatabase* database, | 48 bool DeleteGroupAndRelatedRecords(AppCacheDatabase* database, |
56 int64 group_id, | 49 int64 group_id, |
57 std::vector<int64>* deletable_response_ids) { | 50 std::vector<int64>* deletable_response_ids) { |
58 AppCacheDatabase::CacheRecord cache_record; | 51 AppCacheDatabase::CacheRecord cache_record; |
59 bool success = false; | 52 bool success = false; |
60 if (database->FindCacheForGroup(group_id, &cache_record)) { | 53 if (database->FindCacheForGroup(group_id, &cache_record)) { |
61 database->FindResponseIdsForCacheAsVector(cache_record.cache_id, | 54 database->FindResponseIdsForCacheAsVector(cache_record.cache_id, |
62 deletable_response_ids); | 55 deletable_response_ids); |
63 success = | 56 success = |
(...skipping 1739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1803 AppCacheHistograms::CountInitResult(AppCacheHistograms::DISK_CACHE_ERROR); | 1796 AppCacheHistograms::CountInitResult(AppCacheHistograms::DISK_CACHE_ERROR); |
1804 | 1797 |
1805 // We're unable to open the disk cache, this is a fatal error that we can't | 1798 // We're unable to open the disk cache, this is a fatal error that we can't |
1806 // really recover from. We handle it by disabling the appcache for this | 1799 // really recover from. We handle it by disabling the appcache for this |
1807 // browser session and deleting the directory on disk. The next browser | 1800 // browser session and deleting the directory on disk. The next browser |
1808 // session should start with a clean slate. | 1801 // session should start with a clean slate. |
1809 Disable(); | 1802 Disable(); |
1810 if (!is_incognito_) { | 1803 if (!is_incognito_) { |
1811 VLOG(1) << "Deleting existing appcache data and starting over."; | 1804 VLOG(1) << "Deleting existing appcache data and starting over."; |
1812 db_thread_->PostTask( | 1805 db_thread_->PostTask( |
1813 FROM_HERE, base::Bind(&DeleteDirectory, cache_directory_)); | 1806 FROM_HERE, base::Bind(base::IgnoreResult(&file_util::Delete), |
| 1807 cache_directory_, true)); |
1814 } | 1808 } |
1815 } | 1809 } |
1816 } | 1810 } |
1817 | 1811 |
1818 } // namespace appcache | 1812 } // namespace appcache |
OLD | NEW |