diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-23 20:40:57 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-23 20:40:57 +0000 |
commit | 8a4892d8d5ef84d8be7c47ac5e1b5e601f2a77b7 (patch) | |
tree | dd56c3b7fb32d93154b58616e4e8368cc2702341 /webkit/tools/test_shell/simple_appcache_system.h | |
parent | d6b7266a83b8fffe30fd79c9ebe7c155cb5b687d (diff) | |
download | chromium_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.h')
-rw-r--r-- | webkit/tools/test_shell/simple_appcache_system.h | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/webkit/tools/test_shell/simple_appcache_system.h b/webkit/tools/test_shell/simple_appcache_system.h index c029051..adeedd6 100644 --- a/webkit/tools/test_shell/simple_appcache_system.h +++ b/webkit/tools/test_shell/simple_appcache_system.h @@ -7,9 +7,11 @@ #include "base/file_path.h" #include "base/message_loop.h" +#include "base/thread.h" #include "webkit/appcache/appcache_backend_impl.h" #include "webkit/appcache/appcache_frontend_impl.h" #include "webkit/appcache/appcache_service.h" +#include "webkit/appcache/appcache_thread.h" #include "webkit/glue/resource_type.h" namespace WebKit { @@ -74,9 +76,12 @@ class SimpleAppCacheSystem : public MessageLoop::DestructionObserver { private: friend class SimpleBackendProxy; friend class SimpleFrontendProxy; + friend class appcache::AppCacheThread; - // A low-tech singleton. - static SimpleAppCacheSystem* instance_; + enum AppCacheThreadID { + DB_THREAD_ID, + IO_THREAD_ID, + }; // Instance methods called by our static public methods void InitOnUIThread(const FilePath& cache_directory); @@ -101,6 +106,16 @@ class SimpleAppCacheSystem : public MessageLoop::DestructionObserver { bool is_initailized_on_ui_thread() { return ui_message_loop_ && !cache_directory_.empty(); } + static MessageLoop* GetMessageLoop(int id) { + if (instance_) { + if (id == IO_THREAD_ID) + return instance_->io_message_loop_; + if (id == DB_THREAD_ID) + return instance_->db_thread_.message_loop(); + NOTREACHED() << "Invalid AppCacheThreadID value"; + } + return NULL; + } // IOThread DestructionObserver virtual void WillDestroyCurrentMessageLoop(); @@ -117,6 +132,12 @@ class SimpleAppCacheSystem : public MessageLoop::DestructionObserver { // is started new instances will be created. appcache::AppCacheBackendImpl* backend_impl_; appcache::AppCacheService* service_; + + // We start a thread for use as the DB thread. + base::Thread db_thread_; + + // A low-tech singleton. + static SimpleAppCacheSystem* instance_; }; #endif // WEBKIT_TOOLS_TEST_SHELL_SIMPLE_APPCACHE_SYSTEM_H_ |