OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef WEBKIT_QUOTA_QUOTA_TEMPORARY_STORAGE_EVICTOR_H_ |
| 6 #define WEBKIT_QUOTA_QUOTA_TEMPORARY_STORAGE_EVICTOR_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/memory/scoped_callback_factory.h" |
| 10 #include "base/timer.h" |
| 11 #include "webkit/quota/quota_types.h" |
| 12 |
| 13 class GURL; |
| 14 |
| 15 namespace base { |
| 16 class MessageLoopProxy; |
| 17 } |
| 18 |
| 19 namespace quota { |
| 20 |
| 21 class QuotaEvictionHandler; |
| 22 |
| 23 class QuotaTemporaryStorageEvictor { |
| 24 public: |
| 25 QuotaTemporaryStorageEvictor( |
| 26 QuotaEvictionHandler* quota_eviction_handler, |
| 27 int64 interval_ms, |
| 28 scoped_refptr<base::MessageLoopProxy> io_thread); |
| 29 virtual ~QuotaTemporaryStorageEvictor(); |
| 30 |
| 31 void Start(); |
| 32 |
| 33 bool repeated_eviction() const { return repeated_eviction_; } |
| 34 void set_repeated_eviction(bool repeated_eviction) { |
| 35 repeated_eviction_ = repeated_eviction; |
| 36 } |
| 37 |
| 38 private: |
| 39 friend class QuotaTemporaryStorageEvictorTest; |
| 40 |
| 41 void StartEvictionTimerWithDelay(int delay_ms); |
| 42 void ConsiderEviction(); |
| 43 void OnGotUsageAndQuotaForEviction( |
| 44 QuotaStatusCode status, |
| 45 int64 usage, |
| 46 int64 quota, |
| 47 int64 available_disk_space); |
| 48 void OnGotLRUOrigin(const GURL& origin); |
| 49 void OnEvictionComplete(QuotaStatusCode status); |
| 50 |
| 51 static const double kUsageRatioToStartEviction; |
| 52 static const int64 kDefaultMinAvailableDiskSpaceToStartEviction; |
| 53 |
| 54 const int64 min_available_disk_space_to_start_eviction_; |
| 55 |
| 56 // Not owned; quota_eviction_handler owns us. |
| 57 QuotaEvictionHandler* quota_eviction_handler_; |
| 58 |
| 59 int64 interval_ms_; |
| 60 bool repeated_eviction_; |
| 61 scoped_refptr<base::MessageLoopProxy> io_thread_; |
| 62 |
| 63 base::OneShotTimer<QuotaTemporaryStorageEvictor> timer_; |
| 64 |
| 65 base::ScopedCallbackFactory<QuotaTemporaryStorageEvictor> callback_factory_; |
| 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(QuotaTemporaryStorageEvictor); |
| 68 }; |
| 69 |
| 70 } // namespace quota |
| 71 |
| 72 #endif // WEBKIT_QUOTA_QUOTA_TEMPORARY_STORAGE_EVICTOR_H_ |
OLD | NEW |