Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: storage/browser/quota/client_usage_tracker.cc

Issue 2236453002: storage: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "storage/browser/quota/client_usage_tracker.h" 5 #include "storage/browser/quota/client_usage_tracker.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 28 matching lines...) Expand all
39 39
40 if (found->second.empty()) 40 if (found->second.empty())
41 origins_by_host->erase(host); 41 origins_by_host->erase(host);
42 return true; 42 return true;
43 } 43 }
44 44
45 bool OriginSetContainsOrigin(const OriginSetByHost& origins, 45 bool OriginSetContainsOrigin(const OriginSetByHost& origins,
46 const std::string& host, 46 const std::string& host,
47 const GURL& origin) { 47 const GURL& origin) {
48 OriginSetByHost::const_iterator itr = origins.find(host); 48 OriginSetByHost::const_iterator itr = origins.find(host);
49 return itr != origins.end() && ContainsKey(itr->second, origin); 49 return itr != origins.end() && base::ContainsKey(itr->second, origin);
50 } 50 }
51 51
52 void DidGetGlobalUsageForLimitedGlobalUsage(const UsageCallback& callback, 52 void DidGetGlobalUsageForLimitedGlobalUsage(const UsageCallback& callback,
53 int64_t total_global_usage, 53 int64_t total_global_usage,
54 int64_t global_unlimited_usage) { 54 int64_t global_unlimited_usage) {
55 callback.Run(total_global_usage - global_unlimited_usage); 55 callback.Run(total_global_usage - global_unlimited_usage);
56 } 56 }
57 57
58 } // namespace 58 } // namespace
59 59
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 return; 115 return;
116 } 116 }
117 117
118 client_->GetOriginsForType(type_, base::Bind( 118 client_->GetOriginsForType(type_, base::Bind(
119 &ClientUsageTracker::DidGetOriginsForGlobalUsage, AsWeakPtr(), 119 &ClientUsageTracker::DidGetOriginsForGlobalUsage, AsWeakPtr(),
120 callback)); 120 callback));
121 } 121 }
122 122
123 void ClientUsageTracker::GetHostUsage( 123 void ClientUsageTracker::GetHostUsage(
124 const std::string& host, const UsageCallback& callback) { 124 const std::string& host, const UsageCallback& callback) {
125 if (ContainsKey(cached_hosts_, host) && 125 if (base::ContainsKey(cached_hosts_, host) &&
126 !ContainsKey(non_cached_limited_origins_by_host_, host) && 126 !base::ContainsKey(non_cached_limited_origins_by_host_, host) &&
127 !ContainsKey(non_cached_unlimited_origins_by_host_, host)) { 127 !base::ContainsKey(non_cached_unlimited_origins_by_host_, host)) {
128 // TODO(kinuko): Drop host_usage_map_ cache periodically. 128 // TODO(kinuko): Drop host_usage_map_ cache periodically.
129 callback.Run(GetCachedHostUsage(host)); 129 callback.Run(GetCachedHostUsage(host));
130 return; 130 return;
131 } 131 }
132 132
133 if (!host_usage_accumulators_.Add( 133 if (!host_usage_accumulators_.Add(
134 host, base::Bind(&DidGetHostUsage, callback))) 134 host, base::Bind(&DidGetHostUsage, callback)))
135 return; 135 return;
136 client_->GetOriginsForHost(type_, host, base::Bind( 136 client_->GetOriginsForHost(type_, host, base::Bind(
137 &ClientUsageTracker::DidGetOriginsForHostUsage, AsWeakPtr(), host)); 137 &ClientUsageTracker::DidGetOriginsForHostUsage, AsWeakPtr(), host));
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 } 460 }
461 461
462 bool ClientUsageTracker::IsStorageUnlimited(const GURL& origin) const { 462 bool ClientUsageTracker::IsStorageUnlimited(const GURL& origin) const {
463 if (type_ == kStorageTypeSyncable) 463 if (type_ == kStorageTypeSyncable)
464 return false; 464 return false;
465 return special_storage_policy_.get() && 465 return special_storage_policy_.get() &&
466 special_storage_policy_->IsStorageUnlimited(origin); 466 special_storage_policy_->IsStorageUnlimited(origin);
467 } 467 }
468 468
469 } // namespace storage 469 } // namespace storage
OLDNEW
« no previous file with comments | « storage/browser/fileapi/sandbox_file_system_backend_delegate.cc ('k') | storage/browser/quota/quota_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698