diff options
-rw-r--r-- | webkit/tools/test_shell/simple_appcache_system.cc | 14 | ||||
-rw-r--r-- | webkit/tools/test_shell/simple_appcache_system.h | 2 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_webkit_init.h | 9 |
3 files changed, 21 insertions, 4 deletions
diff --git a/webkit/tools/test_shell/simple_appcache_system.cc b/webkit/tools/test_shell/simple_appcache_system.cc index e714267..e493f87 100644 --- a/webkit/tools/test_shell/simple_appcache_system.cc +++ b/webkit/tools/test_shell/simple_appcache_system.cc @@ -280,16 +280,28 @@ SimpleAppCacheSystem::SimpleAppCacheSystem() instance_ = this; } +static void SignalEvent(base::WaitableEvent* event) { + event->Signal(); +} + SimpleAppCacheSystem::~SimpleAppCacheSystem() { DCHECK(!io_message_loop_ && !backend_impl_ && !service_); frontend_proxy_->clear_appcache_system(); // in case a task is in transit instance_ = NULL; + + if (db_thread_.IsRunning()) { + // We pump a task thru the db thread to ensure any tasks previously + // scheduled on that thread have been performed prior to return. + base::WaitableEvent event(false, false); + db_thread_.message_loop()->PostTask(FROM_HERE, + NewRunnableFunction(&SignalEvent, &event)); + event.Wait(); + } } 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; diff --git a/webkit/tools/test_shell/simple_appcache_system.h b/webkit/tools/test_shell/simple_appcache_system.h index 0ea465a..13c2c5b 100644 --- a/webkit/tools/test_shell/simple_appcache_system.h +++ b/webkit/tools/test_shell/simple_appcache_system.h @@ -126,7 +126,7 @@ class SimpleAppCacheSystem : public MessageLoop::DestructionObserver { return io_message_loop_ && is_initailized_on_ui_thread(); } bool is_initailized_on_ui_thread() { - return ui_message_loop_ && !cache_directory_.empty(); + return ui_message_loop_ ? true : false; } static MessageLoop* GetMessageLoop(int id) { if (instance_) { diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h index ba13026..f31278d 100644 --- a/webkit/tools/test_shell/test_shell_webkit_init.h +++ b/webkit/tools/test_shell/test_shell_webkit_init.h @@ -70,8 +70,13 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl { // Construct and initialize an appcache system for this scope. // A new empty temp directory is created to house any cached // content during the run. Upon exit that directory is deleted. - if (appcache_dir_.CreateUniqueTempDir()) - SimpleAppCacheSystem::InitializeOnUIThread(appcache_dir_.path()); + // If we can't create a tempdir, we'll use in-memory storage. + if (!appcache_dir_.CreateUniqueTempDir()) { + LOG(WARNING) << "Failed to create a temp dir for the appcache, " + "using in-memory storage."; + DCHECK(appcache_dir_.path().empty()); + } + SimpleAppCacheSystem::InitializeOnUIThread(appcache_dir_.path()); WebKit::WebDatabase::setObserver(&database_system_); |