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/quota/mock_storage_client.h" | 5 #include "webkit/quota/mock_storage_client.h" |
6 | 6 |
7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 OriginDataMap::iterator find = origin_data_.find(make_pair(origin_url, type)); | 77 OriginDataMap::iterator find = origin_data_.find(make_pair(origin_url, type)); |
78 DCHECK(find != origin_data_.end()); | 78 DCHECK(find != origin_data_.end()); |
79 find->second += delta; | 79 find->second += delta; |
80 DCHECK_GE(find->second, 0); | 80 DCHECK_GE(find->second, 0); |
81 | 81 |
82 // TODO(tzik): Check quota to prevent usage exceed | 82 // TODO(tzik): Check quota to prevent usage exceed |
83 quota_manager_proxy_->quota_manager()->NotifyStorageModifiedInternal( | 83 quota_manager_proxy_->quota_manager()->NotifyStorageModifiedInternal( |
84 id(), origin_url, type, delta, IncrementMockTime()); | 84 id(), origin_url, type, delta, IncrementMockTime()); |
85 } | 85 } |
86 | 86 |
| 87 void MockStorageClient::TouchAllOriginsAndNotify() { |
| 88 for (OriginDataMap::const_iterator itr = origin_data_.begin(); |
| 89 itr != origin_data_.end(); |
| 90 ++itr) { |
| 91 quota_manager_proxy_->quota_manager()->NotifyStorageModifiedInternal( |
| 92 id(), itr->first.first, itr->first.second, 0, IncrementMockTime()); |
| 93 } |
| 94 } |
| 95 |
87 void MockStorageClient::AddOriginToErrorSet( | 96 void MockStorageClient::AddOriginToErrorSet( |
88 const GURL& origin_url, StorageType type) { | 97 const GURL& origin_url, StorageType type) { |
89 error_origins_.insert(make_pair(origin_url, type)); | 98 error_origins_.insert(make_pair(origin_url, type)); |
90 } | 99 } |
91 | 100 |
92 base::Time MockStorageClient::IncrementMockTime() { | 101 base::Time MockStorageClient::IncrementMockTime() { |
93 ++mock_time_counter_; | 102 ++mock_time_counter_; |
94 return base::Time::FromDoubleT(mock_time_counter_ * 10.0); | 103 return base::Time::FromDoubleT(mock_time_counter_ * 10.0); |
95 } | 104 } |
96 | 105 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 quota_manager_proxy_-> | 210 quota_manager_proxy_-> |
202 NotifyStorageModified(id(), origin_url, type, -delta); | 211 NotifyStorageModified(id(), origin_url, type, -delta); |
203 origin_data_.erase(itr); | 212 origin_data_.erase(itr); |
204 } | 213 } |
205 | 214 |
206 deletion_callbacks_.erase(callback_ptr); | 215 deletion_callbacks_.erase(callback_ptr); |
207 callback->Run(kQuotaStatusOk); | 216 callback->Run(kQuotaStatusOk); |
208 } | 217 } |
209 | 218 |
210 } // namespace quota | 219 } // namespace quota |
OLD | NEW |