OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/sql/connection.h" | 7 #include "app/sql/connection.h" |
8 #include "app/sql/transaction.h" | 8 #include "app/sql/transaction.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 AppCache* newest_cache); | 395 AppCache* newest_cache); |
396 | 396 |
397 virtual void Run(); | 397 virtual void Run(); |
398 virtual void RunCompleted(); | 398 virtual void RunCompleted(); |
399 virtual void CancelCompletion(); | 399 virtual void CancelCompletion(); |
400 | 400 |
401 scoped_refptr<AppCacheGroup> group_; | 401 scoped_refptr<AppCacheGroup> group_; |
402 scoped_refptr<AppCache> cache_; | 402 scoped_refptr<AppCache> cache_; |
403 bool success_; | 403 bool success_; |
404 bool would_exceed_quota_; | 404 bool would_exceed_quota_; |
| 405 int64 quota_override_; |
405 std::vector<int64> newly_deletable_response_ids_; | 406 std::vector<int64> newly_deletable_response_ids_; |
406 }; | 407 }; |
407 | 408 |
408 AppCacheStorageImpl::StoreGroupAndCacheTask::StoreGroupAndCacheTask( | 409 AppCacheStorageImpl::StoreGroupAndCacheTask::StoreGroupAndCacheTask( |
409 AppCacheStorageImpl* storage, AppCacheGroup* group, AppCache* newest_cache) | 410 AppCacheStorageImpl* storage, AppCacheGroup* group, AppCache* newest_cache) |
410 : StoreOrLoadTask(storage), group_(group), cache_(newest_cache), | 411 : StoreOrLoadTask(storage), group_(group), cache_(newest_cache), |
411 success_(false), would_exceed_quota_(false) { | 412 success_(false), would_exceed_quota_(false), |
| 413 quota_override_( |
| 414 storage->GetOriginQuotaInMemory(group->manifest_url().GetOrigin())) { |
412 group_record_.group_id = group->group_id(); | 415 group_record_.group_id = group->group_id(); |
413 group_record_.manifest_url = group->manifest_url(); | 416 group_record_.manifest_url = group->manifest_url(); |
414 group_record_.origin = group_record_.manifest_url.GetOrigin(); | 417 group_record_.origin = group_record_.manifest_url.GetOrigin(); |
415 newest_cache->ToDatabaseRecords( | 418 newest_cache->ToDatabaseRecords( |
416 group, | 419 group, |
417 &cache_record_, &entry_records_, &fallback_namespace_records_, | 420 &cache_record_, &entry_records_, &fallback_namespace_records_, |
418 &online_whitelist_records_); | 421 &online_whitelist_records_); |
419 } | 422 } |
420 | 423 |
421 void AppCacheStorageImpl::StoreGroupAndCacheTask::Run() { | 424 void AppCacheStorageImpl::StoreGroupAndCacheTask::Run() { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 success_ = | 481 success_ = |
479 success_ && | 482 success_ && |
480 database_->InsertCache(&cache_record_) && | 483 database_->InsertCache(&cache_record_) && |
481 database_->InsertEntryRecords(entry_records_) && | 484 database_->InsertEntryRecords(entry_records_) && |
482 database_->InsertFallbackNameSpaceRecords(fallback_namespace_records_)&& | 485 database_->InsertFallbackNameSpaceRecords(fallback_namespace_records_)&& |
483 database_->InsertOnlineWhiteListRecords(online_whitelist_records_); | 486 database_->InsertOnlineWhiteListRecords(online_whitelist_records_); |
484 | 487 |
485 if (!success_) | 488 if (!success_) |
486 return; | 489 return; |
487 | 490 |
488 if (database_->GetOriginUsage(group_record_.origin) > | 491 int64 quota = (quota_override_ >= 0) ? |
489 database_->GetOriginQuota(group_record_.origin)) { | 492 quota_override_ : |
| 493 database_->GetOriginQuota(group_record_.origin); |
| 494 |
| 495 if (database_->GetOriginUsage(group_record_.origin) > quota) { |
490 would_exceed_quota_ = true; | 496 would_exceed_quota_ = true; |
491 success_ = false; | 497 success_ = false; |
492 return; | 498 return; |
493 } | 499 } |
494 | 500 |
495 success_ = transaction.Commit(); | 501 success_ = transaction.Commit(); |
496 } | 502 } |
497 | 503 |
498 void AppCacheStorageImpl::StoreGroupAndCacheTask::RunCompleted() { | 504 void AppCacheStorageImpl::StoreGroupAndCacheTask::RunCompleted() { |
499 if (success_) { | 505 if (success_) { |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 Disable(); | 1319 Disable(); |
1314 if (!is_incognito_) { | 1320 if (!is_incognito_) { |
1315 LOG(INFO) << "Deleting existing appcache data and starting over."; | 1321 LOG(INFO) << "Deleting existing appcache data and starting over."; |
1316 AppCacheThread::PostTask(AppCacheThread::db(), FROM_HERE, | 1322 AppCacheThread::PostTask(AppCacheThread::db(), FROM_HERE, |
1317 NewRunnableFunction(DeleteDirectory, cache_directory_)); | 1323 NewRunnableFunction(DeleteDirectory, cache_directory_)); |
1318 } | 1324 } |
1319 } | 1325 } |
1320 } | 1326 } |
1321 | 1327 |
1322 } // namespace appcache | 1328 } // namespace appcache |
OLD | NEW |