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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: webkit/quota/quota_temporary_storage_evictor.h
diff --git a/webkit/quota/quota_temporary_storage_evictor.h b/webkit/quota/quota_temporary_storage_evictor.h
new file mode 100644
index 0000000000000000000000000000000000000000..2313454bbd236b29c184dfbc0bdf67dbdfac7a21
--- /dev/null
+++ b/webkit/quota/quota_temporary_storage_evictor.h
@@ -0,0 +1,70 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_QUOTA_QUOTA_TEMPORARY_STORAGE_EVICTOR_H_
+#define WEBKIT_QUOTA_QUOTA_TEMPORARY_STORAGE_EVICTOR_H_
+#pragma once
+
+#include "base/message_loop_proxy.h"
+#include "base/memory/scoped_callback_factory.h"
+#include "base/timer.h"
+#include "webkit/quota/quota_manager.h"
+#include "webkit/quota/quota_types.h"
+
+class GURL;
+
+namespace quota {
+
+class QuotaTemporaryStorageEvictor {
+ public:
+ QuotaTemporaryStorageEvictor(
+ QuotaEvictionHandler* quota_eviction_handler,
+ int64 target_available_space,
+ int64 delay_ms,
+ scoped_refptr<base::MessageLoopProxy> io_thread);
+ virtual ~QuotaTemporaryStorageEvictor();
+
+ void Start();
+
+ void OnQuotaManagerDestroyedOnIOThread();
+
+ bool repeated_eviction() const { return repeated_eviction_; }
+ void set_repeated_eviction(bool repeated_eviction) {
+ repeated_eviction_ = repeated_eviction;
+ }
+
+ static const double kUsageRatioToBeEvicted;
+ const int64 physical_available_space_to_be_evicted;
+
+ private:
+ friend struct QuotaTemporaryStorageEvictorDeleter;
+ friend class QuotaTemporaryStorageEvictorTest;
+
+ void MayStartEviction(int delay_ms);
+ void GetUsageAndQuotaThenEvict();
+ void EvictIfRequired(
+ QuotaStatusCode status,
+ int64 usage,
+ int64 quota,
+ int64 physical_available_space);
+ void DoEvict(const GURL& origin);
+ void OnEvictionCompleted(QuotaStatusCode status);
+
+ QuotaEvictionHandler* quota_eviction_handler_;
+
+ int64 target_available_space_;
+ int64 delay_ms_;
+ bool repeated_eviction_;
+ scoped_refptr<base::MessageLoopProxy> io_thread_;
+
+ base::OneShotTimer<QuotaTemporaryStorageEvictor> timer_;
+
+ base::ScopedCallbackFactory<QuotaTemporaryStorageEvictor> callback_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(QuotaTemporaryStorageEvictor);
+};
+
+} // namespace quota
+
+#endif // WEBKIT_QUOTA_QUOTA_TEMPORARY_STORAGE_EVICTOR_H_

Powered by Google App Engine
This is Rietveld 408576698