| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 } | 276 } |
| 277 | 277 |
| 278 void AppCacheStorageImpl::InitTask::RunCompleted() { | 278 void AppCacheStorageImpl::InitTask::RunCompleted() { |
| 279 storage_->last_group_id_ = last_group_id_; | 279 storage_->last_group_id_ = last_group_id_; |
| 280 storage_->last_cache_id_ = last_cache_id_; | 280 storage_->last_cache_id_ = last_cache_id_; |
| 281 storage_->last_response_id_ = last_response_id_; | 281 storage_->last_response_id_ = last_response_id_; |
| 282 storage_->last_deletable_response_rowid_ = last_deletable_response_rowid_; | 282 storage_->last_deletable_response_rowid_ = last_deletable_response_rowid_; |
| 283 | 283 |
| 284 if (!storage_->is_disabled()) { | 284 if (!storage_->is_disabled()) { |
| 285 storage_->usage_map_.swap(usage_map_); | 285 storage_->usage_map_.swap(usage_map_); |
| 286 const int kDelayMillis = 5 * 60 * 1000; // Five minutes. | 286 const base::TimeDelta kDelay = base::TimeDelta::FromMinutes(5); |
| 287 MessageLoop::current()->PostDelayedTask( | 287 MessageLoop::current()->PostDelayedTask( |
| 288 FROM_HERE, | 288 FROM_HERE, |
| 289 base::Bind(&AppCacheStorageImpl::DelayedStartDeletingUnusedResponses, | 289 base::Bind(&AppCacheStorageImpl::DelayedStartDeletingUnusedResponses, |
| 290 storage_->weak_factory_.GetWeakPtr()), | 290 storage_->weak_factory_.GetWeakPtr()), |
| 291 kDelayMillis); | 291 kDelay); |
| 292 } | 292 } |
| 293 | 293 |
| 294 if (storage_->service()->quota_client()) | 294 if (storage_->service()->quota_client()) |
| 295 storage_->service()->quota_client()->NotifyAppCacheReady(); | 295 storage_->service()->quota_client()->NotifyAppCacheReady(); |
| 296 } | 296 } |
| 297 | 297 |
| 298 // CloseConnectionTask ------- | 298 // CloseConnectionTask ------- |
| 299 | 299 |
| 300 class AppCacheStorageImpl::CloseConnectionTask : public DatabaseTask { | 300 class AppCacheStorageImpl::CloseConnectionTask : public DatabaseTask { |
| 301 public: | 301 public: |
| (...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 did_start_deleting_responses_ = true; | 1565 did_start_deleting_responses_ = true; |
| 1566 deletable_response_ids_.insert( | 1566 deletable_response_ids_.insert( |
| 1567 deletable_response_ids_.end(), | 1567 deletable_response_ids_.end(), |
| 1568 response_ids.begin(), response_ids.end()); | 1568 response_ids.begin(), response_ids.end()); |
| 1569 if (!is_response_deletion_scheduled_) | 1569 if (!is_response_deletion_scheduled_) |
| 1570 ScheduleDeleteOneResponse(); | 1570 ScheduleDeleteOneResponse(); |
| 1571 } | 1571 } |
| 1572 | 1572 |
| 1573 void AppCacheStorageImpl::ScheduleDeleteOneResponse() { | 1573 void AppCacheStorageImpl::ScheduleDeleteOneResponse() { |
| 1574 DCHECK(!is_response_deletion_scheduled_); | 1574 DCHECK(!is_response_deletion_scheduled_); |
| 1575 const int kDelayMillis = 10; | 1575 const base::TimeDelta kDelay = base::TimeDelta::FromMilliseconds(10); |
| 1576 MessageLoop::current()->PostDelayedTask( | 1576 MessageLoop::current()->PostDelayedTask( |
| 1577 FROM_HERE, | 1577 FROM_HERE, |
| 1578 base::Bind(&AppCacheStorageImpl::DeleteOneResponse, | 1578 base::Bind(&AppCacheStorageImpl::DeleteOneResponse, |
| 1579 weak_factory_.GetWeakPtr()), | 1579 weak_factory_.GetWeakPtr()), |
| 1580 kDelayMillis); | 1580 kDelay); |
| 1581 is_response_deletion_scheduled_ = true; | 1581 is_response_deletion_scheduled_ = true; |
| 1582 } | 1582 } |
| 1583 | 1583 |
| 1584 void AppCacheStorageImpl::DeleteOneResponse() { | 1584 void AppCacheStorageImpl::DeleteOneResponse() { |
| 1585 DCHECK(is_response_deletion_scheduled_); | 1585 DCHECK(is_response_deletion_scheduled_); |
| 1586 DCHECK(!deletable_response_ids_.empty()); | 1586 DCHECK(!deletable_response_ids_.empty()); |
| 1587 | 1587 |
| 1588 if (!disk_cache()) { | 1588 if (!disk_cache()) { |
| 1589 DCHECK(is_disabled_); | 1589 DCHECK(is_disabled_); |
| 1590 deletable_response_ids_.clear(); | 1590 deletable_response_ids_.clear(); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1715 Disable(); | 1715 Disable(); |
| 1716 if (!is_incognito_) { | 1716 if (!is_incognito_) { |
| 1717 VLOG(1) << "Deleting existing appcache data and starting over."; | 1717 VLOG(1) << "Deleting existing appcache data and starting over."; |
| 1718 db_thread_->PostTask( | 1718 db_thread_->PostTask( |
| 1719 FROM_HERE, base::Bind(&DeleteDirectory, cache_directory_)); | 1719 FROM_HERE, base::Bind(&DeleteDirectory, cache_directory_)); |
| 1720 } | 1720 } |
| 1721 } | 1721 } |
| 1722 } | 1722 } |
| 1723 | 1723 |
| 1724 } // namespace appcache | 1724 } // namespace appcache |
| OLD | NEW |