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 21 matching lines...) Expand all Loading... |
32 #include "webkit/quota/quota_manager.h" | 32 #include "webkit/quota/quota_manager.h" |
33 #include "webkit/quota/special_storage_policy.h" | 33 #include "webkit/quota/special_storage_policy.h" |
34 | 34 |
35 namespace appcache { | 35 namespace appcache { |
36 | 36 |
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 base::FilePath::CharType kDiskCacheDirectoryName[] = |
43 FILE_PATH_LITERAL("Cache"); | 43 FILE_PATH_LITERAL("Cache"); |
44 | 44 |
45 namespace { | 45 namespace { |
46 | 46 |
47 // Helpers for clearing data from the AppCacheDatabase. | 47 // Helpers for clearing data from the AppCacheDatabase. |
48 bool DeleteGroupAndRelatedRecords(AppCacheDatabase* database, | 48 bool DeleteGroupAndRelatedRecords(AppCacheDatabase* database, |
49 int64 group_id, | 49 int64 group_id, |
50 std::vector<int64>* deletable_response_ids) { | 50 std::vector<int64>* deletable_response_ids) { |
51 AppCacheDatabase::CacheRecord cache_record; | 51 AppCacheDatabase::CacheRecord cache_record; |
52 bool success = false; | 52 bool success = false; |
(...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1305 if (database_ && | 1305 if (database_ && |
1306 !db_thread_->PostTask( | 1306 !db_thread_->PostTask( |
1307 FROM_HERE, | 1307 FROM_HERE, |
1308 base::Bind(&ClearSessionOnlyOrigins, database_, | 1308 base::Bind(&ClearSessionOnlyOrigins, database_, |
1309 make_scoped_refptr(service_->special_storage_policy()), | 1309 make_scoped_refptr(service_->special_storage_policy()), |
1310 service()->force_keep_session_state()))) { | 1310 service()->force_keep_session_state()))) { |
1311 delete database_; | 1311 delete database_; |
1312 } | 1312 } |
1313 } | 1313 } |
1314 | 1314 |
1315 void AppCacheStorageImpl::Initialize(const FilePath& cache_directory, | 1315 void AppCacheStorageImpl::Initialize(const base::FilePath& cache_directory, |
1316 base::MessageLoopProxy* db_thread, | 1316 base::MessageLoopProxy* db_thread, |
1317 base::MessageLoopProxy* cache_thread) { | 1317 base::MessageLoopProxy* cache_thread) { |
1318 DCHECK(db_thread); | 1318 DCHECK(db_thread); |
1319 | 1319 |
1320 cache_directory_ = cache_directory; | 1320 cache_directory_ = cache_directory; |
1321 is_incognito_ = cache_directory_.empty(); | 1321 is_incognito_ = cache_directory_.empty(); |
1322 | 1322 |
1323 FilePath db_file_path; | 1323 base::FilePath db_file_path; |
1324 if (!is_incognito_) | 1324 if (!is_incognito_) |
1325 db_file_path = cache_directory_.Append(kAppCacheDatabaseName); | 1325 db_file_path = cache_directory_.Append(kAppCacheDatabaseName); |
1326 database_ = new AppCacheDatabase(db_file_path); | 1326 database_ = new AppCacheDatabase(db_file_path); |
1327 | 1327 |
1328 db_thread_ = db_thread; | 1328 db_thread_ = db_thread; |
1329 cache_thread_ = cache_thread; | 1329 cache_thread_ = cache_thread; |
1330 | 1330 |
1331 scoped_refptr<InitTask> task(new InitTask(this)); | 1331 scoped_refptr<InitTask> task(new InitTask(this)); |
1332 task->Schedule(); | 1332 task->Schedule(); |
1333 } | 1333 } |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1803 if (!is_incognito_) { | 1803 if (!is_incognito_) { |
1804 VLOG(1) << "Deleting existing appcache data and starting over."; | 1804 VLOG(1) << "Deleting existing appcache data and starting over."; |
1805 db_thread_->PostTask( | 1805 db_thread_->PostTask( |
1806 FROM_HERE, base::Bind(base::IgnoreResult(&file_util::Delete), | 1806 FROM_HERE, base::Bind(base::IgnoreResult(&file_util::Delete), |
1807 cache_directory_, true)); | 1807 cache_directory_, true)); |
1808 } | 1808 } |
1809 } | 1809 } |
1810 } | 1810 } |
1811 | 1811 |
1812 } // namespace appcache | 1812 } // namespace appcache |
OLD | NEW |