summaryrefslogtreecommitdiffstats
path: root/webkit/tools/test_shell/simple_appcache_system.cc
diff options
context:
space:
mode:
authormichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-23 20:40:57 +0000
committermichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-23 20:40:57 +0000
commit8a4892d8d5ef84d8be7c47ac5e1b5e601f2a77b7 (patch)
treedd56c3b7fb32d93154b58616e4e8368cc2702341 /webkit/tools/test_shell/simple_appcache_system.cc
parentd6b7266a83b8fffe30fd79c9ebe7c155cb5b687d (diff)
downloadchromium_src-8a4892d8d5ef84d8be7c47ac5e1b5e601f2a77b7.zip
chromium_src-8a4892d8d5ef84d8be7c47ac5e1b5e601f2a77b7.tar.gz
chromium_src-8a4892d8d5ef84d8be7c47ac5e1b5e601f2a77b7.tar.bz2
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 implementing the class declared in appcache_thread.h. Also in this CL are two implementations, one for Chrome and another for test_shell. TEST=none BUG=none Review URL: http://codereview.chromium.org/409005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32846 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/test_shell/simple_appcache_system.cc')
-rw-r--r--webkit/tools/test_shell/simple_appcache_system.cc27
1 files changed, 26 insertions, 1 deletions
diff --git a/webkit/tools/test_shell/simple_appcache_system.cc b/webkit/tools/test_shell/simple_appcache_system.cc
index 297005a..0f9d452 100644
--- a/webkit/tools/test_shell/simple_appcache_system.cc
+++ b/webkit/tools/test_shell/simple_appcache_system.cc
@@ -16,7 +16,28 @@ using WebKit::WebApplicationCacheHostClient;
using appcache::WebApplicationCacheHostImpl;
using appcache::AppCacheBackendImpl;
using appcache::AppCacheInterceptor;
+using appcache::AppCacheThread;
+namespace appcache {
+
+// An impl of AppCacheThread we need to provide to the appcache lib.
+
+bool AppCacheThread::PostTask(
+ int id,
+ const tracked_objects::Location& from_here,
+ Task* task) {
+ scoped_ptr<Task> task_ptr(task);
+ MessageLoop* loop = SimpleAppCacheSystem::GetMessageLoop(id);
+ if (loop)
+ loop->PostTask(from_here, task_ptr.release());
+ return loop ? true : false;
+}
+
+bool AppCacheThread::CurrentlyOn(int id) {
+ return MessageLoop::current() == SimpleAppCacheSystem::GetMessageLoop(id);
+}
+
+} // namespace appcache
// SimpleFrontendProxy --------------------------------------------------------
// Proxies method calls from the backend IO thread to the frontend UI thread.
@@ -247,7 +268,7 @@ SimpleAppCacheSystem::SimpleAppCacheSystem()
backend_proxy_(new SimpleBackendProxy(this))),
ALLOW_THIS_IN_INITIALIZER_LIST(
frontend_proxy_(new SimpleFrontendProxy(this))),
- backend_impl_(NULL), service_(NULL) {
+ backend_impl_(NULL), service_(NULL), db_thread_("AppCacheDBThread") {
DCHECK(!instance_);
instance_ = this;
}
@@ -262,6 +283,7 @@ void SimpleAppCacheSystem::InitOnUIThread(
const FilePath& cache_directory) {
DCHECK(!ui_message_loop_);
DCHECK(!cache_directory.empty());
+ AppCacheThread::InitIDs(DB_THREAD_ID, IO_THREAD_ID);
ui_message_loop_ = MessageLoop::current();
cache_directory_ = cache_directory;
}
@@ -274,6 +296,9 @@ void SimpleAppCacheSystem::InitOnIOThread(URLRequestContext* request_context) {
io_message_loop_ = MessageLoop::current();
io_message_loop_->AddDestructionObserver(this);
+ if (!db_thread_.IsRunning())
+ db_thread_.Start();
+
// Recreate and initialize per each IO thread.
service_ = new appcache::AppCacheService();
backend_impl_ = new appcache::AppCacheBackendImpl();