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/usage_tracker.h" | 5 #include "webkit/quota/usage_tracker.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <deque> | 8 #include <deque> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 if (found->second.empty()) { | 319 if (found->second.empty()) { |
320 non_cached_origins_by_host_.erase(found); | 320 non_cached_origins_by_host_.erase(found); |
321 cached_hosts_.erase(host); | 321 cached_hosts_.erase(host); |
322 global_usage_retrieved_ = false; | 322 global_usage_retrieved_ = false; |
323 } | 323 } |
324 } | 324 } |
325 } | 325 } |
326 | 326 |
327 void ClientUsageTracker::DidGetOriginsForGlobalUsage( | 327 void ClientUsageTracker::DidGetOriginsForGlobalUsage( |
328 const GlobalUsageCallback& callback, | 328 const GlobalUsageCallback& callback, |
329 const std::set<GURL>& origins, StorageType type) { | 329 const std::set<GURL>& origins) { |
330 OriginSetByHost origins_by_host; | 330 OriginSetByHost origins_by_host; |
331 for (std::set<GURL>::const_iterator itr = origins.begin(); | 331 for (std::set<GURL>::const_iterator itr = origins.begin(); |
332 itr != origins.end(); ++itr) | 332 itr != origins.end(); ++itr) |
333 origins_by_host[net::GetHostOrSpecFromURL(*itr)].insert(*itr); | 333 origins_by_host[net::GetHostOrSpecFromURL(*itr)].insert(*itr); |
334 | 334 |
335 AccumulateInfo* info = new AccumulateInfo; | 335 AccumulateInfo* info = new AccumulateInfo; |
336 // Getting host usage may synchronously return the result if the usage is | 336 // Getting host usage may synchronously return the result if the usage is |
337 // cached, which may in turn dispatch the completion callback before we finish | 337 // cached, which may in turn dispatch the completion callback before we finish |
338 // looping over all hosts (because info->pending_jobs may reach 0 during the | 338 // looping over all hosts (because info->pending_jobs may reach 0 during the |
339 // loop). To avoid this, we add one more pending host as a sentinel and | 339 // loop). To avoid this, we add one more pending host as a sentinel and |
(...skipping 30 matching lines...) Expand all Loading... |
370 DCHECK_GE(unlimited_usage, 0); | 370 DCHECK_GE(unlimited_usage, 0); |
371 if (unlimited_usage > total_usage) | 371 if (unlimited_usage > total_usage) |
372 unlimited_usage = total_usage; | 372 unlimited_usage = total_usage; |
373 | 373 |
374 global_usage_retrieved_ = true; | 374 global_usage_retrieved_ = true; |
375 callback.Run(total_usage, unlimited_usage); | 375 callback.Run(total_usage, unlimited_usage); |
376 } | 376 } |
377 | 377 |
378 void ClientUsageTracker::DidGetOriginsForHostUsage( | 378 void ClientUsageTracker::DidGetOriginsForHostUsage( |
379 const std::string& host, | 379 const std::string& host, |
380 const std::set<GURL>& origins, | 380 const std::set<GURL>& origins) { |
381 StorageType type) { | |
382 GetUsageForOrigins(host, origins); | 381 GetUsageForOrigins(host, origins); |
383 } | 382 } |
384 | 383 |
385 void ClientUsageTracker::GetUsageForOrigins( | 384 void ClientUsageTracker::GetUsageForOrigins( |
386 const std::string& host, | 385 const std::string& host, |
387 const std::set<GURL>& origins) { | 386 const std::set<GURL>& origins) { |
388 AccumulateInfo* info = new AccumulateInfo; | 387 AccumulateInfo* info = new AccumulateInfo; |
389 // Getting origin usage may synchronously return the result if the usage is | 388 // Getting origin usage may synchronously return the result if the usage is |
390 // cached, which may in turn dispatch the completion callback before we finish | 389 // cached, which may in turn dispatch the completion callback before we finish |
391 // looping over all origins (because info->pending_jobs may reach 0 during the | 390 // looping over all origins (because info->pending_jobs may reach 0 during the |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 } | 525 } |
527 | 526 |
528 bool ClientUsageTracker::IsStorageUnlimited(const GURL& origin) const { | 527 bool ClientUsageTracker::IsStorageUnlimited(const GURL& origin) const { |
529 if (type_ == kStorageTypeSyncable) | 528 if (type_ == kStorageTypeSyncable) |
530 return false; | 529 return false; |
531 return special_storage_policy_.get() && | 530 return special_storage_policy_.get() && |
532 special_storage_policy_->IsStorageUnlimited(origin); | 531 special_storage_policy_->IsStorageUnlimited(origin); |
533 } | 532 } |
534 | 533 |
535 } // namespace quota | 534 } // namespace quota |
OLD | NEW |