Chromium Code Reviews| 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/quota/quota_manager.h" | 5 #include "webkit/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> |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 391 } | 391 } |
| 392 | 392 |
| 393 private: | 393 private: |
| 394 void DidGetHostUsage(int64 usage) { | 394 void DidGetHostUsage(int64 usage) { |
| 395 if (status_ == kQuotaStatusUnknown) | 395 if (status_ == kQuotaStatusUnknown) |
| 396 status_ = kQuotaStatusOk; | 396 status_ = kQuotaStatusOk; |
| 397 usage_and_quota_.usage = usage; | 397 usage_and_quota_.usage = usage; |
| 398 CheckCompleted(); | 398 CheckCompleted(); |
| 399 } | 399 } |
| 400 | 400 |
| 401 void DidGetGlobalUsage(StorageType type, | 401 void DidGetGlobalUsage(int64 usage, |
| 402 int64 usage, | |
| 403 int64 unlimited_usage) { | 402 int64 unlimited_usage) { |
| 404 if (status_ == kQuotaStatusUnknown) | 403 if (status_ == kQuotaStatusUnknown) |
| 405 status_ = kQuotaStatusOk; | 404 status_ = kQuotaStatusOk; |
| 406 usage_and_quota_.global_usage = usage; | 405 usage_and_quota_.global_usage = usage; |
| 407 usage_and_quota_.global_unlimited_usage = unlimited_usage; | 406 usage_and_quota_.global_unlimited_usage = unlimited_usage; |
| 408 CheckCompleted(); | 407 CheckCompleted(); |
| 409 } | 408 } |
| 410 | 409 |
| 411 void DidGetQuota(QuotaStatusCode status, int64 quota) { | 410 void DidGetQuota(QuotaStatusCode status, int64 quota) { |
| 412 if (status_ == kQuotaStatusUnknown || status_ == kQuotaStatusOk) | 411 if (status_ == kQuotaStatusUnknown || status_ == kQuotaStatusOk) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 480 callback_(callback), | 479 callback_(callback), |
| 481 weak_factory_(this) { | 480 weak_factory_(this) { |
| 482 } | 481 } |
| 483 | 482 |
| 484 protected: | 483 protected: |
| 485 virtual void Run() OVERRIDE { | 484 virtual void Run() OVERRIDE { |
| 486 remaining_trackers_ = 3; | 485 remaining_trackers_ = 3; |
| 487 // This will populate cached hosts and usage info. | 486 // This will populate cached hosts and usage info. |
| 488 manager()->GetUsageTracker(kStorageTypeTemporary)->GetGlobalUsage( | 487 manager()->GetUsageTracker(kStorageTypeTemporary)->GetGlobalUsage( |
| 489 base::Bind(&GetUsageInfoTask::DidGetGlobalUsage, | 488 base::Bind(&GetUsageInfoTask::DidGetGlobalUsage, |
| 490 weak_factory_.GetWeakPtr())); | 489 weak_factory_.GetWeakPtr(), |
| 490 kStorageTypeTemporary)); | |
| 491 manager()->GetUsageTracker(kStorageTypePersistent)->GetGlobalUsage( | 491 manager()->GetUsageTracker(kStorageTypePersistent)->GetGlobalUsage( |
| 492 base::Bind(&GetUsageInfoTask::DidGetGlobalUsage, | 492 base::Bind(&GetUsageInfoTask::DidGetGlobalUsage, |
| 493 weak_factory_.GetWeakPtr())); | 493 weak_factory_.GetWeakPtr(), |
| 494 kStorageTypePersistent)); | |
| 494 manager()->GetUsageTracker(kStorageTypeSyncable)->GetGlobalUsage( | 495 manager()->GetUsageTracker(kStorageTypeSyncable)->GetGlobalUsage( |
| 495 base::Bind(&GetUsageInfoTask::DidGetGlobalUsage, | 496 base::Bind(&GetUsageInfoTask::DidGetGlobalUsage, |
| 496 weak_factory_.GetWeakPtr())); | 497 weak_factory_.GetWeakPtr(), |
| 498 kStorageTypeSyncable)); | |
| 497 } | 499 } |
| 498 | 500 |
| 499 virtual void Completed() OVERRIDE { | 501 virtual void Completed() OVERRIDE { |
| 500 callback_.Run(entries_); | 502 callback_.Run(entries_); |
| 501 DeleteSoon(); | 503 DeleteSoon(); |
| 502 } | 504 } |
| 503 | 505 |
| 504 virtual void Aborted() OVERRIDE { | 506 virtual void Aborted() OVERRIDE { |
| 505 callback_.Run(UsageInfoEntries()); | 507 callback_.Run(UsageInfoEntries()); |
| 506 DeleteSoon(); | 508 DeleteSoon(); |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1339 base::Bind( | 1341 base::Bind( |
| 1340 &QuotaManager::DidGetTemporaryGlobalUsageForHistogram, | 1342 &QuotaManager::DidGetTemporaryGlobalUsageForHistogram, |
| 1341 weak_factory_.GetWeakPtr())); | 1343 weak_factory_.GetWeakPtr())); |
| 1342 GetGlobalUsage(kStorageTypePersistent, | 1344 GetGlobalUsage(kStorageTypePersistent, |
| 1343 base::Bind( | 1345 base::Bind( |
| 1344 &QuotaManager::DidGetPersistentGlobalUsageForHistogram, | 1346 &QuotaManager::DidGetPersistentGlobalUsageForHistogram, |
| 1345 weak_factory_.GetWeakPtr())); | 1347 weak_factory_.GetWeakPtr())); |
| 1346 } | 1348 } |
| 1347 | 1349 |
| 1348 void QuotaManager::DidGetTemporaryGlobalUsageForHistogram( | 1350 void QuotaManager::DidGetTemporaryGlobalUsageForHistogram( |
| 1349 StorageType type, | |
| 1350 int64 usage, | 1351 int64 usage, |
| 1351 int64 unlimited_usage) { | 1352 int64 unlimited_usage) { |
| 1352 UMA_HISTOGRAM_MBYTES("Quota.GlobalUsageOfTemporaryStorage", usage); | 1353 UMA_HISTOGRAM_MBYTES("Quota.GlobalUsageOfTemporaryStorage", usage); |
| 1354 StorageType type = kStorageTypeTemporary; | |
| 1353 | 1355 |
| 1354 std::set<GURL> origins; | 1356 std::set<GURL> origins; |
| 1355 GetCachedOrigins(type, &origins); | 1357 GetCachedOrigins(type, &origins); |
|
kinuko
2013/05/22 10:51:33
You could simply specify kStorageTypeTemporary her
tzik
2013/05/22 11:33:48
Done.
| |
| 1356 | 1358 |
| 1357 size_t num_origins = origins.size(); | 1359 size_t num_origins = origins.size(); |
| 1358 size_t protected_origins = 0; | 1360 size_t protected_origins = 0; |
| 1359 size_t unlimited_origins = 0; | 1361 size_t unlimited_origins = 0; |
| 1360 CountOriginType(origins, special_storage_policy_, | 1362 CountOriginType(origins, special_storage_policy_, |
| 1361 &protected_origins, &unlimited_origins); | 1363 &protected_origins, &unlimited_origins); |
| 1362 | 1364 |
| 1363 UMA_HISTOGRAM_COUNTS("Quota.NumberOfTemporaryStorageOrigins", | 1365 UMA_HISTOGRAM_COUNTS("Quota.NumberOfTemporaryStorageOrigins", |
| 1364 num_origins); | 1366 num_origins); |
| 1365 UMA_HISTOGRAM_COUNTS("Quota.NumberOfProtectedTemporaryStorageOrigins", | 1367 UMA_HISTOGRAM_COUNTS("Quota.NumberOfProtectedTemporaryStorageOrigins", |
| 1366 protected_origins); | 1368 protected_origins); |
| 1367 UMA_HISTOGRAM_COUNTS("Quota.NumberOfUnlimitedTemporaryStorageOrigins", | 1369 UMA_HISTOGRAM_COUNTS("Quota.NumberOfUnlimitedTemporaryStorageOrigins", |
| 1368 unlimited_origins); | 1370 unlimited_origins); |
| 1369 } | 1371 } |
| 1370 | 1372 |
| 1371 void QuotaManager::DidGetPersistentGlobalUsageForHistogram( | 1373 void QuotaManager::DidGetPersistentGlobalUsageForHistogram( |
| 1372 StorageType type, | |
| 1373 int64 usage, | 1374 int64 usage, |
| 1374 int64 unlimited_usage) { | 1375 int64 unlimited_usage) { |
| 1375 UMA_HISTOGRAM_MBYTES("Quota.GlobalUsageOfPersistentStorage", usage); | 1376 UMA_HISTOGRAM_MBYTES("Quota.GlobalUsageOfPersistentStorage", usage); |
| 1377 StorageType type = kStorageTypePersistent; | |
| 1376 | 1378 |
| 1377 std::set<GURL> origins; | 1379 std::set<GURL> origins; |
| 1378 GetCachedOrigins(type, &origins); | 1380 GetCachedOrigins(type, &origins); |
|
kinuko
2013/05/22 10:51:33
ditto.
tzik
2013/05/22 11:33:48
Done.
| |
| 1379 | 1381 |
| 1380 size_t num_origins = origins.size(); | 1382 size_t num_origins = origins.size(); |
| 1381 size_t protected_origins = 0; | 1383 size_t protected_origins = 0; |
| 1382 size_t unlimited_origins = 0; | 1384 size_t unlimited_origins = 0; |
| 1383 CountOriginType(origins, special_storage_policy_, | 1385 CountOriginType(origins, special_storage_policy_, |
| 1384 &protected_origins, &unlimited_origins); | 1386 &protected_origins, &unlimited_origins); |
| 1385 | 1387 |
| 1386 UMA_HISTOGRAM_COUNTS("Quota.NumberOfPersistentStorageOrigins", | 1388 UMA_HISTOGRAM_COUNTS("Quota.NumberOfPersistentStorageOrigins", |
| 1387 num_origins); | 1389 num_origins); |
| 1388 UMA_HISTOGRAM_COUNTS("Quota.NumberOfProtectedPersistentStorageOrigins", | 1390 UMA_HISTOGRAM_COUNTS("Quota.NumberOfProtectedPersistentStorageOrigins", |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1676 | 1678 |
| 1677 QuotaManagerProxy::QuotaManagerProxy( | 1679 QuotaManagerProxy::QuotaManagerProxy( |
| 1678 QuotaManager* manager, base::SingleThreadTaskRunner* io_thread) | 1680 QuotaManager* manager, base::SingleThreadTaskRunner* io_thread) |
| 1679 : manager_(manager), io_thread_(io_thread) { | 1681 : manager_(manager), io_thread_(io_thread) { |
| 1680 } | 1682 } |
| 1681 | 1683 |
| 1682 QuotaManagerProxy::~QuotaManagerProxy() { | 1684 QuotaManagerProxy::~QuotaManagerProxy() { |
| 1683 } | 1685 } |
| 1684 | 1686 |
| 1685 } // namespace quota | 1687 } // namespace quota |
| OLD | NEW |