OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/quota/quota_manager.h" | 5 #include "storage/browser/quota/quota_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <deque> | 8 #include <deque> |
9 #include <functional> | 9 #include <functional> |
10 #include <set> | 10 #include <set> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/file_util.h" | 16 #include "base/file_util.h" |
17 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
18 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
19 #include "base/sequenced_task_runner.h" | 19 #include "base/sequenced_task_runner.h" |
20 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
22 #include "base/sys_info.h" | 22 #include "base/sys_info.h" |
23 #include "base/task_runner_util.h" | 23 #include "base/task_runner_util.h" |
24 #include "base/time/time.h" | 24 #include "base/time/time.h" |
25 #include "net/base/net_util.h" | 25 #include "net/base/net_util.h" |
26 #include "webkit/browser/quota/quota_database.h" | 26 #include "storage/browser/quota/quota_database.h" |
27 #include "webkit/browser/quota/quota_manager_proxy.h" | 27 #include "storage/browser/quota/quota_manager_proxy.h" |
28 #include "webkit/browser/quota/quota_temporary_storage_evictor.h" | 28 #include "storage/browser/quota/quota_temporary_storage_evictor.h" |
29 #include "webkit/browser/quota/storage_monitor.h" | 29 #include "storage/browser/quota/storage_monitor.h" |
30 #include "webkit/browser/quota/usage_tracker.h" | 30 #include "storage/browser/quota/usage_tracker.h" |
31 #include "webkit/common/quota/quota_types.h" | 31 #include "storage/common/quota/quota_types.h" |
32 | 32 |
33 #define UMA_HISTOGRAM_MBYTES(name, sample) \ | 33 #define UMA_HISTOGRAM_MBYTES(name, sample) \ |
34 UMA_HISTOGRAM_CUSTOM_COUNTS( \ | 34 UMA_HISTOGRAM_CUSTOM_COUNTS((name), \ |
35 (name), static_cast<int>((sample) / kMBytes), \ | 35 static_cast<int>((sample) / kMBytes), \ |
36 1, 10 * 1024 * 1024 /* 10TB */, 100) | 36 1, \ |
| 37 10 * 1024 * 1024 /* 10TB */, \ |
| 38 100) |
37 | 39 |
38 namespace quota { | 40 namespace quota { |
39 | 41 |
40 namespace { | 42 namespace { |
41 | 43 |
42 const int64 kMBytes = 1024 * 1024; | 44 const int64 kMBytes = 1024 * 1024; |
43 const int kMinutesInMilliSeconds = 60 * 1000; | 45 const int kMinutesInMilliSeconds = 60 * 1000; |
44 | 46 |
45 const int64 kReportHistogramInterval = 60 * 60 * 1000; // 1 hour | 47 const int64 kReportHistogramInterval = 60 * 60 * 1000; // 1 hour |
46 const double kTemporaryQuotaRatioToAvail = 1.0 / 3.0; // 33% | 48 const double kTemporaryQuotaRatioToAvail = 1.0 / 3.0; // 33% |
47 | 49 |
48 } // namespace | 50 } // namespace |
49 | 51 |
50 // Arbitrary for now, but must be reasonably small so that | 52 // Arbitrary for now, but must be reasonably small so that |
51 // in-memory databases can fit. | 53 // in-memory databases can fit. |
52 // TODO(kinuko): Refer SysInfo::AmountOfPhysicalMemory() to determine this. | 54 // TODO(kinuko): Refer SysInfo::AmountOfPhysicalMemory() to determine this. |
53 const int64 QuotaManager::kIncognitoDefaultQuotaLimit = 100 * kMBytes; | 55 const int64 QuotaManager::kIncognitoDefaultQuotaLimit = 100 * kMBytes; |
54 | 56 |
55 const int64 QuotaManager::kNoLimit = kint64max; | 57 const int64 QuotaManager::kNoLimit = kint64max; |
56 | 58 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 if (policy->IsStorageProtected(*itr)) | 101 if (policy->IsStorageProtected(*itr)) |
100 ++*protected_origins; | 102 ++*protected_origins; |
101 if (policy->IsStorageUnlimited(*itr)) | 103 if (policy->IsStorageUnlimited(*itr)) |
102 ++*unlimited_origins; | 104 ++*unlimited_origins; |
103 } | 105 } |
104 } | 106 } |
105 | 107 |
106 bool SetTemporaryGlobalOverrideQuotaOnDBThread(int64* new_quota, | 108 bool SetTemporaryGlobalOverrideQuotaOnDBThread(int64* new_quota, |
107 QuotaDatabase* database) { | 109 QuotaDatabase* database) { |
108 DCHECK(database); | 110 DCHECK(database); |
109 if (!database->SetQuotaConfigValue( | 111 if (!database->SetQuotaConfigValue(QuotaDatabase::kTemporaryQuotaOverrideKey, |
110 QuotaDatabase::kTemporaryQuotaOverrideKey, *new_quota)) { | 112 *new_quota)) { |
111 *new_quota = -1; | 113 *new_quota = -1; |
112 return false; | 114 return false; |
113 } | 115 } |
114 return true; | 116 return true; |
115 } | 117 } |
116 | 118 |
117 bool GetPersistentHostQuotaOnDBThread(const std::string& host, | 119 bool GetPersistentHostQuotaOnDBThread(const std::string& host, |
118 int64* quota, | 120 int64* quota, |
119 QuotaDatabase* database) { | 121 QuotaDatabase* database) { |
120 DCHECK(database); | 122 DCHECK(database); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 216 |
215 void DispatchTemporaryGlobalQuotaCallback( | 217 void DispatchTemporaryGlobalQuotaCallback( |
216 const QuotaCallback& callback, | 218 const QuotaCallback& callback, |
217 QuotaStatusCode status, | 219 QuotaStatusCode status, |
218 const UsageAndQuota& usage_and_quota) { | 220 const UsageAndQuota& usage_and_quota) { |
219 if (status != kQuotaStatusOk) { | 221 if (status != kQuotaStatusOk) { |
220 callback.Run(status, 0); | 222 callback.Run(status, 0); |
221 return; | 223 return; |
222 } | 224 } |
223 | 225 |
224 callback.Run(status, CalculateTemporaryGlobalQuota( | 226 callback.Run( |
225 usage_and_quota.global_limited_usage, | 227 status, |
226 usage_and_quota.available_disk_space)); | 228 CalculateTemporaryGlobalQuota(usage_and_quota.global_limited_usage, |
| 229 usage_and_quota.available_disk_space)); |
227 } | 230 } |
228 | 231 |
229 int64 CalculateQuotaWithDiskSpace( | 232 int64 CalculateQuotaWithDiskSpace(int64 available_disk_space, |
230 int64 available_disk_space, int64 usage, int64 quota) { | 233 int64 usage, |
| 234 int64 quota) { |
231 if (available_disk_space < QuotaManager::kMinimumPreserveForSystem) { | 235 if (available_disk_space < QuotaManager::kMinimumPreserveForSystem) { |
232 LOG(WARNING) | 236 LOG(WARNING) |
233 << "Running out of disk space for profile." | 237 << "Running out of disk space for profile." |
234 << " QuotaManager starts forbidding further quota consumption."; | 238 << " QuotaManager starts forbidding further quota consumption."; |
235 return usage; | 239 return usage; |
236 } | 240 } |
237 | 241 |
238 if (quota < usage) { | 242 if (quota < usage) { |
239 // No more space; cap the quota to the current usage. | 243 // No more space; cap the quota to the current usage. |
240 return usage; | 244 return usage; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 quota = std::min(quota, QuotaManager::kIncognitoDefaultQuotaLimit); | 286 quota = std::min(quota, QuotaManager::kIncognitoDefaultQuotaLimit); |
283 callback.Run(status, usage, quota); | 287 callback.Run(status, usage, quota); |
284 return; | 288 return; |
285 } | 289 } |
286 | 290 |
287 // For apps with unlimited permission or can_query_disk_size is true (and not | 291 // For apps with unlimited permission or can_query_disk_size is true (and not |
288 // in incognito mode). | 292 // in incognito mode). |
289 // We assume we can expose the actual disk size for them and cap the quota by | 293 // We assume we can expose the actual disk size for them and cap the quota by |
290 // the available disk space. | 294 // the available disk space. |
291 if (is_unlimited || can_query_disk_size) { | 295 if (is_unlimited || can_query_disk_size) { |
292 callback.Run( | 296 callback.Run(status, |
293 status, usage, | 297 usage, |
294 CalculateQuotaWithDiskSpace( | 298 CalculateQuotaWithDiskSpace( |
295 usage_and_quota.available_disk_space, | 299 usage_and_quota.available_disk_space, usage, quota)); |
296 usage, quota)); | |
297 return; | 300 return; |
298 } | 301 } |
299 | 302 |
300 callback.Run(status, usage, quota); | 303 callback.Run(status, usage, quota); |
301 } | 304 } |
302 | 305 |
303 } // namespace | 306 } // namespace |
304 | 307 |
305 UsageAndQuota::UsageAndQuota() | 308 UsageAndQuota::UsageAndQuota() |
306 : usage(0), | 309 : usage(0), global_limited_usage(0), quota(0), available_disk_space(0) { |
307 global_limited_usage(0), | |
308 quota(0), | |
309 available_disk_space(0) { | |
310 } | 310 } |
311 | 311 |
312 UsageAndQuota::UsageAndQuota( | 312 UsageAndQuota::UsageAndQuota(int64 usage, |
313 int64 usage, | 313 int64 global_limited_usage, |
314 int64 global_limited_usage, | 314 int64 quota, |
315 int64 quota, | 315 int64 available_disk_space) |
316 int64 available_disk_space) | |
317 : usage(usage), | 316 : usage(usage), |
318 global_limited_usage(global_limited_usage), | 317 global_limited_usage(global_limited_usage), |
319 quota(quota), | 318 quota(quota), |
320 available_disk_space(available_disk_space) { | 319 available_disk_space(available_disk_space) { |
321 } | 320 } |
322 | 321 |
323 class UsageAndQuotaCallbackDispatcher | 322 class UsageAndQuotaCallbackDispatcher |
324 : public QuotaTask, | 323 : public QuotaTask, |
325 public base::SupportsWeakPtr<UsageAndQuotaCallbackDispatcher> { | 324 public base::SupportsWeakPtr<UsageAndQuotaCallbackDispatcher> { |
326 public: | 325 public: |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 QuotaStatusCode status_; | 457 QuotaStatusCode status_; |
459 UsageAndQuota usage_and_quota_; | 458 UsageAndQuota usage_and_quota_; |
460 QuotaManager::UsageAndQuotaCallback callback_; | 459 QuotaManager::UsageAndQuotaCallback callback_; |
461 int waiting_callbacks_; | 460 int waiting_callbacks_; |
462 | 461 |
463 DISALLOW_COPY_AND_ASSIGN(UsageAndQuotaCallbackDispatcher); | 462 DISALLOW_COPY_AND_ASSIGN(UsageAndQuotaCallbackDispatcher); |
464 }; | 463 }; |
465 | 464 |
466 class QuotaManager::GetUsageInfoTask : public QuotaTask { | 465 class QuotaManager::GetUsageInfoTask : public QuotaTask { |
467 public: | 466 public: |
468 GetUsageInfoTask( | 467 GetUsageInfoTask(QuotaManager* manager, const GetUsageInfoCallback& callback) |
469 QuotaManager* manager, | 468 : QuotaTask(manager), callback_(callback), weak_factory_(this) {} |
470 const GetUsageInfoCallback& callback) | |
471 : QuotaTask(manager), | |
472 callback_(callback), | |
473 weak_factory_(this) { | |
474 } | |
475 | 469 |
476 protected: | 470 protected: |
477 virtual void Run() OVERRIDE { | 471 virtual void Run() OVERRIDE { |
478 remaining_trackers_ = 3; | 472 remaining_trackers_ = 3; |
479 // This will populate cached hosts and usage info. | 473 // This will populate cached hosts and usage info. |
480 manager()->GetUsageTracker(kStorageTypeTemporary)->GetGlobalUsage( | 474 manager()->GetUsageTracker(kStorageTypeTemporary)->GetGlobalUsage( |
481 base::Bind(&GetUsageInfoTask::DidGetGlobalUsage, | 475 base::Bind(&GetUsageInfoTask::DidGetGlobalUsage, |
482 weak_factory_.GetWeakPtr(), | 476 weak_factory_.GetWeakPtr(), |
483 kStorageTypeTemporary)); | 477 kStorageTypeTemporary)); |
484 manager()->GetUsageTracker(kStorageTypePersistent)->GetGlobalUsage( | 478 manager()->GetUsageTracker(kStorageTypePersistent)->GetGlobalUsage( |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 remaining_clients_(-1), | 540 remaining_clients_(-1), |
547 skipped_clients_(0), | 541 skipped_clients_(0), |
548 callback_(callback), | 542 callback_(callback), |
549 weak_factory_(this) {} | 543 weak_factory_(this) {} |
550 | 544 |
551 protected: | 545 protected: |
552 virtual void Run() OVERRIDE { | 546 virtual void Run() OVERRIDE { |
553 error_count_ = 0; | 547 error_count_ = 0; |
554 remaining_clients_ = manager()->clients_.size(); | 548 remaining_clients_ = manager()->clients_.size(); |
555 for (QuotaClientList::iterator iter = manager()->clients_.begin(); | 549 for (QuotaClientList::iterator iter = manager()->clients_.begin(); |
556 iter != manager()->clients_.end(); ++iter) { | 550 iter != manager()->clients_.end(); |
| 551 ++iter) { |
557 if (quota_client_mask_ & (*iter)->id()) { | 552 if (quota_client_mask_ & (*iter)->id()) { |
558 (*iter)->DeleteOriginData( | 553 (*iter)->DeleteOriginData( |
559 origin_, type_, | 554 origin_, |
| 555 type_, |
560 base::Bind(&OriginDataDeleter::DidDeleteOriginData, | 556 base::Bind(&OriginDataDeleter::DidDeleteOriginData, |
561 weak_factory_.GetWeakPtr())); | 557 weak_factory_.GetWeakPtr())); |
562 } else { | 558 } else { |
563 ++skipped_clients_; | 559 ++skipped_clients_; |
564 if (--remaining_clients_ == 0) | 560 if (--remaining_clients_ == 0) |
565 CallCompleted(); | 561 CallCompleted(); |
566 } | 562 } |
567 } | 563 } |
568 } | 564 } |
569 | 565 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 remaining_clients_(-1), | 622 remaining_clients_(-1), |
627 remaining_deleters_(-1), | 623 remaining_deleters_(-1), |
628 callback_(callback), | 624 callback_(callback), |
629 weak_factory_(this) {} | 625 weak_factory_(this) {} |
630 | 626 |
631 protected: | 627 protected: |
632 virtual void Run() OVERRIDE { | 628 virtual void Run() OVERRIDE { |
633 error_count_ = 0; | 629 error_count_ = 0; |
634 remaining_clients_ = manager()->clients_.size(); | 630 remaining_clients_ = manager()->clients_.size(); |
635 for (QuotaClientList::iterator iter = manager()->clients_.begin(); | 631 for (QuotaClientList::iterator iter = manager()->clients_.begin(); |
636 iter != manager()->clients_.end(); ++iter) { | 632 iter != manager()->clients_.end(); |
637 (*iter)->GetOriginsForHost( | 633 ++iter) { |
638 type_, host_, | 634 (*iter) |
639 base::Bind(&HostDataDeleter::DidGetOriginsForHost, | 635 ->GetOriginsForHost(type_, |
640 weak_factory_.GetWeakPtr())); | 636 host_, |
| 637 base::Bind(&HostDataDeleter::DidGetOriginsForHost, |
| 638 weak_factory_.GetWeakPtr())); |
641 } | 639 } |
642 } | 640 } |
643 | 641 |
644 virtual void Completed() OVERRIDE { | 642 virtual void Completed() OVERRIDE { |
645 if (error_count_ == 0) { | 643 if (error_count_ == 0) { |
646 callback_.Run(kQuotaStatusOk); | 644 callback_.Run(kQuotaStatusOk); |
647 } else { | 645 } else { |
648 callback_.Run(kQuotaErrorInvalidModification); | 646 callback_.Run(kQuotaErrorInvalidModification); |
649 } | 647 } |
650 DeleteSoon(); | 648 DeleteSoon(); |
(...skipping 16 matching lines...) Expand all Loading... |
667 else | 665 else |
668 CallCompleted(); | 666 CallCompleted(); |
669 } | 667 } |
670 } | 668 } |
671 | 669 |
672 void ScheduleOriginsDeletion() { | 670 void ScheduleOriginsDeletion() { |
673 remaining_deleters_ = origins_.size(); | 671 remaining_deleters_ = origins_.size(); |
674 for (std::set<GURL>::const_iterator p = origins_.begin(); | 672 for (std::set<GURL>::const_iterator p = origins_.begin(); |
675 p != origins_.end(); | 673 p != origins_.end(); |
676 ++p) { | 674 ++p) { |
677 OriginDataDeleter* deleter = | 675 OriginDataDeleter* deleter = new OriginDataDeleter( |
678 new OriginDataDeleter( | 676 manager(), |
679 manager(), *p, type_, quota_client_mask_, | 677 *p, |
680 base::Bind(&HostDataDeleter::DidDeleteOriginData, | 678 type_, |
681 weak_factory_.GetWeakPtr())); | 679 quota_client_mask_, |
| 680 base::Bind(&HostDataDeleter::DidDeleteOriginData, |
| 681 weak_factory_.GetWeakPtr())); |
682 deleter->Start(); | 682 deleter->Start(); |
683 } | 683 } |
684 } | 684 } |
685 | 685 |
686 void DidDeleteOriginData(QuotaStatusCode status) { | 686 void DidDeleteOriginData(QuotaStatusCode status) { |
687 DCHECK_GT(remaining_deleters_, 0); | 687 DCHECK_GT(remaining_deleters_, 0); |
688 | 688 |
689 if (status != kQuotaStatusOk) | 689 if (status != kQuotaStatusOk) |
690 ++error_count_; | 690 ++error_count_; |
691 | 691 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 return true; | 762 return true; |
763 } | 763 } |
764 | 764 |
765 QuotaTableEntries entries_; | 765 QuotaTableEntries entries_; |
766 }; | 766 }; |
767 | 767 |
768 class QuotaManager::DumpOriginInfoTableHelper { | 768 class QuotaManager::DumpOriginInfoTableHelper { |
769 public: | 769 public: |
770 bool DumpOriginInfoTableOnDBThread(QuotaDatabase* database) { | 770 bool DumpOriginInfoTableOnDBThread(QuotaDatabase* database) { |
771 DCHECK(database); | 771 DCHECK(database); |
772 return database->DumpOriginInfoTable( | 772 return database->DumpOriginInfoTable(base::Bind( |
773 base::Bind(&DumpOriginInfoTableHelper::AppendEntry, | 773 &DumpOriginInfoTableHelper::AppendEntry, base::Unretained(this))); |
774 base::Unretained(this))); | |
775 } | 774 } |
776 | 775 |
777 void DidDumpOriginInfoTable(const base::WeakPtr<QuotaManager>& manager, | 776 void DidDumpOriginInfoTable(const base::WeakPtr<QuotaManager>& manager, |
778 const DumpOriginInfoTableCallback& callback, | 777 const DumpOriginInfoTableCallback& callback, |
779 bool success) { | 778 bool success) { |
780 if (!manager) { | 779 if (!manager) { |
781 // The operation was aborted. | 780 // The operation was aborted. |
782 callback.Run(OriginInfoTableEntries()); | 781 callback.Run(OriginInfoTableEntries()); |
783 return; | 782 return; |
784 } | 783 } |
(...skipping 10 matching lines...) Expand all Loading... |
795 OriginInfoTableEntries entries_; | 794 OriginInfoTableEntries entries_; |
796 }; | 795 }; |
797 | 796 |
798 // QuotaManager --------------------------------------------------------------- | 797 // QuotaManager --------------------------------------------------------------- |
799 | 798 |
800 QuotaManager::QuotaManager(bool is_incognito, | 799 QuotaManager::QuotaManager(bool is_incognito, |
801 const base::FilePath& profile_path, | 800 const base::FilePath& profile_path, |
802 base::SingleThreadTaskRunner* io_thread, | 801 base::SingleThreadTaskRunner* io_thread, |
803 base::SequencedTaskRunner* db_thread, | 802 base::SequencedTaskRunner* db_thread, |
804 SpecialStoragePolicy* special_storage_policy) | 803 SpecialStoragePolicy* special_storage_policy) |
805 : is_incognito_(is_incognito), | 804 : is_incognito_(is_incognito), |
806 profile_path_(profile_path), | 805 profile_path_(profile_path), |
807 proxy_(new QuotaManagerProxy( | 806 proxy_(new QuotaManagerProxy(this, io_thread)), |
808 this, io_thread)), | 807 db_disabled_(false), |
809 db_disabled_(false), | 808 eviction_disabled_(false), |
810 eviction_disabled_(false), | 809 io_thread_(io_thread), |
811 io_thread_(io_thread), | 810 db_thread_(db_thread), |
812 db_thread_(db_thread), | 811 temporary_quota_initialized_(false), |
813 temporary_quota_initialized_(false), | 812 temporary_quota_override_(-1), |
814 temporary_quota_override_(-1), | 813 desired_available_space_(-1), |
815 desired_available_space_(-1), | 814 special_storage_policy_(special_storage_policy), |
816 special_storage_policy_(special_storage_policy), | 815 get_disk_space_fn_(&CallSystemGetAmountOfFreeDiskSpace), |
817 get_disk_space_fn_(&CallSystemGetAmountOfFreeDiskSpace), | 816 storage_monitor_(new StorageMonitor(this)), |
818 storage_monitor_(new StorageMonitor(this)), | 817 weak_factory_(this) { |
819 weak_factory_(this) { | |
820 } | 818 } |
821 | 819 |
822 void QuotaManager::GetUsageInfo(const GetUsageInfoCallback& callback) { | 820 void QuotaManager::GetUsageInfo(const GetUsageInfoCallback& callback) { |
823 LazyInitialize(); | 821 LazyInitialize(); |
824 GetUsageInfoTask* get_usage_info = new GetUsageInfoTask(this, callback); | 822 GetUsageInfoTask* get_usage_info = new GetUsageInfoTask(this, callback); |
825 get_usage_info->Start(); | 823 get_usage_info->Start(); |
826 } | 824 } |
827 | 825 |
828 void QuotaManager::GetUsageAndQuotaForWebApps( | 826 void QuotaManager::GetUsageAndQuotaForWebApps( |
829 const GURL& origin, | 827 const GURL& origin, |
830 StorageType type, | 828 StorageType type, |
831 const GetUsageAndQuotaCallback& callback) { | 829 const GetUsageAndQuotaCallback& callback) { |
832 if (type != kStorageTypeTemporary && | 830 if (type != kStorageTypeTemporary && type != kStorageTypePersistent && |
833 type != kStorageTypePersistent && | |
834 type != kStorageTypeSyncable) { | 831 type != kStorageTypeSyncable) { |
835 callback.Run(kQuotaErrorNotSupported, 0, 0); | 832 callback.Run(kQuotaErrorNotSupported, 0, 0); |
836 return; | 833 return; |
837 } | 834 } |
838 | 835 |
839 DCHECK(origin == origin.GetOrigin()); | 836 DCHECK(origin == origin.GetOrigin()); |
840 LazyInitialize(); | 837 LazyInitialize(); |
841 | 838 |
842 bool unlimited = IsStorageUnlimited(origin, type); | 839 bool unlimited = IsStorageUnlimited(origin, type); |
843 bool can_query_disk_size = CanQueryDiskSize(origin); | 840 bool can_query_disk_size = CanQueryDiskSize(origin); |
844 | 841 |
845 UsageAndQuotaCallbackDispatcher* dispatcher = | 842 UsageAndQuotaCallbackDispatcher* dispatcher = |
846 new UsageAndQuotaCallbackDispatcher(this); | 843 new UsageAndQuotaCallbackDispatcher(this); |
847 | 844 |
848 UsageAndQuota usage_and_quota; | 845 UsageAndQuota usage_and_quota; |
849 if (unlimited) { | 846 if (unlimited) { |
850 dispatcher->set_quota(kNoLimit); | 847 dispatcher->set_quota(kNoLimit); |
851 } else { | 848 } else { |
852 if (type == kStorageTypeTemporary) { | 849 if (type == kStorageTypeTemporary) { |
853 GetUsageTracker(type)->GetGlobalLimitedUsage( | 850 GetUsageTracker(type) |
854 dispatcher->GetGlobalLimitedUsageCallback()); | 851 ->GetGlobalLimitedUsage(dispatcher->GetGlobalLimitedUsageCallback()); |
855 GetTemporaryGlobalQuota(dispatcher->GetQuotaCallback()); | 852 GetTemporaryGlobalQuota(dispatcher->GetQuotaCallback()); |
856 } else if (type == kStorageTypePersistent) { | 853 } else if (type == kStorageTypePersistent) { |
857 GetPersistentHostQuota(net::GetHostOrSpecFromURL(origin), | 854 GetPersistentHostQuota(net::GetHostOrSpecFromURL(origin), |
858 dispatcher->GetQuotaCallback()); | 855 dispatcher->GetQuotaCallback()); |
859 } else { | 856 } else { |
860 dispatcher->set_quota(kSyncableStorageDefaultHostQuota); | 857 dispatcher->set_quota(kSyncableStorageDefaultHostQuota); |
861 } | 858 } |
862 } | 859 } |
863 | 860 |
864 DCHECK(GetUsageTracker(type)); | 861 DCHECK(GetUsageTracker(type)); |
865 GetUsageTracker(type)->GetHostUsage(net::GetHostOrSpecFromURL(origin), | 862 GetUsageTracker(type)->GetHostUsage(net::GetHostOrSpecFromURL(origin), |
866 dispatcher->GetHostUsageCallback()); | 863 dispatcher->GetHostUsageCallback()); |
867 | 864 |
868 if (!is_incognito_ && (unlimited || can_query_disk_size)) | 865 if (!is_incognito_ && (unlimited || can_query_disk_size)) |
869 GetAvailableSpace(dispatcher->GetAvailableSpaceCallback()); | 866 GetAvailableSpace(dispatcher->GetAvailableSpaceCallback()); |
870 | 867 |
871 dispatcher->WaitForResults(base::Bind( | 868 dispatcher->WaitForResults(base::Bind(&DispatchUsageAndQuotaForWebApps, |
872 &DispatchUsageAndQuotaForWebApps, | 869 type, |
873 type, is_incognito_, unlimited, can_query_disk_size, | 870 is_incognito_, |
874 callback)); | 871 unlimited, |
| 872 can_query_disk_size, |
| 873 callback)); |
875 } | 874 } |
876 | 875 |
877 void QuotaManager::GetUsageAndQuota( | 876 void QuotaManager::GetUsageAndQuota(const GURL& origin, |
878 const GURL& origin, StorageType type, | 877 StorageType type, |
879 const GetUsageAndQuotaCallback& callback) { | 878 const GetUsageAndQuotaCallback& callback) { |
880 DCHECK(origin == origin.GetOrigin()); | 879 DCHECK(origin == origin.GetOrigin()); |
881 | 880 |
882 if (IsStorageUnlimited(origin, type)) { | 881 if (IsStorageUnlimited(origin, type)) { |
883 callback.Run(kQuotaStatusOk, 0, kNoLimit); | 882 callback.Run(kQuotaStatusOk, 0, kNoLimit); |
884 return; | 883 return; |
885 } | 884 } |
886 | 885 |
887 GetUsageAndQuotaForWebApps(origin, type, callback); | 886 GetUsageAndQuotaForWebApps(origin, type, callback); |
888 } | 887 } |
889 | 888 |
890 void QuotaManager::NotifyStorageAccessed( | 889 void QuotaManager::NotifyStorageAccessed(QuotaClient::ID client_id, |
891 QuotaClient::ID client_id, | 890 const GURL& origin, |
892 const GURL& origin, StorageType type) { | 891 StorageType type) { |
893 DCHECK(origin == origin.GetOrigin()); | 892 DCHECK(origin == origin.GetOrigin()); |
894 NotifyStorageAccessedInternal(client_id, origin, type, base::Time::Now()); | 893 NotifyStorageAccessedInternal(client_id, origin, type, base::Time::Now()); |
895 } | 894 } |
896 | 895 |
897 void QuotaManager::NotifyStorageModified( | 896 void QuotaManager::NotifyStorageModified(QuotaClient::ID client_id, |
898 QuotaClient::ID client_id, | 897 const GURL& origin, |
899 const GURL& origin, StorageType type, int64 delta) { | 898 StorageType type, |
| 899 int64 delta) { |
900 DCHECK(origin == origin.GetOrigin()); | 900 DCHECK(origin == origin.GetOrigin()); |
901 NotifyStorageModifiedInternal(client_id, origin, type, delta, | 901 NotifyStorageModifiedInternal( |
902 base::Time::Now()); | 902 client_id, origin, type, delta, base::Time::Now()); |
903 } | 903 } |
904 | 904 |
905 void QuotaManager::NotifyOriginInUse(const GURL& origin) { | 905 void QuotaManager::NotifyOriginInUse(const GURL& origin) { |
906 DCHECK(io_thread_->BelongsToCurrentThread()); | 906 DCHECK(io_thread_->BelongsToCurrentThread()); |
907 origins_in_use_[origin]++; | 907 origins_in_use_[origin]++; |
908 } | 908 } |
909 | 909 |
910 void QuotaManager::NotifyOriginNoLongerInUse(const GURL& origin) { | 910 void QuotaManager::NotifyOriginNoLongerInUse(const GURL& origin) { |
911 DCHECK(io_thread_->BelongsToCurrentThread()); | 911 DCHECK(io_thread_->BelongsToCurrentThread()); |
912 DCHECK(IsOriginInUse(origin)); | 912 DCHECK(IsOriginInUse(origin)); |
913 int& count = origins_in_use_[origin]; | 913 int& count = origins_in_use_[origin]; |
914 if (--count == 0) | 914 if (--count == 0) |
915 origins_in_use_.erase(origin); | 915 origins_in_use_.erase(origin); |
916 } | 916 } |
917 | 917 |
918 void QuotaManager::SetUsageCacheEnabled(QuotaClient::ID client_id, | 918 void QuotaManager::SetUsageCacheEnabled(QuotaClient::ID client_id, |
919 const GURL& origin, | 919 const GURL& origin, |
920 StorageType type, | 920 StorageType type, |
921 bool enabled) { | 921 bool enabled) { |
922 LazyInitialize(); | 922 LazyInitialize(); |
923 DCHECK(GetUsageTracker(type)); | 923 DCHECK(GetUsageTracker(type)); |
924 GetUsageTracker(type)->SetUsageCacheEnabled(client_id, origin, enabled); | 924 GetUsageTracker(type)->SetUsageCacheEnabled(client_id, origin, enabled); |
925 } | 925 } |
926 | 926 |
927 void QuotaManager::DeleteOriginData( | 927 void QuotaManager::DeleteOriginData(const GURL& origin, |
928 const GURL& origin, StorageType type, int quota_client_mask, | 928 StorageType type, |
929 const StatusCallback& callback) { | 929 int quota_client_mask, |
| 930 const StatusCallback& callback) { |
930 LazyInitialize(); | 931 LazyInitialize(); |
931 | 932 |
932 if (origin.is_empty() || clients_.empty()) { | 933 if (origin.is_empty() || clients_.empty()) { |
933 callback.Run(kQuotaStatusOk); | 934 callback.Run(kQuotaStatusOk); |
934 return; | 935 return; |
935 } | 936 } |
936 | 937 |
937 DCHECK(origin == origin.GetOrigin()); | 938 DCHECK(origin == origin.GetOrigin()); |
938 OriginDataDeleter* deleter = | 939 OriginDataDeleter* deleter = |
939 new OriginDataDeleter(this, origin, type, quota_client_mask, callback); | 940 new OriginDataDeleter(this, origin, type, quota_client_mask, callback); |
(...skipping 23 matching lines...) Expand all Loading... |
963 PostTaskAndReplyWithResult(db_thread_.get(), | 964 PostTaskAndReplyWithResult(db_thread_.get(), |
964 FROM_HERE, | 965 FROM_HERE, |
965 base::Bind(get_disk_space_fn_, profile_path_), | 966 base::Bind(get_disk_space_fn_, profile_path_), |
966 base::Bind(&QuotaManager::DidGetAvailableSpace, | 967 base::Bind(&QuotaManager::DidGetAvailableSpace, |
967 weak_factory_.GetWeakPtr())); | 968 weak_factory_.GetWeakPtr())); |
968 } | 969 } |
969 | 970 |
970 void QuotaManager::GetTemporaryGlobalQuota(const QuotaCallback& callback) { | 971 void QuotaManager::GetTemporaryGlobalQuota(const QuotaCallback& callback) { |
971 LazyInitialize(); | 972 LazyInitialize(); |
972 if (!temporary_quota_initialized_) { | 973 if (!temporary_quota_initialized_) { |
973 db_initialization_callbacks_.Add(base::Bind( | 974 db_initialization_callbacks_.Add( |
974 &QuotaManager::GetTemporaryGlobalQuota, | 975 base::Bind(&QuotaManager::GetTemporaryGlobalQuota, |
975 weak_factory_.GetWeakPtr(), callback)); | 976 weak_factory_.GetWeakPtr(), |
| 977 callback)); |
976 return; | 978 return; |
977 } | 979 } |
978 | 980 |
979 if (temporary_quota_override_ > 0) { | 981 if (temporary_quota_override_ > 0) { |
980 callback.Run(kQuotaStatusOk, temporary_quota_override_); | 982 callback.Run(kQuotaStatusOk, temporary_quota_override_); |
981 return; | 983 return; |
982 } | 984 } |
983 | 985 |
984 UsageAndQuotaCallbackDispatcher* dispatcher = | 986 UsageAndQuotaCallbackDispatcher* dispatcher = |
985 new UsageAndQuotaCallbackDispatcher(this); | 987 new UsageAndQuotaCallbackDispatcher(this); |
986 GetUsageTracker(kStorageTypeTemporary)-> | 988 GetUsageTracker(kStorageTypeTemporary) |
987 GetGlobalLimitedUsage(dispatcher->GetGlobalLimitedUsageCallback()); | 989 ->GetGlobalLimitedUsage(dispatcher->GetGlobalLimitedUsageCallback()); |
988 GetAvailableSpace(dispatcher->GetAvailableSpaceCallback()); | 990 GetAvailableSpace(dispatcher->GetAvailableSpaceCallback()); |
989 dispatcher->WaitForResults( | 991 dispatcher->WaitForResults( |
990 base::Bind(&DispatchTemporaryGlobalQuotaCallback, callback)); | 992 base::Bind(&DispatchTemporaryGlobalQuotaCallback, callback)); |
991 } | 993 } |
992 | 994 |
993 void QuotaManager::SetTemporaryGlobalOverrideQuota( | 995 void QuotaManager::SetTemporaryGlobalOverrideQuota( |
994 int64 new_quota, const QuotaCallback& callback) { | 996 int64 new_quota, |
| 997 const QuotaCallback& callback) { |
995 LazyInitialize(); | 998 LazyInitialize(); |
996 | 999 |
997 if (new_quota < 0) { | 1000 if (new_quota < 0) { |
998 if (!callback.is_null()) | 1001 if (!callback.is_null()) |
999 callback.Run(kQuotaErrorInvalidModification, -1); | 1002 callback.Run(kQuotaErrorInvalidModification, -1); |
1000 return; | 1003 return; |
1001 } | 1004 } |
1002 | 1005 |
1003 if (db_disabled_) { | 1006 if (db_disabled_) { |
1004 if (!callback.is_null()) | 1007 if (!callback.is_null()) |
(...skipping 22 matching lines...) Expand all Loading... |
1027 callback.Run(kQuotaStatusOk, 0); | 1030 callback.Run(kQuotaStatusOk, 0); |
1028 return; | 1031 return; |
1029 } | 1032 } |
1030 | 1033 |
1031 if (!persistent_host_quota_callbacks_.Add(host, callback)) | 1034 if (!persistent_host_quota_callbacks_.Add(host, callback)) |
1032 return; | 1035 return; |
1033 | 1036 |
1034 int64* quota_ptr = new int64(0); | 1037 int64* quota_ptr = new int64(0); |
1035 PostTaskAndReplyWithResultForDBThread( | 1038 PostTaskAndReplyWithResultForDBThread( |
1036 FROM_HERE, | 1039 FROM_HERE, |
1037 base::Bind(&GetPersistentHostQuotaOnDBThread, | 1040 base::Bind( |
1038 host, | 1041 &GetPersistentHostQuotaOnDBThread, host, base::Unretained(quota_ptr)), |
1039 base::Unretained(quota_ptr)), | |
1040 base::Bind(&QuotaManager::DidGetPersistentHostQuota, | 1042 base::Bind(&QuotaManager::DidGetPersistentHostQuota, |
1041 weak_factory_.GetWeakPtr(), | 1043 weak_factory_.GetWeakPtr(), |
1042 host, | 1044 host, |
1043 base::Owned(quota_ptr))); | 1045 base::Owned(quota_ptr))); |
1044 } | 1046 } |
1045 | 1047 |
1046 void QuotaManager::SetPersistentHostQuota(const std::string& host, | 1048 void QuotaManager::SetPersistentHostQuota(const std::string& host, |
1047 int64 new_quota, | 1049 int64 new_quota, |
1048 const QuotaCallback& callback) { | 1050 const QuotaCallback& callback) { |
1049 LazyInitialize(); | 1051 LazyInitialize(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 callback, | 1161 callback, |
1160 type)); | 1162 type)); |
1161 } | 1163 } |
1162 | 1164 |
1163 bool QuotaManager::ResetUsageTracker(StorageType type) { | 1165 bool QuotaManager::ResetUsageTracker(StorageType type) { |
1164 DCHECK(GetUsageTracker(type)); | 1166 DCHECK(GetUsageTracker(type)); |
1165 if (GetUsageTracker(type)->IsWorking()) | 1167 if (GetUsageTracker(type)->IsWorking()) |
1166 return false; | 1168 return false; |
1167 switch (type) { | 1169 switch (type) { |
1168 case kStorageTypeTemporary: | 1170 case kStorageTypeTemporary: |
1169 temporary_usage_tracker_.reset(new UsageTracker( | 1171 temporary_usage_tracker_.reset( |
1170 clients_, kStorageTypeTemporary, special_storage_policy_.get(), | 1172 new UsageTracker(clients_, |
1171 storage_monitor_.get())); | 1173 kStorageTypeTemporary, |
| 1174 special_storage_policy_.get(), |
| 1175 storage_monitor_.get())); |
1172 return true; | 1176 return true; |
1173 case kStorageTypePersistent: | 1177 case kStorageTypePersistent: |
1174 persistent_usage_tracker_.reset(new UsageTracker( | 1178 persistent_usage_tracker_.reset( |
1175 clients_, kStorageTypePersistent, special_storage_policy_.get(), | 1179 new UsageTracker(clients_, |
1176 storage_monitor_.get())); | 1180 kStorageTypePersistent, |
| 1181 special_storage_policy_.get(), |
| 1182 storage_monitor_.get())); |
1177 return true; | 1183 return true; |
1178 case kStorageTypeSyncable: | 1184 case kStorageTypeSyncable: |
1179 syncable_usage_tracker_.reset(new UsageTracker( | 1185 syncable_usage_tracker_.reset( |
1180 clients_, kStorageTypeSyncable, special_storage_policy_.get(), | 1186 new UsageTracker(clients_, |
1181 storage_monitor_.get())); | 1187 kStorageTypeSyncable, |
| 1188 special_storage_policy_.get(), |
| 1189 storage_monitor_.get())); |
1182 return true; | 1190 return true; |
1183 default: | 1191 default: |
1184 NOTREACHED(); | 1192 NOTREACHED(); |
1185 } | 1193 } |
1186 return true; | 1194 return true; |
1187 } | 1195 } |
1188 | 1196 |
1189 void QuotaManager::AddStorageObserver( | 1197 void QuotaManager::AddStorageObserver( |
1190 StorageObserver* observer, const StorageObserver::MonitorParams& params) { | 1198 StorageObserver* observer, |
| 1199 const StorageObserver::MonitorParams& params) { |
1191 DCHECK(observer); | 1200 DCHECK(observer); |
1192 storage_monitor_->AddObserver(observer, params); | 1201 storage_monitor_->AddObserver(observer, params); |
1193 } | 1202 } |
1194 | 1203 |
1195 void QuotaManager::RemoveStorageObserver(StorageObserver* observer) { | 1204 void QuotaManager::RemoveStorageObserver(StorageObserver* observer) { |
1196 DCHECK(observer); | 1205 DCHECK(observer); |
1197 storage_monitor_->RemoveObserver(observer); | 1206 storage_monitor_->RemoveObserver(observer); |
1198 } | 1207 } |
1199 | 1208 |
1200 void QuotaManager::RemoveStorageObserverForFilter( | 1209 void QuotaManager::RemoveStorageObserverForFilter( |
1201 StorageObserver* observer, const StorageObserver::Filter& filter) { | 1210 StorageObserver* observer, |
| 1211 const StorageObserver::Filter& filter) { |
1202 DCHECK(observer); | 1212 DCHECK(observer); |
1203 storage_monitor_->RemoveObserverForFilter(observer, filter); | 1213 storage_monitor_->RemoveObserverForFilter(observer, filter); |
1204 } | 1214 } |
1205 | 1215 |
1206 QuotaManager::~QuotaManager() { | 1216 QuotaManager::~QuotaManager() { |
1207 proxy_->manager_ = NULL; | 1217 proxy_->manager_ = NULL; |
1208 std::for_each(clients_.begin(), clients_.end(), | 1218 std::for_each(clients_.begin(), |
| 1219 clients_.end(), |
1209 std::mem_fun(&QuotaClient::OnQuotaManagerDestroyed)); | 1220 std::mem_fun(&QuotaClient::OnQuotaManagerDestroyed)); |
1210 if (database_) | 1221 if (database_) |
1211 db_thread_->DeleteSoon(FROM_HERE, database_.release()); | 1222 db_thread_->DeleteSoon(FROM_HERE, database_.release()); |
1212 } | 1223 } |
1213 | 1224 |
1214 QuotaManager::EvictionContext::EvictionContext() | 1225 QuotaManager::EvictionContext::EvictionContext() |
1215 : evicted_type(kStorageTypeUnknown) { | 1226 : evicted_type(kStorageTypeUnknown) { |
1216 } | 1227 } |
1217 | 1228 |
1218 QuotaManager::EvictionContext::~EvictionContext() { | 1229 QuotaManager::EvictionContext::~EvictionContext() { |
1219 } | 1230 } |
1220 | 1231 |
1221 void QuotaManager::LazyInitialize() { | 1232 void QuotaManager::LazyInitialize() { |
1222 DCHECK(io_thread_->BelongsToCurrentThread()); | 1233 DCHECK(io_thread_->BelongsToCurrentThread()); |
1223 if (database_) { | 1234 if (database_) { |
1224 // Initialization seems to be done already. | 1235 // Initialization seems to be done already. |
1225 return; | 1236 return; |
1226 } | 1237 } |
1227 | 1238 |
1228 // Use an empty path to open an in-memory only databse for incognito. | 1239 // Use an empty path to open an in-memory only databse for incognito. |
1229 database_.reset(new QuotaDatabase(is_incognito_ ? base::FilePath() : | 1240 database_.reset(new QuotaDatabase( |
1230 profile_path_.AppendASCII(kDatabaseName))); | 1241 is_incognito_ ? base::FilePath() |
| 1242 : profile_path_.AppendASCII(kDatabaseName))); |
1231 | 1243 |
1232 temporary_usage_tracker_.reset(new UsageTracker( | 1244 temporary_usage_tracker_.reset(new UsageTracker(clients_, |
1233 clients_, kStorageTypeTemporary, special_storage_policy_.get(), | 1245 kStorageTypeTemporary, |
1234 storage_monitor_.get())); | 1246 special_storage_policy_.get(), |
1235 persistent_usage_tracker_.reset(new UsageTracker( | 1247 storage_monitor_.get())); |
1236 clients_, kStorageTypePersistent, special_storage_policy_.get(), | 1248 persistent_usage_tracker_.reset( |
1237 storage_monitor_.get())); | 1249 new UsageTracker(clients_, |
1238 syncable_usage_tracker_.reset(new UsageTracker( | 1250 kStorageTypePersistent, |
1239 clients_, kStorageTypeSyncable, special_storage_policy_.get(), | 1251 special_storage_policy_.get(), |
1240 storage_monitor_.get())); | 1252 storage_monitor_.get())); |
| 1253 syncable_usage_tracker_.reset(new UsageTracker(clients_, |
| 1254 kStorageTypeSyncable, |
| 1255 special_storage_policy_.get(), |
| 1256 storage_monitor_.get())); |
1241 | 1257 |
1242 int64* temporary_quota_override = new int64(-1); | 1258 int64* temporary_quota_override = new int64(-1); |
1243 int64* desired_available_space = new int64(-1); | 1259 int64* desired_available_space = new int64(-1); |
1244 PostTaskAndReplyWithResultForDBThread( | 1260 PostTaskAndReplyWithResultForDBThread( |
1245 FROM_HERE, | 1261 FROM_HERE, |
1246 base::Bind(&InitializeOnDBThread, | 1262 base::Bind(&InitializeOnDBThread, |
1247 base::Unretained(temporary_quota_override), | 1263 base::Unretained(temporary_quota_override), |
1248 base::Unretained(desired_available_space)), | 1264 base::Unretained(desired_available_space)), |
1249 base::Bind(&QuotaManager::DidInitialize, | 1265 base::Bind(&QuotaManager::DidInitialize, |
1250 weak_factory_.GetWeakPtr(), | 1266 weak_factory_.GetWeakPtr(), |
(...skipping 15 matching lines...) Expand all Loading... |
1266 case kStorageTypeSyncable: | 1282 case kStorageTypeSyncable: |
1267 return syncable_usage_tracker_.get(); | 1283 return syncable_usage_tracker_.get(); |
1268 case kStorageTypeQuotaNotManaged: | 1284 case kStorageTypeQuotaNotManaged: |
1269 return NULL; | 1285 return NULL; |
1270 case kStorageTypeUnknown: | 1286 case kStorageTypeUnknown: |
1271 NOTREACHED(); | 1287 NOTREACHED(); |
1272 } | 1288 } |
1273 return NULL; | 1289 return NULL; |
1274 } | 1290 } |
1275 | 1291 |
1276 void QuotaManager::GetCachedOrigins( | 1292 void QuotaManager::GetCachedOrigins(StorageType type, std::set<GURL>* origins) { |
1277 StorageType type, std::set<GURL>* origins) { | |
1278 DCHECK(origins); | 1293 DCHECK(origins); |
1279 LazyInitialize(); | 1294 LazyInitialize(); |
1280 DCHECK(GetUsageTracker(type)); | 1295 DCHECK(GetUsageTracker(type)); |
1281 GetUsageTracker(type)->GetCachedOrigins(origins); | 1296 GetUsageTracker(type)->GetCachedOrigins(origins); |
1282 } | 1297 } |
1283 | 1298 |
1284 void QuotaManager::NotifyStorageAccessedInternal( | 1299 void QuotaManager::NotifyStorageAccessedInternal(QuotaClient::ID client_id, |
1285 QuotaClient::ID client_id, | 1300 const GURL& origin, |
1286 const GURL& origin, StorageType type, | 1301 StorageType type, |
1287 base::Time accessed_time) { | 1302 base::Time accessed_time) { |
1288 LazyInitialize(); | 1303 LazyInitialize(); |
1289 if (type == kStorageTypeTemporary && !lru_origin_callback_.is_null()) { | 1304 if (type == kStorageTypeTemporary && !lru_origin_callback_.is_null()) { |
1290 // Record the accessed origins while GetLRUOrigin task is runing | 1305 // Record the accessed origins while GetLRUOrigin task is runing |
1291 // to filter out them from eviction. | 1306 // to filter out them from eviction. |
1292 access_notified_origins_.insert(origin); | 1307 access_notified_origins_.insert(origin); |
1293 } | 1308 } |
1294 | 1309 |
1295 if (db_disabled_) | 1310 if (db_disabled_) |
1296 return; | 1311 return; |
1297 PostTaskAndReplyWithResultForDBThread( | 1312 PostTaskAndReplyWithResultForDBThread( |
1298 FROM_HERE, | 1313 FROM_HERE, |
1299 base::Bind(&UpdateAccessTimeOnDBThread, origin, type, accessed_time), | 1314 base::Bind(&UpdateAccessTimeOnDBThread, origin, type, accessed_time), |
1300 base::Bind(&QuotaManager::DidDatabaseWork, | 1315 base::Bind(&QuotaManager::DidDatabaseWork, weak_factory_.GetWeakPtr())); |
1301 weak_factory_.GetWeakPtr())); | |
1302 } | 1316 } |
1303 | 1317 |
1304 void QuotaManager::NotifyStorageModifiedInternal( | 1318 void QuotaManager::NotifyStorageModifiedInternal(QuotaClient::ID client_id, |
1305 QuotaClient::ID client_id, | 1319 const GURL& origin, |
1306 const GURL& origin, | 1320 StorageType type, |
1307 StorageType type, | 1321 int64 delta, |
1308 int64 delta, | 1322 base::Time modified_time) { |
1309 base::Time modified_time) { | |
1310 LazyInitialize(); | 1323 LazyInitialize(); |
1311 DCHECK(GetUsageTracker(type)); | 1324 DCHECK(GetUsageTracker(type)); |
1312 GetUsageTracker(type)->UpdateUsageCache(client_id, origin, delta); | 1325 GetUsageTracker(type)->UpdateUsageCache(client_id, origin, delta); |
1313 | 1326 |
1314 PostTaskAndReplyWithResultForDBThread( | 1327 PostTaskAndReplyWithResultForDBThread( |
1315 FROM_HERE, | 1328 FROM_HERE, |
1316 base::Bind(&UpdateModifiedTimeOnDBThread, origin, type, modified_time), | 1329 base::Bind(&UpdateModifiedTimeOnDBThread, origin, type, modified_time), |
1317 base::Bind(&QuotaManager::DidDatabaseWork, | 1330 base::Bind(&QuotaManager::DidDatabaseWork, weak_factory_.GetWeakPtr())); |
1318 weak_factory_.GetWeakPtr())); | |
1319 } | 1331 } |
1320 | 1332 |
1321 void QuotaManager::DumpQuotaTable(const DumpQuotaTableCallback& callback) { | 1333 void QuotaManager::DumpQuotaTable(const DumpQuotaTableCallback& callback) { |
1322 DumpQuotaTableHelper* helper = new DumpQuotaTableHelper; | 1334 DumpQuotaTableHelper* helper = new DumpQuotaTableHelper; |
1323 PostTaskAndReplyWithResultForDBThread( | 1335 PostTaskAndReplyWithResultForDBThread( |
1324 FROM_HERE, | 1336 FROM_HERE, |
1325 base::Bind(&DumpQuotaTableHelper::DumpQuotaTableOnDBThread, | 1337 base::Bind(&DumpQuotaTableHelper::DumpQuotaTableOnDBThread, |
1326 base::Unretained(helper)), | 1338 base::Unretained(helper)), |
1327 base::Bind(&DumpQuotaTableHelper::DidDumpQuotaTable, | 1339 base::Bind(&DumpQuotaTableHelper::DidDumpQuotaTable, |
1328 base::Owned(helper), | 1340 base::Owned(helper), |
1329 weak_factory_.GetWeakPtr(), | 1341 weak_factory_.GetWeakPtr(), |
1330 callback)); | 1342 callback)); |
1331 } | 1343 } |
1332 | 1344 |
1333 void QuotaManager::DumpOriginInfoTable( | 1345 void QuotaManager::DumpOriginInfoTable( |
1334 const DumpOriginInfoTableCallback& callback) { | 1346 const DumpOriginInfoTableCallback& callback) { |
1335 DumpOriginInfoTableHelper* helper = new DumpOriginInfoTableHelper; | 1347 DumpOriginInfoTableHelper* helper = new DumpOriginInfoTableHelper; |
1336 PostTaskAndReplyWithResultForDBThread( | 1348 PostTaskAndReplyWithResultForDBThread( |
1337 FROM_HERE, | 1349 FROM_HERE, |
1338 base::Bind(&DumpOriginInfoTableHelper::DumpOriginInfoTableOnDBThread, | 1350 base::Bind(&DumpOriginInfoTableHelper::DumpOriginInfoTableOnDBThread, |
1339 base::Unretained(helper)), | 1351 base::Unretained(helper)), |
1340 base::Bind(&DumpOriginInfoTableHelper::DidDumpOriginInfoTable, | 1352 base::Bind(&DumpOriginInfoTableHelper::DidDumpOriginInfoTable, |
1341 base::Owned(helper), | 1353 base::Owned(helper), |
1342 weak_factory_.GetWeakPtr(), | 1354 weak_factory_.GetWeakPtr(), |
1343 callback)); | 1355 callback)); |
1344 } | 1356 } |
1345 | 1357 |
1346 void QuotaManager::StartEviction() { | 1358 void QuotaManager::StartEviction() { |
1347 DCHECK(!temporary_storage_evictor_.get()); | 1359 DCHECK(!temporary_storage_evictor_.get()); |
1348 temporary_storage_evictor_.reset(new QuotaTemporaryStorageEvictor( | 1360 temporary_storage_evictor_.reset( |
1349 this, kEvictionIntervalInMilliSeconds)); | 1361 new QuotaTemporaryStorageEvictor(this, kEvictionIntervalInMilliSeconds)); |
1350 if (desired_available_space_ >= 0) | 1362 if (desired_available_space_ >= 0) |
1351 temporary_storage_evictor_->set_min_available_disk_space_to_start_eviction( | 1363 temporary_storage_evictor_->set_min_available_disk_space_to_start_eviction( |
1352 desired_available_space_); | 1364 desired_available_space_); |
1353 temporary_storage_evictor_->Start(); | 1365 temporary_storage_evictor_->Start(); |
1354 } | 1366 } |
1355 | 1367 |
1356 void QuotaManager::DeleteOriginFromDatabase( | 1368 void QuotaManager::DeleteOriginFromDatabase(const GURL& origin, |
1357 const GURL& origin, StorageType type) { | 1369 StorageType type) { |
1358 LazyInitialize(); | 1370 LazyInitialize(); |
1359 if (db_disabled_) | 1371 if (db_disabled_) |
1360 return; | 1372 return; |
1361 | 1373 |
1362 PostTaskAndReplyWithResultForDBThread( | 1374 PostTaskAndReplyWithResultForDBThread( |
1363 FROM_HERE, | 1375 FROM_HERE, |
1364 base::Bind(&DeleteOriginInfoOnDBThread, origin, type), | 1376 base::Bind(&DeleteOriginInfoOnDBThread, origin, type), |
1365 base::Bind(&QuotaManager::DidDatabaseWork, | 1377 base::Bind(&QuotaManager::DidDatabaseWork, weak_factory_.GetWeakPtr())); |
1366 weak_factory_.GetWeakPtr())); | |
1367 } | 1378 } |
1368 | 1379 |
1369 void QuotaManager::DidOriginDataEvicted(QuotaStatusCode status) { | 1380 void QuotaManager::DidOriginDataEvicted(QuotaStatusCode status) { |
1370 DCHECK(io_thread_->BelongsToCurrentThread()); | 1381 DCHECK(io_thread_->BelongsToCurrentThread()); |
1371 | 1382 |
1372 // We only try evict origins that are not in use, so basically | 1383 // We only try evict origins that are not in use, so basically |
1373 // deletion attempt for eviction should not fail. Let's record | 1384 // deletion attempt for eviction should not fail. Let's record |
1374 // the origin if we get error and exclude it from future eviction | 1385 // the origin if we get error and exclude it from future eviction |
1375 // if the error happens consistently (> kThresholdOfErrorsToBeBlacklisted). | 1386 // if the error happens consistently (> kThresholdOfErrorsToBeBlacklisted). |
1376 if (status != kQuotaStatusOk) | 1387 if (status != kQuotaStatusOk) |
1377 origins_in_error_[eviction_context_.evicted_origin]++; | 1388 origins_in_error_[eviction_context_.evicted_origin]++; |
1378 | 1389 |
1379 eviction_context_.evict_origin_data_callback.Run(status); | 1390 eviction_context_.evict_origin_data_callback.Run(status); |
1380 eviction_context_.evict_origin_data_callback.Reset(); | 1391 eviction_context_.evict_origin_data_callback.Reset(); |
1381 } | 1392 } |
1382 | 1393 |
1383 void QuotaManager::ReportHistogram() { | 1394 void QuotaManager::ReportHistogram() { |
1384 GetGlobalUsage(kStorageTypeTemporary, | 1395 GetGlobalUsage( |
1385 base::Bind( | 1396 kStorageTypeTemporary, |
1386 &QuotaManager::DidGetTemporaryGlobalUsageForHistogram, | 1397 base::Bind(&QuotaManager::DidGetTemporaryGlobalUsageForHistogram, |
1387 weak_factory_.GetWeakPtr())); | 1398 weak_factory_.GetWeakPtr())); |
1388 GetGlobalUsage(kStorageTypePersistent, | 1399 GetGlobalUsage( |
1389 base::Bind( | 1400 kStorageTypePersistent, |
1390 &QuotaManager::DidGetPersistentGlobalUsageForHistogram, | 1401 base::Bind(&QuotaManager::DidGetPersistentGlobalUsageForHistogram, |
1391 weak_factory_.GetWeakPtr())); | 1402 weak_factory_.GetWeakPtr())); |
1392 } | 1403 } |
1393 | 1404 |
1394 void QuotaManager::DidGetTemporaryGlobalUsageForHistogram( | 1405 void QuotaManager::DidGetTemporaryGlobalUsageForHistogram( |
1395 int64 usage, | 1406 int64 usage, |
1396 int64 unlimited_usage) { | 1407 int64 unlimited_usage) { |
1397 UMA_HISTOGRAM_MBYTES("Quota.GlobalUsageOfTemporaryStorage", usage); | 1408 UMA_HISTOGRAM_MBYTES("Quota.GlobalUsageOfTemporaryStorage", usage); |
1398 | 1409 |
1399 std::set<GURL> origins; | 1410 std::set<GURL> origins; |
1400 GetCachedOrigins(kStorageTypeTemporary, &origins); | 1411 GetCachedOrigins(kStorageTypeTemporary, &origins); |
1401 | 1412 |
1402 size_t num_origins = origins.size(); | 1413 size_t num_origins = origins.size(); |
1403 size_t protected_origins = 0; | 1414 size_t protected_origins = 0; |
1404 size_t unlimited_origins = 0; | 1415 size_t unlimited_origins = 0; |
1405 CountOriginType(origins, | 1416 CountOriginType(origins, |
1406 special_storage_policy_.get(), | 1417 special_storage_policy_.get(), |
1407 &protected_origins, | 1418 &protected_origins, |
1408 &unlimited_origins); | 1419 &unlimited_origins); |
1409 | 1420 |
1410 UMA_HISTOGRAM_COUNTS("Quota.NumberOfTemporaryStorageOrigins", | 1421 UMA_HISTOGRAM_COUNTS("Quota.NumberOfTemporaryStorageOrigins", num_origins); |
1411 num_origins); | |
1412 UMA_HISTOGRAM_COUNTS("Quota.NumberOfProtectedTemporaryStorageOrigins", | 1422 UMA_HISTOGRAM_COUNTS("Quota.NumberOfProtectedTemporaryStorageOrigins", |
1413 protected_origins); | 1423 protected_origins); |
1414 UMA_HISTOGRAM_COUNTS("Quota.NumberOfUnlimitedTemporaryStorageOrigins", | 1424 UMA_HISTOGRAM_COUNTS("Quota.NumberOfUnlimitedTemporaryStorageOrigins", |
1415 unlimited_origins); | 1425 unlimited_origins); |
1416 } | 1426 } |
1417 | 1427 |
1418 void QuotaManager::DidGetPersistentGlobalUsageForHistogram( | 1428 void QuotaManager::DidGetPersistentGlobalUsageForHistogram( |
1419 int64 usage, | 1429 int64 usage, |
1420 int64 unlimited_usage) { | 1430 int64 unlimited_usage) { |
1421 UMA_HISTOGRAM_MBYTES("Quota.GlobalUsageOfPersistentStorage", usage); | 1431 UMA_HISTOGRAM_MBYTES("Quota.GlobalUsageOfPersistentStorage", usage); |
1422 | 1432 |
1423 std::set<GURL> origins; | 1433 std::set<GURL> origins; |
1424 GetCachedOrigins(kStorageTypePersistent, &origins); | 1434 GetCachedOrigins(kStorageTypePersistent, &origins); |
1425 | 1435 |
1426 size_t num_origins = origins.size(); | 1436 size_t num_origins = origins.size(); |
1427 size_t protected_origins = 0; | 1437 size_t protected_origins = 0; |
1428 size_t unlimited_origins = 0; | 1438 size_t unlimited_origins = 0; |
1429 CountOriginType(origins, | 1439 CountOriginType(origins, |
1430 special_storage_policy_.get(), | 1440 special_storage_policy_.get(), |
1431 &protected_origins, | 1441 &protected_origins, |
1432 &unlimited_origins); | 1442 &unlimited_origins); |
1433 | 1443 |
1434 UMA_HISTOGRAM_COUNTS("Quota.NumberOfPersistentStorageOrigins", | 1444 UMA_HISTOGRAM_COUNTS("Quota.NumberOfPersistentStorageOrigins", num_origins); |
1435 num_origins); | |
1436 UMA_HISTOGRAM_COUNTS("Quota.NumberOfProtectedPersistentStorageOrigins", | 1445 UMA_HISTOGRAM_COUNTS("Quota.NumberOfProtectedPersistentStorageOrigins", |
1437 protected_origins); | 1446 protected_origins); |
1438 UMA_HISTOGRAM_COUNTS("Quota.NumberOfUnlimitedPersistentStorageOrigins", | 1447 UMA_HISTOGRAM_COUNTS("Quota.NumberOfUnlimitedPersistentStorageOrigins", |
1439 unlimited_origins); | 1448 unlimited_origins); |
1440 } | 1449 } |
1441 | 1450 |
1442 void QuotaManager::GetLRUOrigin( | 1451 void QuotaManager::GetLRUOrigin(StorageType type, |
1443 StorageType type, | 1452 const GetLRUOriginCallback& callback) { |
1444 const GetLRUOriginCallback& callback) { | |
1445 LazyInitialize(); | 1453 LazyInitialize(); |
1446 // This must not be called while there's an in-flight task. | 1454 // This must not be called while there's an in-flight task. |
1447 DCHECK(lru_origin_callback_.is_null()); | 1455 DCHECK(lru_origin_callback_.is_null()); |
1448 lru_origin_callback_ = callback; | 1456 lru_origin_callback_ = callback; |
1449 if (db_disabled_) { | 1457 if (db_disabled_) { |
1450 lru_origin_callback_.Run(GURL()); | 1458 lru_origin_callback_.Run(GURL()); |
1451 lru_origin_callback_.Reset(); | 1459 lru_origin_callback_.Reset(); |
1452 return; | 1460 return; |
1453 } | 1461 } |
1454 | 1462 |
(...skipping 17 matching lines...) Expand all Loading... |
1472 base::Bind(&GetLRUOriginOnDBThread, | 1480 base::Bind(&GetLRUOriginOnDBThread, |
1473 type, | 1481 type, |
1474 base::Owned(exceptions), | 1482 base::Owned(exceptions), |
1475 special_storage_policy_, | 1483 special_storage_policy_, |
1476 base::Unretained(url)), | 1484 base::Unretained(url)), |
1477 base::Bind(&QuotaManager::DidGetLRUOrigin, | 1485 base::Bind(&QuotaManager::DidGetLRUOrigin, |
1478 weak_factory_.GetWeakPtr(), | 1486 weak_factory_.GetWeakPtr(), |
1479 base::Owned(url))); | 1487 base::Owned(url))); |
1480 } | 1488 } |
1481 | 1489 |
1482 void QuotaManager::EvictOriginData( | 1490 void QuotaManager::EvictOriginData(const GURL& origin, |
1483 const GURL& origin, | 1491 StorageType type, |
1484 StorageType type, | 1492 const EvictOriginDataCallback& callback) { |
1485 const EvictOriginDataCallback& callback) { | |
1486 DCHECK(io_thread_->BelongsToCurrentThread()); | 1493 DCHECK(io_thread_->BelongsToCurrentThread()); |
1487 DCHECK_EQ(type, kStorageTypeTemporary); | 1494 DCHECK_EQ(type, kStorageTypeTemporary); |
1488 | 1495 |
1489 eviction_context_.evicted_origin = origin; | 1496 eviction_context_.evicted_origin = origin; |
1490 eviction_context_.evicted_type = type; | 1497 eviction_context_.evicted_type = type; |
1491 eviction_context_.evict_origin_data_callback = callback; | 1498 eviction_context_.evict_origin_data_callback = callback; |
1492 | 1499 |
1493 DeleteOriginData(origin, type, QuotaClient::kAllClientsMask, | 1500 DeleteOriginData(origin, |
1494 base::Bind(&QuotaManager::DidOriginDataEvicted, | 1501 type, |
1495 weak_factory_.GetWeakPtr())); | 1502 QuotaClient::kAllClientsMask, |
| 1503 base::Bind(&QuotaManager::DidOriginDataEvicted, |
| 1504 weak_factory_.GetWeakPtr())); |
1496 } | 1505 } |
1497 | 1506 |
1498 void QuotaManager::GetUsageAndQuotaForEviction( | 1507 void QuotaManager::GetUsageAndQuotaForEviction( |
1499 const UsageAndQuotaCallback& callback) { | 1508 const UsageAndQuotaCallback& callback) { |
1500 DCHECK(io_thread_->BelongsToCurrentThread()); | 1509 DCHECK(io_thread_->BelongsToCurrentThread()); |
1501 LazyInitialize(); | 1510 LazyInitialize(); |
1502 | 1511 |
1503 UsageAndQuotaCallbackDispatcher* dispatcher = | 1512 UsageAndQuotaCallbackDispatcher* dispatcher = |
1504 new UsageAndQuotaCallbackDispatcher(this); | 1513 new UsageAndQuotaCallbackDispatcher(this); |
1505 GetUsageTracker(kStorageTypeTemporary)-> | 1514 GetUsageTracker(kStorageTypeTemporary) |
1506 GetGlobalLimitedUsage(dispatcher->GetGlobalLimitedUsageCallback()); | 1515 ->GetGlobalLimitedUsage(dispatcher->GetGlobalLimitedUsageCallback()); |
1507 GetTemporaryGlobalQuota(dispatcher->GetQuotaCallback()); | 1516 GetTemporaryGlobalQuota(dispatcher->GetQuotaCallback()); |
1508 GetAvailableSpace(dispatcher->GetAvailableSpaceCallback()); | 1517 GetAvailableSpace(dispatcher->GetAvailableSpaceCallback()); |
1509 dispatcher->WaitForResults(callback); | 1518 dispatcher->WaitForResults(callback); |
1510 } | 1519 } |
1511 | 1520 |
1512 void QuotaManager::DidSetTemporaryGlobalOverrideQuota( | 1521 void QuotaManager::DidSetTemporaryGlobalOverrideQuota( |
1513 const QuotaCallback& callback, | 1522 const QuotaCallback& callback, |
1514 const int64* new_quota, | 1523 const int64* new_quota, |
1515 bool success) { | 1524 bool success) { |
1516 QuotaStatusCode status = kQuotaErrorInvalidAccess; | 1525 QuotaStatusCode status = kQuotaErrorInvalidAccess; |
1517 DidDatabaseWork(success); | 1526 DidDatabaseWork(success); |
1518 if (success) { | 1527 if (success) { |
1519 temporary_quota_override_ = *new_quota; | 1528 temporary_quota_override_ = *new_quota; |
1520 status = kQuotaStatusOk; | 1529 status = kQuotaStatusOk; |
1521 } | 1530 } |
1522 | 1531 |
1523 if (callback.is_null()) | 1532 if (callback.is_null()) |
1524 return; | 1533 return; |
1525 | 1534 |
1526 callback.Run(status, *new_quota); | 1535 callback.Run(status, *new_quota); |
1527 } | 1536 } |
1528 | 1537 |
1529 void QuotaManager::DidGetPersistentHostQuota(const std::string& host, | 1538 void QuotaManager::DidGetPersistentHostQuota(const std::string& host, |
1530 const int64* quota, | 1539 const int64* quota, |
1531 bool success) { | 1540 bool success) { |
1532 DidDatabaseWork(success); | 1541 DidDatabaseWork(success); |
1533 persistent_host_quota_callbacks_.Run( | 1542 persistent_host_quota_callbacks_.Run(host, MakeTuple(kQuotaStatusOk, *quota)); |
1534 host, MakeTuple(kQuotaStatusOk, *quota)); | |
1535 } | 1543 } |
1536 | 1544 |
1537 void QuotaManager::DidSetPersistentHostQuota(const std::string& host, | 1545 void QuotaManager::DidSetPersistentHostQuota(const std::string& host, |
1538 const QuotaCallback& callback, | 1546 const QuotaCallback& callback, |
1539 const int64* new_quota, | 1547 const int64* new_quota, |
1540 bool success) { | 1548 bool success) { |
1541 DidDatabaseWork(success); | 1549 DidDatabaseWork(success); |
1542 callback.Run(success ? kQuotaStatusOk : kQuotaErrorInvalidAccess, *new_quota); | 1550 callback.Run(success ? kQuotaStatusOk : kQuotaErrorInvalidAccess, *new_quota); |
1543 } | 1551 } |
1544 | 1552 |
1545 void QuotaManager::DidInitialize(int64* temporary_quota_override, | 1553 void QuotaManager::DidInitialize(int64* temporary_quota_override, |
1546 int64* desired_available_space, | 1554 int64* desired_available_space, |
1547 bool success) { | 1555 bool success) { |
1548 temporary_quota_override_ = *temporary_quota_override; | 1556 temporary_quota_override_ = *temporary_quota_override; |
1549 desired_available_space_ = *desired_available_space; | 1557 desired_available_space_ = *desired_available_space; |
1550 temporary_quota_initialized_ = true; | 1558 temporary_quota_initialized_ = true; |
1551 DidDatabaseWork(success); | 1559 DidDatabaseWork(success); |
1552 | 1560 |
1553 histogram_timer_.Start(FROM_HERE, | 1561 histogram_timer_.Start( |
1554 base::TimeDelta::FromMilliseconds( | 1562 FROM_HERE, |
1555 kReportHistogramInterval), | 1563 base::TimeDelta::FromMilliseconds(kReportHistogramInterval), |
1556 this, &QuotaManager::ReportHistogram); | 1564 this, |
| 1565 &QuotaManager::ReportHistogram); |
1557 | 1566 |
1558 db_initialization_callbacks_.Run(MakeTuple()); | 1567 db_initialization_callbacks_.Run(MakeTuple()); |
1559 GetTemporaryGlobalQuota( | 1568 GetTemporaryGlobalQuota( |
1560 base::Bind(&QuotaManager::DidGetInitialTemporaryGlobalQuota, | 1569 base::Bind(&QuotaManager::DidGetInitialTemporaryGlobalQuota, |
1561 weak_factory_.GetWeakPtr())); | 1570 weak_factory_.GetWeakPtr())); |
1562 } | 1571 } |
1563 | 1572 |
1564 void QuotaManager::DidGetLRUOrigin(const GURL* origin, | 1573 void QuotaManager::DidGetLRUOrigin(const GURL* origin, bool success) { |
1565 bool success) { | |
1566 DidDatabaseWork(success); | 1574 DidDatabaseWork(success); |
1567 // Make sure the returned origin is (still) not in the origin_in_use_ set | 1575 // Make sure the returned origin is (still) not in the origin_in_use_ set |
1568 // and has not been accessed since we posted the task. | 1576 // and has not been accessed since we posted the task. |
1569 if (origins_in_use_.find(*origin) != origins_in_use_.end() || | 1577 if (origins_in_use_.find(*origin) != origins_in_use_.end() || |
1570 access_notified_origins_.find(*origin) != access_notified_origins_.end()) | 1578 access_notified_origins_.find(*origin) != access_notified_origins_.end()) |
1571 lru_origin_callback_.Run(GURL()); | 1579 lru_origin_callback_.Run(GURL()); |
1572 else | 1580 else |
1573 lru_origin_callback_.Run(*origin); | 1581 lru_origin_callback_.Run(*origin); |
1574 access_notified_origins_.clear(); | 1582 access_notified_origins_.clear(); |
1575 lru_origin_callback_.Reset(); | 1583 lru_origin_callback_.Reset(); |
1576 } | 1584 } |
1577 | 1585 |
1578 void QuotaManager::DidGetInitialTemporaryGlobalQuota( | 1586 void QuotaManager::DidGetInitialTemporaryGlobalQuota(QuotaStatusCode status, |
1579 QuotaStatusCode status, int64 quota_unused) { | 1587 int64 quota_unused) { |
1580 if (eviction_disabled_) | 1588 if (eviction_disabled_) |
1581 return; | 1589 return; |
1582 | 1590 |
1583 std::set<GURL>* origins = new std::set<GURL>; | 1591 std::set<GURL>* origins = new std::set<GURL>; |
1584 temporary_usage_tracker_->GetCachedOrigins(origins); | 1592 temporary_usage_tracker_->GetCachedOrigins(origins); |
1585 // This will call the StartEviction() when initial origin registration | 1593 // This will call the StartEviction() when initial origin registration |
1586 // is completed. | 1594 // is completed. |
1587 PostTaskAndReplyWithResultForDBThread( | 1595 PostTaskAndReplyWithResultForDBThread( |
1588 FROM_HERE, | 1596 FROM_HERE, |
1589 base::Bind(&InitializeTemporaryOriginsInfoOnDBThread, | 1597 base::Bind(&InitializeTemporaryOriginsInfoOnDBThread, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1622 // |database_|, therefore we can be sure that database_ is alive when this | 1630 // |database_|, therefore we can be sure that database_ is alive when this |
1623 // task runs. | 1631 // task runs. |
1624 base::PostTaskAndReplyWithResult( | 1632 base::PostTaskAndReplyWithResult( |
1625 db_thread_.get(), | 1633 db_thread_.get(), |
1626 from_here, | 1634 from_here, |
1627 base::Bind(task, base::Unretained(database_.get())), | 1635 base::Bind(task, base::Unretained(database_.get())), |
1628 reply); | 1636 reply); |
1629 } | 1637 } |
1630 | 1638 |
1631 } // namespace quota | 1639 } // namespace quota |
OLD | NEW |