diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-03 21:00:14 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-03 21:00:14 +0000 |
commit | 1ac6af94287a2f821a43003b2be2ba21f319a66d (patch) | |
tree | 3398fd0b22e8f9bde49f5aa7f50ff3ab1a42a81c /webkit/appcache | |
parent | cc204b2cfb421e72bb9d6187fa88cb412576fc94 (diff) | |
download | chromium_src-1ac6af94287a2f821a43003b2be2ba21f319a66d.zip chromium_src-1ac6af94287a2f821a43003b2be2ba21f319a66d.tar.gz chromium_src-1ac6af94287a2f821a43003b2be2ba21f319a66d.tar.bz2 |
Make HostResolver NonThreadSafe and not thread safe refcounted.
Required making SyncHostResolverBridge not use RefCountedThreadSafe. I refactored the innards to have a thread safe refcounted Core implementation.
BUG=45298
Review URL: http://codereview.chromium.org/2122015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48867 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache')
-rw-r--r-- | webkit/appcache/appcache_update_job_unittest.cc | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/webkit/appcache/appcache_update_job_unittest.cc b/webkit/appcache/appcache_update_job_unittest.cc index 7ea664f..a10f53f 100644 --- a/webkit/appcache/appcache_update_job_unittest.cc +++ b/webkit/appcache/appcache_update_job_unittest.cc @@ -308,6 +308,36 @@ std::string HttpHeadersRequestTestJob::expect_if_none_match_; bool HttpHeadersRequestTestJob::saw_if_none_match_ = false; bool HttpHeadersRequestTestJob::already_checked_ = false; +namespace { + +class IOThread : public base::Thread { + public: + IOThread(const char* name) : base::Thread(name) { + } + + ~IOThread() { + // We cannot rely on our base class to stop the thread since we want our + // CleanUp function to run. + Stop(); + } + + const scoped_refptr<URLRequestContext>& request_context() { + return request_context_; + } + + virtual void Init() { + request_context_ = new TestURLRequestContext(); + } + + virtual void CleanUp() { + request_context_ = NULL; + } + + scoped_refptr<URLRequestContext> request_context_; +}; + +} // namespace + class AppCacheUpdateJobTest : public testing::Test, public AppCacheGroup::UpdateObserver { public: @@ -358,15 +388,13 @@ class AppCacheUpdateJobTest : public testing::Test, } static void SetUpTestCase() { - io_thread_ = new base::Thread("AppCacheUpdateJob IO test thread"); + io_thread_ = new IOThread("AppCacheUpdateJob IO test thread"); base::Thread::Options options(MessageLoop::TYPE_IO, 0); io_thread_->StartWithOptions(options); http_server_ = HTTPTestServer::CreateServer( kDocRoot, io_thread_->message_loop()).release(); ASSERT_TRUE(http_server_); - request_context_ = new TestURLRequestContext(); - request_context_->AddRef(); } static base::WaitableEvent* io_thread_shutdown_event_; @@ -377,10 +405,6 @@ class AppCacheUpdateJobTest : public testing::Test, http_server_->Release(); http_server_ = NULL; } - if (request_context_) { - request_context_->Release(); - request_context_ = NULL; - } io_thread_shutdown_event_->Signal(); } @@ -2630,7 +2654,7 @@ class AppCacheUpdateJobTest : public testing::Test, void MakeService() { service_.reset(new MockAppCacheService()); - service_->set_request_context(request_context_); + service_->set_request_context(io_thread_->request_context()); service_->set_appcache_policy(&policy_); } @@ -2915,9 +2939,8 @@ class AppCacheUpdateJobTest : public testing::Test, PENDING_MASTER_NO_UPDATE, }; - static base::Thread* io_thread_; + static IOThread* io_thread_; static HTTPTestServer* http_server_; - static TestURLRequestContext* request_context_; scoped_ptr<MockAppCacheService> service_; scoped_refptr<AppCacheGroup> group_; @@ -2950,9 +2973,8 @@ class AppCacheUpdateJobTest : public testing::Test, }; // static -base::Thread* AppCacheUpdateJobTest::io_thread_ = NULL; +IOThread* AppCacheUpdateJobTest::io_thread_ = NULL; HTTPTestServer* AppCacheUpdateJobTest::http_server_ = NULL; -TestURLRequestContext* AppCacheUpdateJobTest::request_context_ = NULL; base::WaitableEvent* AppCacheUpdateJobTest::io_thread_shutdown_event_ = NULL; |