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

Side by Side Diff: webkit/quota/quota_temporary_storage_evictor.h

Issue 7002024: Implement QuotaTemporaryStorageEvictor. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Cleaned-up with using Timer. (No clean-up for the unit-test.) Created 9 years, 7 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 | Annotate | Revision Log
OLDNEW
(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/message_loop_proxy.h"
10 #include "base/memory/scoped_callback_factory.h"
11 #include "base/timer.h"
12 #include "webkit/quota/quota_manager.h"
13 #include "webkit/quota/quota_types.h"
14
15 class GURL;
16
17 namespace quota {
18
19 class QuotaTemporaryStorageEvictor {
20 public:
21 QuotaTemporaryStorageEvictor(
22 QuotaEvictionHandler* quota_eviction_handler,
23 int64 target_available_space,
24 int64 delay_ms,
25 scoped_refptr<base::MessageLoopProxy> io_thread);
26 virtual ~QuotaTemporaryStorageEvictor();
27
28 void Start();
29
30 void OnQuotaManagerDestroyedOnIOThread();
31
32 bool repeated_eviction() const { return repeated_eviction_; }
33 void set_repeated_eviction(bool repeated_eviction) {
34 repeated_eviction_ = repeated_eviction;
35 }
36
37 static const double kUsageRatioToBeEvicted;
38 const int64 physical_available_space_to_be_evicted;
39
40 private:
41 friend struct QuotaTemporaryStorageEvictorDeleter;
42 friend class QuotaTemporaryStorageEvictorTest;
43
44 void MayStartEviction(int delay_ms);
45 void GetUsageAndQuotaThenEvict();
46 void EvictIfRequired(
47 QuotaStatusCode status,
48 int64 usage,
49 int64 quota,
50 int64 physical_available_space);
51 void DoEvict(const GURL& origin);
52 void OnEvictionCompleted(QuotaStatusCode status);
53
54 QuotaEvictionHandler* quota_eviction_handler_;
55
56 int64 target_available_space_;
57 int64 delay_ms_;
58 bool repeated_eviction_;
59 scoped_refptr<base::MessageLoopProxy> io_thread_;
60
61 base::OneShotTimer<QuotaTemporaryStorageEvictor> timer_;
62
63 base::ScopedCallbackFactory<QuotaTemporaryStorageEvictor> callback_factory_;
64
65 DISALLOW_COPY_AND_ASSIGN(QuotaTemporaryStorageEvictor);
66 };
67
68 } // namespace quota
69
70 #endif // WEBKIT_QUOTA_QUOTA_TEMPORARY_STORAGE_EVICTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698