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

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

Issue 7002024: Implement QuotaTemporaryStorageEvictor. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Catching up the latest 7003021. 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 #include "webkit/quota/quota_temporary_storage_evictor.h"
6
7 #include "base/message_loop.h"
8 #include "base/task.h"
9 #include "googleurl/src/gurl.h"
10 #include "webkit/quota/quota_client.h"
11
12 #include <vector>
13 #include <list>
14
15 namespace quota {
16
17 QuotaTemporaryStorageEvictor::QuotaTemporaryStorageEvictor(
18 QuotaManager* manager,
19 QuotaDatabase* database,
20 int64 delay_ms,
21 scoped_refptr<base::MessageLoopProxy> db_message_loop)
22 : manager_(manager),
23 database_(database),
24 delay_ms_(delay_ms),
25 db_message_loop_(db_message_loop),
26 num_clients_(0),
27 num_deleted_(0),
28 runnable_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
29 }
30
31 QuotaTemporaryStorageEvictor::~QuotaTemporaryStorageEvictor() {}
32
33 void QuotaTemporaryStorageEvictor::OnDeleted(QuotaStatusCode status) {
34 LOG(ERROR) << "OnDeleted " << num_deleted_ << "/" << num_clients_;
35 if (status != kQuotaStatusOk) {
36 // Post the next task.
37 MessageLoop::current()->PostDelayedTask(FROM_HERE, runnable_factory_.
38 NewRunnableMethod(&QuotaTemporaryStorageEvictor::Evict), delay_ms_);
kinuko 2011/05/11 12:43:30 How would we do handle other already running clien
Dai Mikurube (NOT FULLTIME) 2011/05/12 02:45:50 Exactly. At first, I've added an error flag.
39 return;
40 }
41
42 ++num_deleted_;
43 DCHECK(num_deleted_ <= num_clients_);
44 if (num_deleted_ == num_clients_) {
45 num_clients_ = 0;
46 num_deleted_ = 0;
47 if (false /* More deletion required? */) {
kinuko 2011/05/11 12:43:30 This part would need some design doc. There's a r
Dai Mikurube (NOT FULLTIME) 2011/05/12 02:45:50 Yes, that's the point. Let's discuss later. I'll
48 // Delete another origin.
49 MessageLoop::current()->PostTask(FROM_HERE, runnable_factory_.
50 NewRunnableMethod(&QuotaTemporaryStorageEvictor::Evict));
51 } else {
52 // Post the next task.
53 MessageLoop::current()->PostDelayedTask(FROM_HERE, runnable_factory_.
54 NewRunnableMethod(&QuotaTemporaryStorageEvictor::Evict), delay_ms_);
55 }
56 }
57 }
58
59 void QuotaTemporaryStorageEvictor::Evict() {
60 LOG(ERROR) << "Evict";
61 GURL origin;
62 // origin = database_->GetLRUOrigin(/* fs_type?, */ in_use);
63 origin = GURL("http://www.example.com"); // test.
64
65 QuotaClientList clients;
66 // manager_->GetClients(...);
67 clients.push_back(NULL); // test.
68 clients.push_back(NULL); // test.
69 clients.push_back(NULL); // test.
70 num_clients_ = clients.size();
kinuko 2011/05/11 12:43:30 :) Let's start thinking how we could test this cla
Dai Mikurube (NOT FULLTIME) 2011/05/12 02:45:50 Before that, I think some method to get a list of
71
72 if (origin.is_empty() || num_clients_ == 0 || num_deleted_ > 0
73 /* || not quota exceeded */) {
Dai Mikurube (NOT FULLTIME) 2011/05/11 12:30:21 Calling QuotaManager and callback would be require
74 MessageLoop::current()->PostDelayedTask(FROM_HERE, runnable_factory_.
75 NewRunnableMethod(&QuotaTemporaryStorageEvictor::Evict), delay_ms_);
76 return;
77 }
78
79 for (QuotaClientList::iterator p = clients.begin();
80 p != clients.end();
81 ++p) {
82 /*
83 p->DeleteOriginData(origin, kStorageTypeTemporary, runnable_factory_.
84 NewRunnableMethod(&QuotaTemporaryStorageEvictor::OnDeleted));
85 */
86 OnDeleted(kQuotaStatusOk); // test.
87 }
88 }
89
90 void QuotaTemporaryStorageEvictor::Start() {
91 // TODO(dmikurube): Check if it's in the db_thread. ( + re-post in db_thread?)
92 MessageLoop::current()->PostTask(FROM_HERE, runnable_factory_.
kinuko 2011/05/11 12:43:30 I think we should replace MessageLoop::current() w
Dai Mikurube (NOT FULLTIME) 2011/05/11 13:59:22 Actually, just replacing with db_message_loop_ cau
Dai Mikurube (NOT FULLTIME) 2011/05/12 04:12:02 FYI: base/task.h:71-72 says // The factories are n
kinuko 2011/05/12 05:41:34 :( ...I see, so it's only to post tasks to the cu
93 NewRunnableMethod(&QuotaTemporaryStorageEvictor::Evict));
94 }
95
96 } // namespace quota
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698