blob: 7a0a70c6c26299193348f12499c8f1d624bf6ade (
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
|
// Copyright (c) 2009 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_APPCACHE_APPCACHE_THREAD_H_
#define WEBKIT_APPCACHE_APPCACHE_THREAD_H_
#include "base/task.h"
namespace tracked_objects {
class Location;
}
class MessageLoop;
namespace appcache {
// The appcache system uses two threads, an IO thread and a DB thread.
// It does not create these threads, the embedder is responsible for
// providing them to the appcache library by providing a concrete
// implementation of the PostTask and CurrentlyOn methods declared here,
// and by calling the Init method prior to using the appcache library.
// The disk_cache also requires the embedder to provide a thread message
// loop.
class AppCacheThread {
public:
static void Init(int db, int io, MessageLoop* disk_cache_thread) {
db_ = db;
io_ = io;
disk_cache_thread_ = disk_cache_thread;
}
static int db() { return db_; }
static int io() { return io_; }
static MessageLoop* disk_cache_thread() { return disk_cache_thread_; }
static bool PostTask(int id,
const tracked_objects::Location& from_here,
Task* task);
static bool CurrentlyOn(int id);
template <class T>
static bool DeleteSoon(int id,
const tracked_objects::Location& from_here,
T* object) {
return PostTask(id, from_here, new DeleteTask<T>(object));
}
private:
AppCacheThread();
~AppCacheThread();
static int db_;
static int io_;
static MessageLoop* disk_cache_thread_;
};
} // namespace appcache
#endif // WEBKIT_APPCACHE_APPCACHE_THREAD_H_
|