blob: 1102dacfca2c6798c1ce1dbbc3d4948737e88007 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
// Copyright (c) 2012 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_TASK_H_
#define WEBKIT_QUOTA_QUOTA_TASK_H_
#include <set>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/sequenced_task_runner_helpers.h"
#include "webkit/storage/webkit_storage_export.h"
namespace base {
class SingleThreadTaskRunner;
class TaskRunner;
}
namespace quota {
class QuotaTaskObserver;
// A base class for quota tasks.
// TODO(kinuko): Revise this using base::Callback.
class QuotaTask {
public:
void Start();
protected:
explicit QuotaTask(QuotaTaskObserver* observer);
virtual ~QuotaTask();
// The task body.
virtual void Run() = 0;
// Called upon completion, on the original message loop.
virtual void Completed() = 0;
// Called when the task is aborted.
virtual void Aborted() {}
void CallCompleted();
// Call this to delete itself.
void DeleteSoon();
QuotaTaskObserver* observer() const { return observer_; }
base::SingleThreadTaskRunner* original_task_runner() const {
return original_task_runner_;
}
private:
friend class base::DeleteHelper<QuotaTask>;
friend class QuotaTaskObserver;
void Abort();
QuotaTaskObserver* observer_;
scoped_refptr<base::SingleThreadTaskRunner> original_task_runner_;
bool delete_scheduled_;
};
class WEBKIT_STORAGE_EXPORT QuotaTaskObserver {
protected:
friend class QuotaTask;
QuotaTaskObserver();
virtual ~QuotaTaskObserver();
void RegisterTask(QuotaTask* task);
void UnregisterTask(QuotaTask* task);
typedef std::set<QuotaTask*> TaskSet;
TaskSet running_quota_tasks_;
};
}
#endif // WEBKIT_QUOTA_QUOTA_TASK_H_
|