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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 184 |
185 int64 CallSystemGetAmountOfFreeDiskSpace(const base::FilePath& profile_path) { | 185 int64 CallSystemGetAmountOfFreeDiskSpace(const base::FilePath& profile_path) { |
186 // Ensure the profile path exists. | 186 // Ensure the profile path exists. |
187 if(!file_util::CreateDirectory(profile_path)) { | 187 if(!file_util::CreateDirectory(profile_path)) { |
188 LOG(WARNING) << "Create directory failed for path" << profile_path.value(); | 188 LOG(WARNING) << "Create directory failed for path" << profile_path.value(); |
189 return 0; | 189 return 0; |
190 } | 190 } |
191 return base::SysInfo::AmountOfFreeDiskSpace(profile_path); | 191 return base::SysInfo::AmountOfFreeDiskSpace(profile_path); |
192 } | 192 } |
193 | 193 |
194 int64 CalculateTemporaryGlobalQuota(int64 global_usage, | 194 int64 CalculateTemporaryGlobalQuota(int64 global_limited_usage, |
195 int64 global_unlimited_usage, | |
196 int64 available_space) { | 195 int64 available_space) { |
197 DCHECK_GE(global_usage, global_unlimited_usage); | 196 DCHECK_GE(global_limited_usage, 0); |
198 int64 limited_usage = global_usage - global_unlimited_usage; | 197 int64 avail_space = available_space; |
199 int64 avail_space = available_space; | 198 if (avail_space < kint64max - global_limited_usage) { |
200 if (avail_space < kint64max - limited_usage) { | 199 // We basically calculate the temporary quota by |
201 // We basically calculate the temporary quota by | 200 // [available_space + space_used_for_temp] * kTempQuotaRatio, |
202 // [available_space + space_used_for_temp] * kTempQuotaRatio, | 201 // but make sure we'll have no overflow. |
203 // but make sure we'll have no overflow. | 202 avail_space += global_limited_usage; |
204 avail_space += limited_usage; | 203 } |
205 } | 204 return avail_space * kTemporaryQuotaRatioToAvail; |
206 return avail_space * kTemporaryQuotaRatioToAvail; | |
207 } | 205 } |
208 | 206 |
209 void DispatchTemporaryGlobalQuotaCallback( | 207 void DispatchTemporaryGlobalQuotaCallback( |
210 const QuotaCallback& callback, | 208 const QuotaCallback& callback, |
211 QuotaStatusCode status, | 209 QuotaStatusCode status, |
212 const UsageAndQuota& usage_and_quota) { | 210 const UsageAndQuota& usage_and_quota) { |
213 if (status != kQuotaStatusOk) { | 211 if (status != kQuotaStatusOk) { |
214 callback.Run(status, 0); | 212 callback.Run(status, 0); |
215 return; | 213 return; |
216 } | 214 } |
217 | 215 |
218 callback.Run(status, CalculateTemporaryGlobalQuota( | 216 callback.Run(status, CalculateTemporaryGlobalQuota( |
219 usage_and_quota.global_usage, | 217 usage_and_quota.global_limited_usage, |
220 usage_and_quota.global_unlimited_usage, | |
221 usage_and_quota.available_disk_space)); | 218 usage_and_quota.available_disk_space)); |
222 } | 219 } |
223 | 220 |
224 int64 CalculateQuotaWithDiskSpace( | 221 int64 CalculateQuotaWithDiskSpace( |
225 int64 available_disk_space, int64 usage, int64 quota) { | 222 int64 available_disk_space, int64 usage, int64 quota) { |
226 if (available_disk_space < QuotaManager::kMinimumPreserveForSystem || | 223 if (available_disk_space < QuotaManager::kMinimumPreserveForSystem || |
227 quota < usage) { | 224 quota < usage) { |
228 // No more space; cap the quota to the current usage. | 225 // No more space; cap the quota to the current usage. |
229 return usage; | 226 return usage; |
230 } | 227 } |
231 | 228 |
232 available_disk_space -= QuotaManager::kMinimumPreserveForSystem; | 229 available_disk_space -= QuotaManager::kMinimumPreserveForSystem; |
233 if (available_disk_space < quota - usage) | 230 if (available_disk_space < quota - usage) |
234 return available_disk_space + usage; | 231 return available_disk_space + usage; |
235 | 232 |
236 return quota; | 233 return quota; |
237 } | 234 } |
238 | 235 |
239 int64 CalculateTemporaryHostQuota(int64 host_usage, | 236 int64 CalculateTemporaryHostQuota(int64 host_usage, |
240 int64 global_quota, | 237 int64 global_quota, |
241 int64 global_usage, | 238 int64 global_limited_usage) { |
242 int64 global_unlimited_usage) { | 239 DCHECK_GE(global_limited_usage, 0); |
243 DCHECK_GE(global_usage, global_unlimited_usage); | 240 int64 host_quota = global_quota / QuotaManager::kPerHostTemporaryPortion; |
244 int64 limited_global_usage = global_usage - global_unlimited_usage; | 241 if (global_limited_usage > global_quota) |
245 int64 host_quota = global_quota / QuotaManager::kPerHostTemporaryPortion; | 242 host_quota = std::min(host_quota, host_usage); |
246 if (limited_global_usage > global_quota) | 243 return host_quota; |
247 host_quota = std::min(host_quota, host_usage); | |
248 return host_quota; | |
249 } | 244 } |
250 | 245 |
251 void DispatchUsageAndQuotaForWebApps( | 246 void DispatchUsageAndQuotaForWebApps( |
252 StorageType type, | 247 StorageType type, |
253 bool is_incognito, | 248 bool is_incognito, |
254 bool is_unlimited, | 249 bool is_unlimited, |
255 bool can_query_disk_size, | 250 bool can_query_disk_size, |
256 const QuotaManager::GetUsageAndQuotaCallback& callback, | 251 const QuotaManager::GetUsageAndQuotaCallback& callback, |
257 QuotaStatusCode status, | 252 QuotaStatusCode status, |
258 const UsageAndQuota& usage_and_quota) { | 253 const UsageAndQuota& usage_and_quota) { |
259 if (status != kQuotaStatusOk) { | 254 if (status != kQuotaStatusOk) { |
260 callback.Run(status, 0, 0); | 255 callback.Run(status, 0, 0); |
261 return; | 256 return; |
262 } | 257 } |
263 | 258 |
264 int64 usage = usage_and_quota.usage; | 259 int64 usage = usage_and_quota.usage; |
265 int64 quota = usage_and_quota.quota; | 260 int64 quota = usage_and_quota.quota; |
266 | 261 |
267 if (type == kStorageTypeTemporary) { | 262 if (type == kStorageTypeTemporary && !is_unlimited) { |
268 quota = CalculateTemporaryHostQuota( | 263 quota = CalculateTemporaryHostQuota( |
269 usage, quota, | 264 usage, quota, usage_and_quota.global_limited_usage); |
270 usage_and_quota.global_usage, | |
271 usage_and_quota.global_unlimited_usage); | |
272 } | 265 } |
273 | 266 |
274 if (is_incognito) { | 267 if (is_incognito) { |
275 quota = std::min(quota, QuotaManager::kIncognitoDefaultQuotaLimit); | 268 quota = std::min(quota, QuotaManager::kIncognitoDefaultQuotaLimit); |
276 callback.Run(status, usage, quota); | 269 callback.Run(status, usage, quota); |
277 return; | 270 return; |
278 } | 271 } |
279 | 272 |
280 // For apps with unlimited permission or can_query_disk_size is true (and not | 273 // For apps with unlimited permission or can_query_disk_size is true (and not |
281 // in incognito mode). | 274 // in incognito mode). |
282 // We assume we can expose the actual disk size for them and cap the quota by | 275 // We assume we can expose the actual disk size for them and cap the quota by |
283 // the available disk space. | 276 // the available disk space. |
284 if (is_unlimited || can_query_disk_size) { | 277 if (is_unlimited || can_query_disk_size) { |
285 callback.Run( | 278 callback.Run( |
286 status, usage, | 279 status, usage, |
287 CalculateQuotaWithDiskSpace( | 280 CalculateQuotaWithDiskSpace( |
288 usage_and_quota.available_disk_space, | 281 usage_and_quota.available_disk_space, |
289 usage, quota)); | 282 usage, quota)); |
290 return; | 283 return; |
291 } | 284 } |
292 | 285 |
293 callback.Run(status, usage, quota); | 286 callback.Run(status, usage, quota); |
294 } | 287 } |
295 | 288 |
296 } // namespace | 289 } // namespace |
297 | 290 |
298 UsageAndQuota::UsageAndQuota() | 291 UsageAndQuota::UsageAndQuota() |
299 : usage(0), | 292 : usage(0), |
300 global_usage(0), | 293 global_limited_usage(0), |
301 global_unlimited_usage(0), | |
302 quota(0), | 294 quota(0), |
303 available_disk_space(0) { | 295 available_disk_space(0) { |
304 } | 296 } |
305 | 297 |
306 UsageAndQuota::UsageAndQuota( | 298 UsageAndQuota::UsageAndQuota( |
307 int64 usage, | 299 int64 usage, |
308 int64 global_usage, | 300 int64 global_limited_usage, |
309 int64 global_unlimited_usage, | |
310 int64 quota, | 301 int64 quota, |
311 int64 available_disk_space) | 302 int64 available_disk_space) |
312 : usage(usage), | 303 : usage(usage), |
313 global_usage(global_usage), | 304 global_limited_usage(global_limited_usage), |
314 global_unlimited_usage(global_unlimited_usage), | |
315 quota(quota), | 305 quota(quota), |
316 available_disk_space(available_disk_space) { | 306 available_disk_space(available_disk_space) { |
317 } | 307 } |
318 | 308 |
319 class UsageAndQuotaCallbackDispatcher | 309 class UsageAndQuotaCallbackDispatcher |
320 : public QuotaTask, | 310 : public QuotaTask, |
321 public base::SupportsWeakPtr<UsageAndQuotaCallbackDispatcher> { | 311 public base::SupportsWeakPtr<UsageAndQuotaCallbackDispatcher> { |
322 public: | 312 public: |
323 UsageAndQuotaCallbackDispatcher(QuotaManager* manager) | 313 UsageAndQuotaCallbackDispatcher(QuotaManager* manager) |
324 : QuotaTask(manager), | 314 : QuotaTask(manager), |
325 has_usage_(false), | 315 has_usage_(false), |
326 has_global_usage_(false), | 316 has_global_limited_usage_(false), |
327 has_quota_(false), | 317 has_quota_(false), |
328 has_available_disk_space_(false), | 318 has_available_disk_space_(false), |
329 status_(kQuotaStatusUnknown), | 319 status_(kQuotaStatusUnknown), |
330 usage_and_quota_(-1, -1, -1, -1, -1), | 320 usage_and_quota_(-1, -1, -1, -1), |
331 waiting_callbacks_(1) {} | 321 waiting_callbacks_(1) {} |
332 | 322 |
333 virtual ~UsageAndQuotaCallbackDispatcher() {} | 323 virtual ~UsageAndQuotaCallbackDispatcher() {} |
334 | 324 |
335 void WaitForResults(const QuotaManager::UsageAndQuotaCallback& callback) { | 325 void WaitForResults(const QuotaManager::UsageAndQuotaCallback& callback) { |
336 callback_ = callback; | 326 callback_ = callback; |
337 Start(); | 327 Start(); |
338 } | 328 } |
339 | 329 |
340 void set_usage(int64 usage) { | 330 void set_usage(int64 usage) { |
341 usage_and_quota_.usage = usage; | 331 usage_and_quota_.usage = usage; |
342 has_usage_ = true; | 332 has_usage_ = true; |
343 } | 333 } |
344 | 334 |
345 void set_global_usage(int64 global_usage) { | 335 void set_global_limited_usage(int64 global_limited_usage) { |
346 usage_and_quota_.global_usage = global_usage; | 336 usage_and_quota_.global_limited_usage = global_limited_usage; |
347 has_global_usage_ = true; | 337 has_global_limited_usage_ = true; |
348 } | |
349 | |
350 void set_global_unlimited_usage(int64 global_unlimited_usage) { | |
351 usage_and_quota_.global_unlimited_usage = global_unlimited_usage; | |
352 has_global_usage_ = true; | |
353 } | 338 } |
354 | 339 |
355 void set_quota(int64 quota) { | 340 void set_quota(int64 quota) { |
356 usage_and_quota_.quota = quota; | 341 usage_and_quota_.quota = quota; |
357 has_quota_ = true; | 342 has_quota_ = true; |
358 } | 343 } |
359 | 344 |
360 void set_available_disk_space(int64 available_disk_space) { | 345 void set_available_disk_space(int64 available_disk_space) { |
361 usage_and_quota_.available_disk_space = available_disk_space; | 346 usage_and_quota_.available_disk_space = available_disk_space; |
362 has_available_disk_space_ = true; | 347 has_available_disk_space_ = true; |
363 } | 348 } |
364 | 349 |
365 UsageCallback GetHostUsageCallback() { | 350 UsageCallback GetHostUsageCallback() { |
366 ++waiting_callbacks_; | 351 ++waiting_callbacks_; |
367 has_usage_ = true; | 352 has_usage_ = true; |
368 return base::Bind(&UsageAndQuotaCallbackDispatcher::DidGetHostUsage, | 353 return base::Bind(&UsageAndQuotaCallbackDispatcher::DidGetHostUsage, |
369 AsWeakPtr()); | 354 AsWeakPtr()); |
370 } | 355 } |
371 | 356 |
372 GlobalUsageCallback GetGlobalUsageCallback() { | 357 UsageCallback GetGlobalLimitedUsageCallback() { |
373 ++waiting_callbacks_; | 358 ++waiting_callbacks_; |
374 has_global_usage_ = true; | 359 has_global_limited_usage_ = true; |
375 return base::Bind(&UsageAndQuotaCallbackDispatcher::DidGetGlobalUsage, | 360 return base::Bind( |
376 AsWeakPtr()); | 361 &UsageAndQuotaCallbackDispatcher::DidGetGlobalLimitedUsage, |
| 362 AsWeakPtr()); |
377 } | 363 } |
378 | 364 |
379 QuotaCallback GetQuotaCallback() { | 365 QuotaCallback GetQuotaCallback() { |
380 ++waiting_callbacks_; | 366 ++waiting_callbacks_; |
381 has_quota_ = true; | 367 has_quota_ = true; |
382 return base::Bind(&UsageAndQuotaCallbackDispatcher::DidGetQuota, | 368 return base::Bind(&UsageAndQuotaCallbackDispatcher::DidGetQuota, |
383 AsWeakPtr()); | 369 AsWeakPtr()); |
384 } | 370 } |
385 | 371 |
386 QuotaCallback GetAvailableSpaceCallback() { | 372 QuotaCallback GetAvailableSpaceCallback() { |
387 ++waiting_callbacks_; | 373 ++waiting_callbacks_; |
388 has_available_disk_space_ = true; | 374 has_available_disk_space_ = true; |
389 return base::Bind(&UsageAndQuotaCallbackDispatcher::DidGetAvailableSpace, | 375 return base::Bind(&UsageAndQuotaCallbackDispatcher::DidGetAvailableSpace, |
390 AsWeakPtr()); | 376 AsWeakPtr()); |
391 } | 377 } |
392 | 378 |
393 private: | 379 private: |
394 void DidGetHostUsage(int64 usage) { | 380 void DidGetHostUsage(int64 usage) { |
395 if (status_ == kQuotaStatusUnknown) | 381 if (status_ == kQuotaStatusUnknown) |
396 status_ = kQuotaStatusOk; | 382 status_ = kQuotaStatusOk; |
397 usage_and_quota_.usage = usage; | 383 usage_and_quota_.usage = usage; |
398 CheckCompleted(); | 384 CheckCompleted(); |
399 } | 385 } |
400 | 386 |
401 void DidGetGlobalUsage(int64 usage, | 387 void DidGetGlobalLimitedUsage(int64 limited_usage) { |
402 int64 unlimited_usage) { | |
403 if (status_ == kQuotaStatusUnknown) | 388 if (status_ == kQuotaStatusUnknown) |
404 status_ = kQuotaStatusOk; | 389 status_ = kQuotaStatusOk; |
405 usage_and_quota_.global_usage = usage; | 390 usage_and_quota_.global_limited_usage = limited_usage; |
406 usage_and_quota_.global_unlimited_usage = unlimited_usage; | |
407 CheckCompleted(); | 391 CheckCompleted(); |
408 } | 392 } |
409 | 393 |
410 void DidGetQuota(QuotaStatusCode status, int64 quota) { | 394 void DidGetQuota(QuotaStatusCode status, int64 quota) { |
411 if (status_ == kQuotaStatusUnknown || status_ == kQuotaStatusOk) | 395 if (status_ == kQuotaStatusUnknown || status_ == kQuotaStatusOk) |
412 status_ = status; | 396 status_ = status; |
413 usage_and_quota_.quota = quota; | 397 usage_and_quota_.quota = quota; |
414 CheckCompleted(); | 398 CheckCompleted(); |
415 } | 399 } |
416 | 400 |
(...skipping 12 matching lines...) Expand all Loading... |
429 CheckCompleted(); | 413 CheckCompleted(); |
430 } | 414 } |
431 | 415 |
432 virtual void Aborted() OVERRIDE { | 416 virtual void Aborted() OVERRIDE { |
433 callback_.Run(kQuotaErrorAbort, UsageAndQuota()); | 417 callback_.Run(kQuotaErrorAbort, UsageAndQuota()); |
434 DeleteSoon(); | 418 DeleteSoon(); |
435 } | 419 } |
436 | 420 |
437 virtual void Completed() OVERRIDE { | 421 virtual void Completed() OVERRIDE { |
438 DCHECK(!has_usage_ || usage_and_quota_.usage >= 0); | 422 DCHECK(!has_usage_ || usage_and_quota_.usage >= 0); |
439 DCHECK_LE(usage_and_quota_.global_unlimited_usage, | 423 DCHECK(!has_global_limited_usage_ || |
440 usage_and_quota_.global_usage); | 424 usage_and_quota_.global_limited_usage >= 0); |
441 DCHECK(!has_global_usage_ || | |
442 usage_and_quota_.global_unlimited_usage >= 0); | |
443 DCHECK(!has_quota_ || usage_and_quota_.quota >= 0); | 425 DCHECK(!has_quota_ || usage_and_quota_.quota >= 0); |
444 DCHECK(!has_available_disk_space_ || | 426 DCHECK(!has_available_disk_space_ || |
445 usage_and_quota_.available_disk_space >= 0); | 427 usage_and_quota_.available_disk_space >= 0); |
446 | 428 |
447 callback_.Run(status_, usage_and_quota_); | 429 callback_.Run(status_, usage_and_quota_); |
448 DeleteSoon(); | 430 DeleteSoon(); |
449 } | 431 } |
450 | 432 |
451 void CheckCompleted() { | 433 void CheckCompleted() { |
452 if (--waiting_callbacks_ <= 0) | 434 if (--waiting_callbacks_ <= 0) |
453 CallCompleted(); | 435 CallCompleted(); |
454 } | 436 } |
455 | 437 |
456 // For sanity checks, they're checked only when DCHECK is on. | 438 // For sanity checks, they're checked only when DCHECK is on. |
457 bool has_usage_; | 439 bool has_usage_; |
458 bool has_global_usage_; | 440 bool has_global_limited_usage_; |
459 bool has_quota_; | 441 bool has_quota_; |
460 bool has_available_disk_space_; | 442 bool has_available_disk_space_; |
461 | 443 |
462 QuotaStatusCode status_; | 444 QuotaStatusCode status_; |
463 UsageAndQuota usage_and_quota_; | 445 UsageAndQuota usage_and_quota_; |
464 QuotaManager::UsageAndQuotaCallback callback_; | 446 QuotaManager::UsageAndQuotaCallback callback_; |
465 int waiting_callbacks_; | 447 int waiting_callbacks_; |
466 | 448 |
467 DISALLOW_COPY_AND_ASSIGN(UsageAndQuotaCallbackDispatcher); | 449 DISALLOW_COPY_AND_ASSIGN(UsageAndQuotaCallbackDispatcher); |
468 }; | 450 }; |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 bool can_query_disk_size = CanQueryDiskSize(origin); | 833 bool can_query_disk_size = CanQueryDiskSize(origin); |
852 | 834 |
853 UsageAndQuotaCallbackDispatcher* dispatcher = | 835 UsageAndQuotaCallbackDispatcher* dispatcher = |
854 new UsageAndQuotaCallbackDispatcher(this); | 836 new UsageAndQuotaCallbackDispatcher(this); |
855 | 837 |
856 UsageAndQuota usage_and_quota; | 838 UsageAndQuota usage_and_quota; |
857 if (unlimited) { | 839 if (unlimited) { |
858 dispatcher->set_quota(kNoLimit); | 840 dispatcher->set_quota(kNoLimit); |
859 } else { | 841 } else { |
860 if (type == kStorageTypeTemporary) { | 842 if (type == kStorageTypeTemporary) { |
861 GetUsageTracker(type)->GetGlobalUsage( | 843 GetUsageTracker(type)->GetGlobalLimitedUsage( |
862 dispatcher->GetGlobalUsageCallback()); | 844 dispatcher->GetGlobalLimitedUsageCallback()); |
863 GetTemporaryGlobalQuota(dispatcher->GetQuotaCallback()); | 845 GetTemporaryGlobalQuota(dispatcher->GetQuotaCallback()); |
864 } else if (type == kStorageTypePersistent) { | 846 } else if (type == kStorageTypePersistent) { |
865 GetPersistentHostQuota(net::GetHostOrSpecFromURL(origin), | 847 GetPersistentHostQuota(net::GetHostOrSpecFromURL(origin), |
866 dispatcher->GetQuotaCallback()); | 848 dispatcher->GetQuotaCallback()); |
867 } else { | 849 } else { |
868 dispatcher->set_quota(kSyncableStorageDefaultHostQuota); | 850 dispatcher->set_quota(kSyncableStorageDefaultHostQuota); |
869 } | 851 } |
870 } | 852 } |
871 | 853 |
872 GetUsageTracker(type)->GetHostUsage(net::GetHostOrSpecFromURL(origin), | 854 GetUsageTracker(type)->GetHostUsage(net::GetHostOrSpecFromURL(origin), |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 return; | 965 return; |
984 } | 966 } |
985 | 967 |
986 if (temporary_quota_override_ > 0) { | 968 if (temporary_quota_override_ > 0) { |
987 callback.Run(kQuotaStatusOk, temporary_quota_override_); | 969 callback.Run(kQuotaStatusOk, temporary_quota_override_); |
988 return; | 970 return; |
989 } | 971 } |
990 | 972 |
991 UsageAndQuotaCallbackDispatcher* dispatcher = | 973 UsageAndQuotaCallbackDispatcher* dispatcher = |
992 new UsageAndQuotaCallbackDispatcher(this); | 974 new UsageAndQuotaCallbackDispatcher(this); |
993 GetGlobalUsage(kStorageTypeTemporary, | 975 GetUsageTracker(kStorageTypeTemporary)-> |
994 dispatcher->GetGlobalUsageCallback()); | 976 GetGlobalLimitedUsage(dispatcher->GetGlobalLimitedUsageCallback()); |
995 GetAvailableSpace(dispatcher->GetAvailableSpaceCallback()); | 977 GetAvailableSpace(dispatcher->GetAvailableSpaceCallback()); |
996 dispatcher->WaitForResults( | 978 dispatcher->WaitForResults( |
997 base::Bind(&DispatchTemporaryGlobalQuotaCallback, callback)); | 979 base::Bind(&DispatchTemporaryGlobalQuotaCallback, callback)); |
998 } | 980 } |
999 | 981 |
1000 void QuotaManager::SetTemporaryGlobalOverrideQuota( | 982 void QuotaManager::SetTemporaryGlobalOverrideQuota( |
1001 int64 new_quota, const QuotaCallback& callback) { | 983 int64 new_quota, const QuotaCallback& callback) { |
1002 LazyInitialize(); | 984 LazyInitialize(); |
1003 | 985 |
1004 if (new_quota < 0) { | 986 if (new_quota < 0) { |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 eviction_context_.evict_origin_data_callback = callback; | 1425 eviction_context_.evict_origin_data_callback = callback; |
1444 | 1426 |
1445 DeleteOriginData(origin, type, QuotaClient::kAllClientsMask, | 1427 DeleteOriginData(origin, type, QuotaClient::kAllClientsMask, |
1446 base::Bind(&QuotaManager::DidOriginDataEvicted, | 1428 base::Bind(&QuotaManager::DidOriginDataEvicted, |
1447 weak_factory_.GetWeakPtr())); | 1429 weak_factory_.GetWeakPtr())); |
1448 } | 1430 } |
1449 | 1431 |
1450 void QuotaManager::GetUsageAndQuotaForEviction( | 1432 void QuotaManager::GetUsageAndQuotaForEviction( |
1451 const UsageAndQuotaCallback& callback) { | 1433 const UsageAndQuotaCallback& callback) { |
1452 DCHECK(io_thread_->BelongsToCurrentThread()); | 1434 DCHECK(io_thread_->BelongsToCurrentThread()); |
| 1435 LazyInitialize(); |
1453 | 1436 |
1454 UsageAndQuotaCallbackDispatcher* dispatcher = | 1437 UsageAndQuotaCallbackDispatcher* dispatcher = |
1455 new UsageAndQuotaCallbackDispatcher(this); | 1438 new UsageAndQuotaCallbackDispatcher(this); |
1456 GetGlobalUsage(kStorageTypeTemporary, | 1439 GetUsageTracker(kStorageTypeTemporary)-> |
1457 dispatcher->GetGlobalUsageCallback()); | 1440 GetGlobalLimitedUsage(dispatcher->GetGlobalLimitedUsageCallback()); |
1458 GetTemporaryGlobalQuota(dispatcher->GetQuotaCallback()); | 1441 GetTemporaryGlobalQuota(dispatcher->GetQuotaCallback()); |
1459 GetAvailableSpace(dispatcher->GetAvailableSpaceCallback()); | 1442 GetAvailableSpace(dispatcher->GetAvailableSpaceCallback()); |
1460 dispatcher->WaitForResults(callback); | 1443 dispatcher->WaitForResults(callback); |
1461 } | 1444 } |
1462 | 1445 |
1463 void QuotaManager::DidSetTemporaryGlobalOverrideQuota( | 1446 void QuotaManager::DidSetTemporaryGlobalOverrideQuota( |
1464 const QuotaCallback& callback, | 1447 const QuotaCallback& callback, |
1465 const int64* new_quota, | 1448 const int64* new_quota, |
1466 bool success) { | 1449 bool success) { |
1467 QuotaStatusCode status = kQuotaErrorInvalidAccess; | 1450 QuotaStatusCode status = kQuotaErrorInvalidAccess; |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1676 | 1659 |
1677 QuotaManagerProxy::QuotaManagerProxy( | 1660 QuotaManagerProxy::QuotaManagerProxy( |
1678 QuotaManager* manager, base::SingleThreadTaskRunner* io_thread) | 1661 QuotaManager* manager, base::SingleThreadTaskRunner* io_thread) |
1679 : manager_(manager), io_thread_(io_thread) { | 1662 : manager_(manager), io_thread_(io_thread) { |
1680 } | 1663 } |
1681 | 1664 |
1682 QuotaManagerProxy::~QuotaManagerProxy() { | 1665 QuotaManagerProxy::~QuotaManagerProxy() { |
1683 } | 1666 } |
1684 | 1667 |
1685 } // namespace quota | 1668 } // namespace quota |
OLD | NEW |