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

Side by Side Diff: storage/browser/quota/quota_temporary_storage_evictor.h

Issue 2592793002: Revert of Change how the quota system computes the total poolsize for temporary storage (Closed)
Patch Set: Created 4 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef STORAGE_BROWSER_QUOTA_QUOTA_TEMPORARY_STORAGE_EVICTOR_H_ 5 #ifndef STORAGE_BROWSER_QUOTA_QUOTA_TEMPORARY_STORAGE_EVICTOR_H_
6 #define STORAGE_BROWSER_QUOTA_QUOTA_TEMPORARY_STORAGE_EVICTOR_H_ 6 #define STORAGE_BROWSER_QUOTA_QUOTA_TEMPORARY_STORAGE_EVICTOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 13
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/threading/non_thread_safe.h" 16 #include "base/threading/non_thread_safe.h"
17 #include "base/timer/timer.h" 17 #include "base/timer/timer.h"
18 #include "storage/browser/storage_browser_export.h" 18 #include "storage/browser/storage_browser_export.h"
19 #include "storage/common/quota/quota_types.h" 19 #include "storage/common/quota/quota_types.h"
20 20
21 class GURL; 21 class GURL;
22 22
23 namespace content { 23 namespace content {
24 class QuotaTemporaryStorageEvictorTest; 24 class QuotaTemporaryStorageEvictorTest;
25 } 25 }
26 26
27 namespace storage { 27 namespace storage {
28 28
29 class QuotaEvictionHandler; 29 class QuotaEvictionHandler;
30 struct QuotaSettings; 30 struct UsageAndQuota;
31 31
32 class STORAGE_EXPORT QuotaTemporaryStorageEvictor : public base::NonThreadSafe { 32 class STORAGE_EXPORT QuotaTemporaryStorageEvictor : public base::NonThreadSafe {
33 public: 33 public:
34 struct Statistics { 34 struct Statistics {
35 Statistics() 35 Statistics()
36 : num_errors_on_evicting_origin(0), 36 : num_errors_on_evicting_origin(0),
37 num_errors_on_getting_usage_and_quota(0), 37 num_errors_on_getting_usage_and_quota(0),
38 num_evicted_origins(0), 38 num_evicted_origins(0),
39 num_eviction_rounds(0), 39 num_eviction_rounds(0),
40 num_skipped_eviction_rounds(0) {} 40 num_skipped_eviction_rounds(0) {}
(...skipping 30 matching lines...) Expand all
71 71
72 QuotaTemporaryStorageEvictor(QuotaEvictionHandler* quota_eviction_handler, 72 QuotaTemporaryStorageEvictor(QuotaEvictionHandler* quota_eviction_handler,
73 int64_t interval_ms); 73 int64_t interval_ms);
74 virtual ~QuotaTemporaryStorageEvictor(); 74 virtual ~QuotaTemporaryStorageEvictor();
75 75
76 void GetStatistics(std::map<std::string, int64_t>* statistics); 76 void GetStatistics(std::map<std::string, int64_t>* statistics);
77 void ReportPerRoundHistogram(); 77 void ReportPerRoundHistogram();
78 void ReportPerHourHistogram(); 78 void ReportPerHourHistogram();
79 void Start(); 79 void Start();
80 80
81 void reset_min_available_disk_space_to_start_eviction() {
82 min_available_to_start_eviction_ =
83 kMinAvailableToStartEvictionNotSpecified;
84 }
85 void set_min_available_disk_space_to_start_eviction(int64_t value) {
86 min_available_to_start_eviction_ = value;
87 }
88
81 private: 89 private:
82 friend class content::QuotaTemporaryStorageEvictorTest; 90 friend class content::QuotaTemporaryStorageEvictorTest;
83 91
84 void StartEvictionTimerWithDelay(int delay_ms); 92 void StartEvictionTimerWithDelay(int delay_ms);
85 void ConsiderEviction(); 93 void ConsiderEviction();
86 void OnGotEvictionRoundInfo(QuotaStatusCode status, 94 void OnGotVolumeInfo(bool success,
87 const QuotaSettings& settings, 95 uint64_t available_space,
88 int64_t available_space, 96 uint64_t total_size);
89 int64_t total_space, 97 void OnGotUsageAndQuotaForEviction(
90 int64_t current_usage, 98 int64_t must_remain_available_space,
91 bool current_usage_is_complete); 99 QuotaStatusCode status,
100 const UsageAndQuota& quota_and_usage);
92 void OnGotEvictionOrigin(const GURL& origin); 101 void OnGotEvictionOrigin(const GURL& origin);
93 void OnEvictionComplete(QuotaStatusCode status); 102 void OnEvictionComplete(QuotaStatusCode status);
94 103
95 void OnEvictionRoundStarted(); 104 void OnEvictionRoundStarted();
96 void OnEvictionRoundFinished(); 105 void OnEvictionRoundFinished();
97 106
107 // This is only used for tests.
108 void set_repeated_eviction(bool repeated_eviction) {
109 repeated_eviction_ = repeated_eviction;
110 }
111
112 static const int kMinAvailableToStartEvictionNotSpecified;
113
114 int64_t min_available_to_start_eviction_;
115
98 // Not owned; quota_eviction_handler owns us. 116 // Not owned; quota_eviction_handler owns us.
99 QuotaEvictionHandler* quota_eviction_handler_; 117 QuotaEvictionHandler* quota_eviction_handler_;
100 118
101 Statistics statistics_; 119 Statistics statistics_;
102 Statistics previous_statistics_; 120 Statistics previous_statistics_;
103 EvictionRoundStatistics round_statistics_; 121 EvictionRoundStatistics round_statistics_;
104 base::Time time_of_end_of_last_nonskipped_round_; 122 base::Time time_of_end_of_last_nonskipped_round_;
105 base::Time time_of_end_of_last_round_; 123 base::Time time_of_end_of_last_round_;
106 std::set<GURL> in_progress_eviction_origins_; 124 std::set<GURL> in_progress_eviction_origins_;
107 125
108 int64_t interval_ms_; 126 int64_t interval_ms_;
109 bool timer_disabled_for_testing_; 127 bool repeated_eviction_;
110 128
111 base::OneShotTimer eviction_timer_; 129 base::OneShotTimer eviction_timer_;
112 base::RepeatingTimer histogram_timer_; 130 base::RepeatingTimer histogram_timer_;
113 base::WeakPtrFactory<QuotaTemporaryStorageEvictor> weak_factory_; 131 base::WeakPtrFactory<QuotaTemporaryStorageEvictor> weak_factory_;
114 132
115 DISALLOW_COPY_AND_ASSIGN(QuotaTemporaryStorageEvictor); 133 DISALLOW_COPY_AND_ASSIGN(QuotaTemporaryStorageEvictor);
116 }; 134 };
117 135
118 } // namespace storage 136 } // namespace storage
119 137
120 #endif // STORAGE_BROWSER_QUOTA_QUOTA_TEMPORARY_STORAGE_EVICTOR_H_ 138 #endif // STORAGE_BROWSER_QUOTA_QUOTA_TEMPORARY_STORAGE_EVICTOR_H_
OLDNEW
« no previous file with comments | « storage/browser/quota/quota_settings.cc ('k') | storage/browser/quota/quota_temporary_storage_evictor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698