OLD | NEW |
---|---|
(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 #include "webkit/quota/quota_temporary_storage_evictor.h" | |
6 | |
7 #include "webkit/quota/quota_client.h" | |
8 #include "webkit/quota/quota_task.h" | |
9 | |
10 #include <vector> | |
11 #include <list> | |
12 | |
13 namespace quota { | |
14 | |
15 QuotaTemporaryStorageEvictor::QuotaTemporaryStorageEvictor( | |
16 QuotaManager* manager, | |
17 QuotaDatabase* database, | |
18 scoped_refptr<base::MessageLoopProxy> db_message_loop) | |
19 : manager_(manager), | |
20 database_(database), | |
21 db_message_loop_(db_message_loop) { | |
22 } | |
23 | |
24 QuotaTemporaryStorageEvictor::~QuotaTemporaryStorageEvictor() {} | |
25 | |
26 void QuotaTemporaryStorageEvictor::Start() { | |
27 scoped_refptr<EvictTask> task( | |
28 new EvictTask(manager_, database_, 10000, db_message_loop_)); | |
29 task->Start(); | |
30 } | |
31 | |
32 class QuotaTemporaryStorageEvictor::EvictTask : public QuotaDelayedThreadTask { | |
33 public: | |
34 EvictTask( | |
35 QuotaManager* manager, | |
36 QuotaDatabase* database, | |
37 int64 delay_ms, | |
38 scoped_refptr<base::MessageLoopProxy> db_message_loop) | |
39 : QuotaDelayedThreadTask(manager, db_message_loop, delay_ms), | |
40 manager_(manager), | |
41 database_(database) { | |
42 DCHECK(database_); | |
43 } | |
44 | |
45 protected: | |
46 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.
| |
47 /* | |
48 // Return least recently used origins whose used_count is <= | |
49 // |max_used_count| up to |num_origins_limit|. If |max_used_count| is -1, | |
50 // it just returns LRU storages regardless of the used_count value. | |
51 // |num_origins_limit| must be > 0. | |
52 bool GetLRUOrigins(StorageType type, std::vector<GURL>* origins, | |
53 int max_used_count, int num_origins_limit); | |
54 */ | |
55 std::vector<GURL> origins; | |
56 database_->GetLRUOrigins(...); | |
57 | |
58 QuotaClientList clients; | |
59 manager_->GetClients(...); | |
60 | |
61 for (std::vector<GURL>::iterator p = origins.begin(); | |
62 p != origins.end(); | |
63 ++p) { | |
64 for (QuotaClientList::iterator q = clients.begin(); | |
65 q != clients.end(); | |
66 ++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
| |
67 } | |
68 } | |
69 } | |
70 | |
71 virtual void Completed() OVERRIDE { | |
72 } | |
73 | |
74 private: | |
75 QuotaManager* manager_; | |
76 QuotaDatabase* database_; | |
77 }; | |
78 | |
79 } // namespace quota | |
OLD | NEW |