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 "content/browser/appcache/appcache_storage_impl.h" |
| 6 |
5 #include <stdint.h> | 7 #include <stdint.h> |
6 | |
7 #include <stack> | 8 #include <stack> |
| 9 #include <utility> |
8 | 10 |
9 #include "base/bind.h" | 11 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
11 #include "base/callback.h" | 13 #include "base/callback.h" |
12 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
13 #include "base/files/scoped_temp_dir.h" | 15 #include "base/files/scoped_temp_dir.h" |
14 #include "base/location.h" | 16 #include "base/location.h" |
15 #include "base/macros.h" | 17 #include "base/macros.h" |
16 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
17 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
18 #include "base/synchronization/waitable_event.h" | 20 #include "base/synchronization/waitable_event.h" |
19 #include "base/thread_task_runner_handle.h" | 21 #include "base/thread_task_runner_handle.h" |
20 #include "base/threading/thread.h" | 22 #include "base/threading/thread.h" |
21 #include "content/browser/appcache/appcache.h" | 23 #include "content/browser/appcache/appcache.h" |
22 #include "content/browser/appcache/appcache_backend_impl.h" | 24 #include "content/browser/appcache/appcache_backend_impl.h" |
23 #include "content/browser/appcache/appcache_database.h" | 25 #include "content/browser/appcache/appcache_database.h" |
24 #include "content/browser/appcache/appcache_entry.h" | 26 #include "content/browser/appcache/appcache_entry.h" |
25 #include "content/browser/appcache/appcache_group.h" | 27 #include "content/browser/appcache/appcache_group.h" |
26 #include "content/browser/appcache/appcache_host.h" | 28 #include "content/browser/appcache/appcache_host.h" |
27 #include "content/browser/appcache/appcache_interceptor.h" | 29 #include "content/browser/appcache/appcache_interceptor.h" |
28 #include "content/browser/appcache/appcache_request_handler.h" | 30 #include "content/browser/appcache/appcache_request_handler.h" |
29 #include "content/browser/appcache/appcache_service_impl.h" | 31 #include "content/browser/appcache/appcache_service_impl.h" |
30 #include "content/browser/appcache/appcache_storage_impl.h" | |
31 #include "net/base/net_errors.h" | 32 #include "net/base/net_errors.h" |
32 #include "net/base/request_priority.h" | 33 #include "net/base/request_priority.h" |
33 #include "net/http/http_response_headers.h" | 34 #include "net/http/http_response_headers.h" |
34 #include "net/url_request/url_request_error_job.h" | 35 #include "net/url_request/url_request_error_job.h" |
35 #include "net/url_request/url_request_job_factory_impl.h" | 36 #include "net/url_request/url_request_job_factory_impl.h" |
36 #include "net/url_request/url_request_test_job.h" | 37 #include "net/url_request/url_request_test_job.h" |
37 #include "net/url_request/url_request_test_util.h" | 38 #include "net/url_request/url_request_test_util.h" |
38 #include "sql/test/test_helpers.h" | 39 #include "sql/test/test_helpers.h" |
39 #include "storage/browser/quota/quota_manager.h" | 40 #include "storage/browser/quota/quota_manager.h" |
40 #include "testing/gtest/include/gtest/gtest.h" | 41 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 arraysize(not_found_headers)); | 126 arraysize(not_found_headers)); |
126 (*body) = ""; | 127 (*body) = ""; |
127 } | 128 } |
128 } | 129 } |
129 }; | 130 }; |
130 | 131 |
131 class MockHttpServerJobFactory | 132 class MockHttpServerJobFactory |
132 : public net::URLRequestJobFactory::ProtocolHandler { | 133 : public net::URLRequestJobFactory::ProtocolHandler { |
133 public: | 134 public: |
134 MockHttpServerJobFactory( | 135 MockHttpServerJobFactory( |
135 scoped_ptr<net::URLRequestInterceptor> appcache_start_interceptor) | 136 scoped_ptr<net::URLRequestInterceptor> appcache_start_interceptor) |
136 : appcache_start_interceptor_(appcache_start_interceptor.Pass()) { | 137 : appcache_start_interceptor_(std::move(appcache_start_interceptor)) {} |
137 } | |
138 | 138 |
139 net::URLRequestJob* MaybeCreateJob( | 139 net::URLRequestJob* MaybeCreateJob( |
140 net::URLRequest* request, | 140 net::URLRequest* request, |
141 net::NetworkDelegate* network_delegate) const override { | 141 net::NetworkDelegate* network_delegate) const override { |
142 net::URLRequestJob* appcache_job = | 142 net::URLRequestJob* appcache_job = |
143 appcache_start_interceptor_->MaybeInterceptRequest( | 143 appcache_start_interceptor_->MaybeInterceptRequest( |
144 request, network_delegate); | 144 request, network_delegate); |
145 if (appcache_job) | 145 if (appcache_job) |
146 return appcache_job; | 146 return appcache_job; |
147 return MockHttpServer::CreateJob(request, network_delegate); | 147 return MockHttpServer::CreateJob(request, network_delegate); |
(...skipping 13 matching lines...) Expand all Loading... |
161 net::URLRequestContext* request_context() { | 161 net::URLRequestContext* request_context() { |
162 return request_context_.get(); | 162 return request_context_.get(); |
163 } | 163 } |
164 | 164 |
165 void Init() override { | 165 void Init() override { |
166 scoped_ptr<net::URLRequestJobFactoryImpl> factory( | 166 scoped_ptr<net::URLRequestJobFactoryImpl> factory( |
167 new net::URLRequestJobFactoryImpl()); | 167 new net::URLRequestJobFactoryImpl()); |
168 factory->SetProtocolHandler( | 168 factory->SetProtocolHandler( |
169 "http", make_scoped_ptr(new MockHttpServerJobFactory( | 169 "http", make_scoped_ptr(new MockHttpServerJobFactory( |
170 make_scoped_ptr(new AppCacheInterceptor())))); | 170 make_scoped_ptr(new AppCacheInterceptor())))); |
171 job_factory_ = factory.Pass(); | 171 job_factory_ = std::move(factory); |
172 request_context_.reset(new net::TestURLRequestContext()); | 172 request_context_.reset(new net::TestURLRequestContext()); |
173 request_context_->set_job_factory(job_factory_.get()); | 173 request_context_->set_job_factory(job_factory_.get()); |
174 } | 174 } |
175 | 175 |
176 void CleanUp() override { | 176 void CleanUp() override { |
177 request_context_.reset(); | 177 request_context_.reset(); |
178 job_factory_.reset(); | 178 job_factory_.reset(); |
179 } | 179 } |
180 | 180 |
181 private: | 181 private: |
(...skipping 1842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2024 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2); | 2024 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2); |
2025 } | 2025 } |
2026 | 2026 |
2027 TEST_F(AppCacheStorageImplTest, Reinitialize3) { | 2027 TEST_F(AppCacheStorageImplTest, Reinitialize3) { |
2028 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize3); | 2028 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize3); |
2029 } | 2029 } |
2030 | 2030 |
2031 // That's all folks! | 2031 // That's all folks! |
2032 | 2032 |
2033 } // namespace content | 2033 } // namespace content |
OLD | NEW |