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

Side by Side Diff: webkit/appcache/appcache_thread.h

Issue 2249005: AppCache: Use a dedicated thread for the disk cache. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Bound to IO thread Created 10 years, 6 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
« no previous file with comments | « webkit/appcache/appcache_storage_impl_unittest.cc ('k') | webkit/appcache/appcache_thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WEBKIT_APPCACHE_APPCACHE_THREAD_H_ 5 #ifndef WEBKIT_APPCACHE_APPCACHE_THREAD_H_
6 #define WEBKIT_APPCACHE_APPCACHE_THREAD_H_ 6 #define WEBKIT_APPCACHE_APPCACHE_THREAD_H_
7 7
8 #include "base/task.h" 8 #include "base/task.h"
9 9
10 namespace tracked_objects { 10 namespace tracked_objects {
11 class Location; 11 class Location;
12 } 12 }
13 13
14 class MessageLoop;
15
16 namespace appcache { 14 namespace appcache {
17 15
18 // The appcache system uses two threads, an IO thread and a DB thread. 16 // The appcache system uses two threads, an IO thread and a DB thread.
19 // It does not create these threads, the embedder is responsible for 17 // It does not create these threads, the embedder is responsible for
20 // providing them to the appcache library by providing a concrete 18 // providing them to the appcache library by providing a concrete
21 // implementation of the PostTask and CurrentlyOn methods declared here, 19 // implementation of the PostTask and CurrentlyOn methods declared here,
22 // and by calling the Init method prior to using the appcache library. 20 // and by calling the Init method prior to using the appcache library.
23 // The disk_cache also requires the embedder to provide a thread message
24 // loop.
25 class AppCacheThread { 21 class AppCacheThread {
26 public: 22 public:
27 static void Init(int db, int io, MessageLoop* disk_cache_thread) { 23 static void Init(int db, int io) {
28 db_ = db; 24 db_ = db;
29 io_ = io; 25 io_ = io;
30 disk_cache_thread_ = disk_cache_thread;
31 } 26 }
32 static int db() { return db_; } 27 static int db() { return db_; }
33 static int io() { return io_; } 28 static int io() { return io_; }
34 static MessageLoop* disk_cache_thread() { return disk_cache_thread_; }
35 29
36 static bool PostTask(int id, 30 static bool PostTask(int id,
37 const tracked_objects::Location& from_here, 31 const tracked_objects::Location& from_here,
38 Task* task); 32 Task* task);
39 static bool CurrentlyOn(int id); 33 static bool CurrentlyOn(int id);
40 34
41 template <class T> 35 template <class T>
42 static bool DeleteSoon(int id, 36 static bool DeleteSoon(int id,
43 const tracked_objects::Location& from_here, 37 const tracked_objects::Location& from_here,
44 T* object) { 38 T* object) {
45 return PostTask(id, from_here, new DeleteTask<T>(object)); 39 return PostTask(id, from_here, new DeleteTask<T>(object));
46 } 40 }
47 41
48 private: 42 private:
49 AppCacheThread(); 43 AppCacheThread();
50 ~AppCacheThread(); 44 ~AppCacheThread();
51 45
52 static int db_; 46 static int db_;
53 static int io_; 47 static int io_;
54 static MessageLoop* disk_cache_thread_;
55 }; 48 };
56 49
57 } // namespace appcache 50 } // namespace appcache
58 51
59 #endif // WEBKIT_APPCACHE_APPCACHE_THREAD_H_ 52 #endif // WEBKIT_APPCACHE_APPCACHE_THREAD_H_
OLDNEW
« no previous file with comments | « webkit/appcache/appcache_storage_impl_unittest.cc ('k') | webkit/appcache/appcache_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698