diff options
Diffstat (limited to 'webkit/tools')
-rw-r--r-- | webkit/tools/test_shell/simple_appcache_system.cc | 11 | ||||
-rw-r--r-- | webkit/tools/test_shell/simple_appcache_system.h | 33 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.gyp | 2 |
3 files changed, 40 insertions, 6 deletions
diff --git a/webkit/tools/test_shell/simple_appcache_system.cc b/webkit/tools/test_shell/simple_appcache_system.cc index 0f9d452..e714267 100644 --- a/webkit/tools/test_shell/simple_appcache_system.cc +++ b/webkit/tools/test_shell/simple_appcache_system.cc @@ -26,6 +26,10 @@ bool AppCacheThread::PostTask( int id, const tracked_objects::Location& from_here, Task* task) { + if (SimpleAppCacheSystem::thread_provider()) { + return SimpleAppCacheSystem::thread_provider()->PostTask( + id, from_here, task); + } scoped_ptr<Task> task_ptr(task); MessageLoop* loop = SimpleAppCacheSystem::GetMessageLoop(id); if (loop) @@ -34,6 +38,8 @@ bool AppCacheThread::PostTask( } bool AppCacheThread::CurrentlyOn(int id) { + if (SimpleAppCacheSystem::thread_provider()) + return SimpleAppCacheSystem::thread_provider()->CurrentlyOn(id); return MessageLoop::current() == SimpleAppCacheSystem::GetMessageLoop(id); } @@ -268,7 +274,8 @@ SimpleAppCacheSystem::SimpleAppCacheSystem() backend_proxy_(new SimpleBackendProxy(this))), ALLOW_THIS_IN_INITIALIZER_LIST( frontend_proxy_(new SimpleFrontendProxy(this))), - backend_impl_(NULL), service_(NULL), db_thread_("AppCacheDBThread") { + backend_impl_(NULL), service_(NULL), db_thread_("AppCacheDBThread"), + thread_provider_(NULL) { DCHECK(!instance_); instance_ = this; } @@ -346,11 +353,11 @@ void SimpleAppCacheSystem::WillDestroyCurrentMessageLoop() { DCHECK(is_io_thread()); DCHECK(backend_impl_->hosts().empty()); - io_message_loop_ = NULL; delete backend_impl_; delete service_; backend_impl_ = NULL; service_ = NULL; + io_message_loop_ = NULL; // Just in case the main thread is waiting on it. backend_proxy_->SignalEvent(); diff --git a/webkit/tools/test_shell/simple_appcache_system.h b/webkit/tools/test_shell/simple_appcache_system.h index adeedd6..0ea465a 100644 --- a/webkit/tools/test_shell/simple_appcache_system.h +++ b/webkit/tools/test_shell/simple_appcache_system.h @@ -73,16 +73,38 @@ class SimpleAppCacheSystem : public MessageLoop::DestructionObserver { instance_->GetExtraResponseBits(request, cache_id, manifest_url); } - private: - friend class SimpleBackendProxy; - friend class SimpleFrontendProxy; - friend class appcache::AppCacheThread; + // Some unittests create their own IO and DB threads. enum AppCacheThreadID { DB_THREAD_ID, IO_THREAD_ID, }; + class ThreadProvider { + public: + virtual ~ThreadProvider() {} + virtual bool PostTask( + int id, + const tracked_objects::Location& from_here, + Task* task) = 0; + virtual bool CurrentlyOn(int id) = 0; + }; + + static void set_thread_provider(ThreadProvider* provider) { + DCHECK(instance_); + DCHECK(!provider || !instance_->thread_provider_); + instance_->thread_provider_ = provider; + } + + static ThreadProvider* thread_provider() { + return instance_ ? instance_->thread_provider_ : NULL; + } + + private: + friend class SimpleBackendProxy; + friend class SimpleFrontendProxy; + friend class appcache::AppCacheThread; + // Instance methods called by our static public methods void InitOnUIThread(const FilePath& cache_directory); void InitOnIOThread(URLRequestContext* request_context); @@ -136,6 +158,9 @@ class SimpleAppCacheSystem : public MessageLoop::DestructionObserver { // We start a thread for use as the DB thread. base::Thread db_thread_; + // Some unittests create there own IO and DB threads. + ThreadProvider* thread_provider_; + // A low-tech singleton. static SimpleAppCacheSystem* instance_; }; diff --git a/webkit/tools/test_shell/test_shell.gyp b/webkit/tools/test_shell/test_shell.gyp index 1b5ff01..3b78abf 100644 --- a/webkit/tools/test_shell/test_shell.gyp +++ b/webkit/tools/test_shell/test_shell.gyp @@ -380,11 +380,13 @@ '../../../skia/ext/vector_canvas_unittest.cc', '../../appcache/manifest_parser_unittest.cc', '../../appcache/appcache_unittest.cc', + '../../appcache/appcache_database_unittest.cc', '../../appcache/appcache_group_unittest.cc', '../../appcache/appcache_host_unittest.cc', '../../appcache/appcache_request_handler_unittest.cc', '../../appcache/appcache_response_unittest.cc', '../../appcache/appcache_storage_unittest.cc', + '../../appcache/appcache_storage_impl_unittest.cc', '../../appcache/appcache_update_job_unittest.cc', '../../appcache/appcache_url_request_job_unittest.cc', '../../appcache/mock_appcache_service.h', |