Chromium Code Reviews| Index: webkit/quota/quota_temporary_storage_evictor.cc |
| diff --git a/webkit/quota/quota_temporary_storage_evictor.cc b/webkit/quota/quota_temporary_storage_evictor.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3e46f3382f2edd19901f045f0b8717755565e041 |
| --- /dev/null |
| +++ b/webkit/quota/quota_temporary_storage_evictor.cc |
| @@ -0,0 +1,79 @@ |
| +// 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. |
| + |
| +#include "webkit/quota/quota_temporary_storage_evictor.h" |
| + |
| +#include "webkit/quota/quota_client.h" |
| +#include "webkit/quota/quota_task.h" |
| + |
| +#include <vector> |
| +#include <list> |
| + |
| +namespace quota { |
| + |
| +QuotaTemporaryStorageEvictor::QuotaTemporaryStorageEvictor( |
| + QuotaManager* manager, |
| + QuotaDatabase* database, |
| + scoped_refptr<base::MessageLoopProxy> db_message_loop) |
| + : manager_(manager), |
| + database_(database), |
| + db_message_loop_(db_message_loop) { |
| +} |
| + |
| +QuotaTemporaryStorageEvictor::~QuotaTemporaryStorageEvictor() {} |
| + |
| +void QuotaTemporaryStorageEvictor::Start() { |
| + scoped_refptr<EvictTask> task( |
| + new EvictTask(manager_, database_, 10000, db_message_loop_)); |
| + task->Start(); |
| +} |
| + |
| +class QuotaTemporaryStorageEvictor::EvictTask : public QuotaDelayedThreadTask { |
| + public: |
| + EvictTask( |
| + QuotaManager* manager, |
| + QuotaDatabase* database, |
| + int64 delay_ms, |
| + scoped_refptr<base::MessageLoopProxy> db_message_loop) |
| + : QuotaDelayedThreadTask(manager, db_message_loop, delay_ms), |
| + manager_(manager), |
| + database_(database) { |
| + DCHECK(database_); |
| + } |
| + |
| + protected: |
| + virtual void RunOnTargetThread() OVERRIDE { |
|
kinuko
2011/05/11 07:49:30
This method can be in the Evictor?
Dai Mikurube (NOT FULLTIME)
2011/05/11 11:23:50
Moved.
|
| + /* |
| + // Return least recently used origins whose used_count is <= |
| + // |max_used_count| up to |num_origins_limit|. If |max_used_count| is -1, |
| + // it just returns LRU storages regardless of the used_count value. |
| + // |num_origins_limit| must be > 0. |
| + bool GetLRUOrigins(StorageType type, std::vector<GURL>* origins, |
| + int max_used_count, int num_origins_limit); |
| + */ |
| + std::vector<GURL> origins; |
| + database_->GetLRUOrigins(...); |
| + |
| + QuotaClientList clients; |
| + manager_->GetClients(...); |
| + |
| + for (std::vector<GURL>::iterator p = origins.begin(); |
| + p != origins.end(); |
| + ++p) { |
| + for (QuotaClientList::iterator q = clients.begin(); |
| + q != clients.end(); |
| + ++q) { |
|
kinuko
2011/05/11 07:49:30
Conceptually the main loop would look like that.
Dai Mikurube (NOT FULLTIME)
2011/05/11 11:23:50
Yeah, it was just a conceptual code. Changed it w
|
| + } |
| + } |
| + } |
| + |
| + virtual void Completed() OVERRIDE { |
| + } |
| + |
| + private: |
| + QuotaManager* manager_; |
| + QuotaDatabase* database_; |
| +}; |
| + |
| +} // namespace quota |