| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stack> | 5 #include <stack> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 (*headers) = std::string(not_found_headers, | 119 (*headers) = std::string(not_found_headers, |
| 120 arraysize(not_found_headers)); | 120 arraysize(not_found_headers)); |
| 121 (*body) = ""; | 121 (*body) = ""; |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 class MockHttpServerJobFactory | 126 class MockHttpServerJobFactory |
| 127 : public net::URLRequestJobFactory::ProtocolHandler { | 127 : public net::URLRequestJobFactory::ProtocolHandler { |
| 128 public: | 128 public: |
| 129 MockHttpServerJobFactory( |
| 130 scoped_ptr<net::URLRequestInterceptor> appcache_start_interceptor) |
| 131 : appcache_start_interceptor_(appcache_start_interceptor.Pass()) { |
| 132 } |
| 133 |
| 129 virtual net::URLRequestJob* MaybeCreateJob( | 134 virtual net::URLRequestJob* MaybeCreateJob( |
| 130 net::URLRequest* request, | 135 net::URLRequest* request, |
| 131 net::NetworkDelegate* network_delegate) const override { | 136 net::NetworkDelegate* network_delegate) const override { |
| 137 net::URLRequestJob* appcache_job = |
| 138 appcache_start_interceptor_->MaybeInterceptRequest( |
| 139 request, network_delegate); |
| 140 if (appcache_job) |
| 141 return appcache_job; |
| 132 return MockHttpServer::CreateJob(request, network_delegate); | 142 return MockHttpServer::CreateJob(request, network_delegate); |
| 133 } | 143 } |
| 144 private: |
| 145 scoped_ptr<net::URLRequestInterceptor> appcache_start_interceptor_; |
| 134 }; | 146 }; |
| 135 | 147 |
| 136 class IOThread : public base::Thread { | 148 class IOThread : public base::Thread { |
| 137 public: | 149 public: |
| 138 explicit IOThread(const char* name) | 150 explicit IOThread(const char* name) |
| 139 : base::Thread(name) { | 151 : base::Thread(name) { |
| 140 } | 152 } |
| 141 | 153 |
| 142 virtual ~IOThread() { | 154 virtual ~IOThread() { |
| 143 Stop(); | 155 Stop(); |
| 144 } | 156 } |
| 145 | 157 |
| 146 net::URLRequestContext* request_context() { | 158 net::URLRequestContext* request_context() { |
| 147 return request_context_.get(); | 159 return request_context_.get(); |
| 148 } | 160 } |
| 149 | 161 |
| 150 virtual void Init() override { | 162 virtual void Init() override { |
| 151 scoped_ptr<net::URLRequestJobFactoryImpl> factory( | 163 scoped_ptr<net::URLRequestJobFactoryImpl> factory( |
| 152 new net::URLRequestJobFactoryImpl()); | 164 new net::URLRequestJobFactoryImpl()); |
| 153 factory->SetProtocolHandler("http", new MockHttpServerJobFactory); | 165 factory->SetProtocolHandler( |
| 166 "http", |
| 167 new MockHttpServerJobFactory( |
| 168 AppCacheInterceptor::CreateStartInterceptor())); |
| 154 job_factory_ = factory.Pass(); | 169 job_factory_ = factory.Pass(); |
| 155 request_context_.reset(new net::TestURLRequestContext()); | 170 request_context_.reset(new net::TestURLRequestContext()); |
| 156 request_context_->set_job_factory(job_factory_.get()); | 171 request_context_->set_job_factory(job_factory_.get()); |
| 157 AppCacheInterceptor::EnsureRegistered(); | 172 AppCacheInterceptor::EnsureRegistered(); |
| 158 } | 173 } |
| 159 | 174 |
| 160 virtual void CleanUp() override { | 175 virtual void CleanUp() override { |
| 161 request_context_.reset(); | 176 request_context_.reset(); |
| 162 job_factory_.reset(); | 177 job_factory_.reset(); |
| 163 } | 178 } |
| (...skipping 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2016 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2); | 2031 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2); |
| 2017 } | 2032 } |
| 2018 | 2033 |
| 2019 TEST_F(AppCacheStorageImplTest, Reinitialize3) { | 2034 TEST_F(AppCacheStorageImplTest, Reinitialize3) { |
| 2020 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize3); | 2035 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize3); |
| 2021 } | 2036 } |
| 2022 | 2037 |
| 2023 // That's all folks! | 2038 // That's all folks! |
| 2024 | 2039 |
| 2025 } // namespace content | 2040 } // namespace content |
| OLD | NEW |