| 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..627786ddf1e224b7e19301d0d4b5d1f01e80e282
|
| --- /dev/null
|
| +++ b/webkit/quota/quota_temporary_storage_evictor.h
|
| @@ -0,0 +1,95 @@
|
| +// 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/ref_counted.h"
|
| +#include "base/memory/scoped_callback_factory.h"
|
| +#include "webkit/quota/quota_database.h"
|
| +#include "webkit/quota/quota_manager.h"
|
| +#include "webkit/quota/quota_task.h"
|
| +#include "webkit/quota/quota_types.h"
|
| +
|
| +class GURL;
|
| +
|
| +namespace quota {
|
| +
|
| +struct QuotaTemporaryStorageEvictorDeleter;
|
| +
|
| +class QuotaTemporaryStorageEvictor
|
| + : public base::RefCountedThreadSafe<QuotaTemporaryStorageEvictor,
|
| + QuotaTemporaryStorageEvictorDeleter> {
|
| + public:
|
| + // Constructed on the io_thread.
|
| + QuotaTemporaryStorageEvictor(
|
| + int64 target_available_space,
|
| + int64 delay_ms,
|
| + scoped_refptr<base::MessageLoopProxy> io_message_loop);
|
| + virtual ~QuotaTemporaryStorageEvictor();
|
| +
|
| + // TODO(dmikurube): Make it a private friend of QuotaManager ?
|
| + void RegisterQuotaManagerOnIOThread(QuotaEvictionHandler* quota_manager);
|
| +
|
| + // It can be called from any thread.
|
| + // It posts a task to the io_thread internally.
|
| + void Start();
|
| +
|
| + // It must be called on the io_thread.
|
| + 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 Evict(bool delete_immediately);
|
| +
|
| + // They must be called-back from the io_thread.
|
| + void OnGottenUsageAndQuotaOnIOThread(
|
| + QuotaStatusCode status,
|
| + int64 usage,
|
| + int64 quota,
|
| + int64 physical_available_space);
|
| + void OnEvictionCompletedOnIOThread(
|
| + QuotaStatusCode status);
|
| +
|
| + // They must be called on the io_thread.
|
| + void CallEvictOriginOnIOThread(const GURL& origin);
|
| + void CallGetUsageAndQuotaOnIOThread();
|
| +
|
| + void DeleteOnCorrectThread() const;
|
| +
|
| + // This pointer must be accessed in the io_thread.
|
| + QuotaEvictionHandler* quota_manager_;
|
| +
|
| + int64 target_available_space_;
|
| + int64 delay_ms_;
|
| + bool repeated_eviction_;
|
| + scoped_refptr<base::MessageLoopProxy> io_message_loop_;
|
| +
|
| + base::ScopedCallbackFactory<QuotaTemporaryStorageEvictor> callback_factory_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(QuotaTemporaryStorageEvictor);
|
| +};
|
| +
|
| +struct QuotaTemporaryStorageEvictorDeleter {
|
| + static void Destruct(const QuotaTemporaryStorageEvictor* evictor) {
|
| + LOG(ERROR) << "Deleter::Destruct";
|
| + evictor->DeleteOnCorrectThread();
|
| + }
|
| +};
|
| +
|
| +} // namespace quota
|
| +
|
| +#endif // WEBKIT_QUOTA_QUOTA_TEMPORARY_STORAGE_EVICTOR_H_
|
|
|