Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 | |
| 14 namespace appcache { | 16 namespace appcache { |
| 15 | 17 |
| 16 // The appcache system uses two threads, an IO thread and a DB thread. | 18 // The appcache system uses two threads, an IO thread and a DB thread. |
| 17 // It does not create these threads, the embedder is responsible for | 19 // It does not create these threads, the embedder is responsible for |
| 18 // providing them to the appcache library by providing a concrete | 20 // providing them to the appcache library by providing a concrete |
| 19 // implementation of the PostTask and CurrentlyOn methods declared here, | 21 // implementation of the PostTask and CurrentlyOn methods declared here, |
| 20 // and by calling the InitIDs method prior to using the appcache library. | 22 // 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. | |
| 21 class AppCacheThread { | 25 class AppCacheThread { |
| 22 public: | 26 public: |
| 23 static void InitIDs(int db, int io) { | 27 static void Init(int db, int io, MessageLoop* disk_cache_thread) { |
|
rvargas (doing something else)
2010/03/18 22:17:07
I'm sad for the lack of symmetry but I see that th
| |
| 24 db_ = db; | 28 db_ = db; |
| 25 io_ = io; | 29 io_ = io; |
| 30 disk_cache_thread_ = disk_cache_thread; | |
| 26 } | 31 } |
| 27 static int db() { return db_; } | 32 static int db() { return db_; } |
| 28 static int io() { return io_; } | 33 static int io() { return io_; } |
| 34 static MessageLoop* disk_cache_thread() { return disk_cache_thread_; } | |
| 29 | 35 |
| 30 static bool PostTask(int id, | 36 static bool PostTask(int id, |
| 31 const tracked_objects::Location& from_here, | 37 const tracked_objects::Location& from_here, |
| 32 Task* task); | 38 Task* task); |
| 33 static bool CurrentlyOn(int id); | 39 static bool CurrentlyOn(int id); |
| 34 | 40 |
| 35 template <class T> | 41 template <class T> |
| 36 static bool DeleteSoon(int id, | 42 static bool DeleteSoon(int id, |
| 37 const tracked_objects::Location& from_here, | 43 const tracked_objects::Location& from_here, |
| 38 T* object) { | 44 T* object) { |
| 39 return PostTask(id, from_here, new DeleteTask<T>(object)); | 45 return PostTask(id, from_here, new DeleteTask<T>(object)); |
| 40 } | 46 } |
| 41 | 47 |
| 42 private: | 48 private: |
| 43 AppCacheThread(); | 49 AppCacheThread(); |
| 44 ~AppCacheThread(); | 50 ~AppCacheThread(); |
| 45 | 51 |
| 46 static int db_; | 52 static int db_; |
| 47 static int io_; | 53 static int io_; |
| 54 static MessageLoop* disk_cache_thread_; | |
| 48 }; | 55 }; |
| 49 | 56 |
| 50 } // namespace appcache | 57 } // namespace appcache |
| 51 | 58 |
| 52 #endif // WEBKIT_APPCACHE_APPCACHE_THREAD_H_ | 59 #endif // WEBKIT_APPCACHE_APPCACHE_THREAD_H_ |
| OLD | NEW |