Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(488)

Side by Side Diff: content/browser/appcache/appcache_storage_impl_unittest.cc

Issue 1874893002: Convert //content/browser from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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" 5 #include "content/browser/appcache/appcache_storage_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8
9 #include <memory>
8 #include <stack> 10 #include <stack>
9 #include <utility> 11 #include <utility>
10 12
11 #include "base/bind.h" 13 #include "base/bind.h"
12 #include "base/bind_helpers.h" 14 #include "base/bind_helpers.h"
13 #include "base/callback.h" 15 #include "base/callback.h"
14 #include "base/files/file_util.h" 16 #include "base/files/file_util.h"
15 #include "base/files/scoped_temp_dir.h" 17 #include "base/files/scoped_temp_dir.h"
16 #include "base/location.h" 18 #include "base/location.h"
17 #include "base/macros.h" 19 #include "base/macros.h"
18 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/ptr_util.h"
19 #include "base/single_thread_task_runner.h" 21 #include "base/single_thread_task_runner.h"
20 #include "base/synchronization/waitable_event.h" 22 #include "base/synchronization/waitable_event.h"
21 #include "base/thread_task_runner_handle.h" 23 #include "base/thread_task_runner_handle.h"
22 #include "base/threading/thread.h" 24 #include "base/threading/thread.h"
23 #include "content/browser/appcache/appcache.h" 25 #include "content/browser/appcache/appcache.h"
24 #include "content/browser/appcache/appcache_backend_impl.h" 26 #include "content/browser/appcache/appcache_backend_impl.h"
25 #include "content/browser/appcache/appcache_database.h" 27 #include "content/browser/appcache/appcache_database.h"
26 #include "content/browser/appcache/appcache_entry.h" 28 #include "content/browser/appcache/appcache_entry.h"
27 #include "content/browser/appcache/appcache_group.h" 29 #include "content/browser/appcache/appcache_group.h"
28 #include "content/browser/appcache/appcache_host.h" 30 #include "content/browser/appcache/appcache_host.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 arraysize(not_found_headers)); 128 arraysize(not_found_headers));
127 (*body) = ""; 129 (*body) = "";
128 } 130 }
129 } 131 }
130 }; 132 };
131 133
132 class MockHttpServerJobFactory 134 class MockHttpServerJobFactory
133 : public net::URLRequestJobFactory::ProtocolHandler { 135 : public net::URLRequestJobFactory::ProtocolHandler {
134 public: 136 public:
135 MockHttpServerJobFactory( 137 MockHttpServerJobFactory(
136 scoped_ptr<net::URLRequestInterceptor> appcache_start_interceptor) 138 std::unique_ptr<net::URLRequestInterceptor> appcache_start_interceptor)
137 : appcache_start_interceptor_(std::move(appcache_start_interceptor)) {} 139 : appcache_start_interceptor_(std::move(appcache_start_interceptor)) {}
138 140
139 net::URLRequestJob* MaybeCreateJob( 141 net::URLRequestJob* MaybeCreateJob(
140 net::URLRequest* request, 142 net::URLRequest* request,
141 net::NetworkDelegate* network_delegate) const override { 143 net::NetworkDelegate* network_delegate) const override {
142 net::URLRequestJob* appcache_job = 144 net::URLRequestJob* appcache_job =
143 appcache_start_interceptor_->MaybeInterceptRequest( 145 appcache_start_interceptor_->MaybeInterceptRequest(
144 request, network_delegate); 146 request, network_delegate);
145 if (appcache_job) 147 if (appcache_job)
146 return appcache_job; 148 return appcache_job;
147 return MockHttpServer::CreateJob(request, network_delegate); 149 return MockHttpServer::CreateJob(request, network_delegate);
148 } 150 }
149 private: 151 private:
150 scoped_ptr<net::URLRequestInterceptor> appcache_start_interceptor_; 152 std::unique_ptr<net::URLRequestInterceptor> appcache_start_interceptor_;
151 }; 153 };
152 154
153 class IOThread : public base::Thread { 155 class IOThread : public base::Thread {
154 public: 156 public:
155 explicit IOThread(const char* name) 157 explicit IOThread(const char* name)
156 : base::Thread(name) { 158 : base::Thread(name) {
157 } 159 }
158 160
159 ~IOThread() override { Stop(); } 161 ~IOThread() override { Stop(); }
160 162
161 net::URLRequestContext* request_context() { 163 net::URLRequestContext* request_context() {
162 return request_context_.get(); 164 return request_context_.get();
163 } 165 }
164 166
165 void Init() override { 167 void Init() override {
166 scoped_ptr<net::URLRequestJobFactoryImpl> factory( 168 std::unique_ptr<net::URLRequestJobFactoryImpl> factory(
167 new net::URLRequestJobFactoryImpl()); 169 new net::URLRequestJobFactoryImpl());
168 factory->SetProtocolHandler( 170 factory->SetProtocolHandler(
169 "http", make_scoped_ptr(new MockHttpServerJobFactory( 171 "http", base::WrapUnique(new MockHttpServerJobFactory(
170 make_scoped_ptr(new AppCacheInterceptor())))); 172 base::WrapUnique(new AppCacheInterceptor()))));
171 job_factory_ = std::move(factory); 173 job_factory_ = std::move(factory);
172 request_context_.reset(new net::TestURLRequestContext()); 174 request_context_.reset(new net::TestURLRequestContext());
173 request_context_->set_job_factory(job_factory_.get()); 175 request_context_->set_job_factory(job_factory_.get());
174 } 176 }
175 177
176 void CleanUp() override { 178 void CleanUp() override {
177 request_context_.reset(); 179 request_context_.reset();
178 job_factory_.reset(); 180 job_factory_.reset();
179 } 181 }
180 182
181 private: 183 private:
182 scoped_ptr<net::URLRequestJobFactory> job_factory_; 184 std::unique_ptr<net::URLRequestJobFactory> job_factory_;
183 scoped_ptr<net::URLRequestContext> request_context_; 185 std::unique_ptr<net::URLRequestContext> request_context_;
184 }; 186 };
185 187
186 scoped_ptr<IOThread> io_thread; 188 std::unique_ptr<IOThread> io_thread;
187 scoped_ptr<base::Thread> db_thread; 189 std::unique_ptr<base::Thread> db_thread;
188 190
189 } // namespace 191 } // namespace
190 192
191 class AppCacheStorageImplTest : public testing::Test { 193 class AppCacheStorageImplTest : public testing::Test {
192 public: 194 public:
193 class MockStorageDelegate : public AppCacheStorage::Delegate { 195 class MockStorageDelegate : public AppCacheStorage::Delegate {
194 public: 196 public:
195 explicit MockStorageDelegate(AppCacheStorageImplTest* test) 197 explicit MockStorageDelegate(AppCacheStorageImplTest* test)
196 : loaded_cache_id_(0), stored_group_success_(false), 198 : loaded_cache_id_(0), stored_group_success_(false),
197 would_exceed_quota_(false), obsoleted_success_(false), 199 would_exceed_quota_(false), obsoleted_success_(false),
(...skipping 1674 matching lines...) Expand 10 before | Expand all | Expand 10 after
1872 entry_record.response_size = default_entry.response_size(); 1874 entry_record.response_size = default_entry.response_size();
1873 EXPECT_TRUE(database()->InsertEntry(&entry_record)); 1875 EXPECT_TRUE(database()->InsertEntry(&entry_record));
1874 1876
1875 storage()->usage_map_[manifest_url.GetOrigin()] = 1877 storage()->usage_map_[manifest_url.GetOrigin()] =
1876 default_entry.response_size(); 1878 default_entry.response_size();
1877 } 1879 }
1878 } 1880 }
1879 1881
1880 // Data members -------------------------------------------------- 1882 // Data members --------------------------------------------------
1881 1883
1882 scoped_ptr<base::WaitableEvent> test_finished_event_; 1884 std::unique_ptr<base::WaitableEvent> test_finished_event_;
1883 std::stack<base::Closure> task_stack_; 1885 std::stack<base::Closure> task_stack_;
1884 scoped_ptr<AppCacheServiceImpl> service_; 1886 std::unique_ptr<AppCacheServiceImpl> service_;
1885 scoped_ptr<MockStorageDelegate> delegate_; 1887 std::unique_ptr<MockStorageDelegate> delegate_;
1886 scoped_refptr<MockQuotaManagerProxy> mock_quota_manager_proxy_; 1888 scoped_refptr<MockQuotaManagerProxy> mock_quota_manager_proxy_;
1887 scoped_refptr<AppCacheGroup> group_; 1889 scoped_refptr<AppCacheGroup> group_;
1888 scoped_refptr<AppCache> cache_; 1890 scoped_refptr<AppCache> cache_;
1889 scoped_refptr<AppCache> cache2_; 1891 scoped_refptr<AppCache> cache2_;
1890 1892
1891 // Specifically for the Reinitalize test. 1893 // Specifically for the Reinitalize test.
1892 base::ScopedTempDir temp_directory_; 1894 base::ScopedTempDir temp_directory_;
1893 scoped_ptr<MockServiceObserver> observer_; 1895 std::unique_ptr<MockServiceObserver> observer_;
1894 MockAppCacheFrontend frontend_; 1896 MockAppCacheFrontend frontend_;
1895 scoped_ptr<AppCacheBackendImpl> backend_; 1897 std::unique_ptr<AppCacheBackendImpl> backend_;
1896 net::TestDelegate request_delegate_; 1898 net::TestDelegate request_delegate_;
1897 scoped_ptr<net::URLRequest> request_; 1899 std::unique_ptr<net::URLRequest> request_;
1898 }; 1900 };
1899 1901
1900 1902
1901 TEST_F(AppCacheStorageImplTest, LoadCache_Miss) { 1903 TEST_F(AppCacheStorageImplTest, LoadCache_Miss) {
1902 RunTestOnIOThread(&AppCacheStorageImplTest::LoadCache_Miss); 1904 RunTestOnIOThread(&AppCacheStorageImplTest::LoadCache_Miss);
1903 } 1905 }
1904 1906
1905 TEST_F(AppCacheStorageImplTest, LoadCache_NearHit) { 1907 TEST_F(AppCacheStorageImplTest, LoadCache_NearHit) {
1906 RunTestOnIOThread(&AppCacheStorageImplTest::LoadCache_NearHit); 1908 RunTestOnIOThread(&AppCacheStorageImplTest::LoadCache_NearHit);
1907 } 1909 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2024 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2); 2026 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2);
2025 } 2027 }
2026 2028
2027 TEST_F(AppCacheStorageImplTest, Reinitialize3) { 2029 TEST_F(AppCacheStorageImplTest, Reinitialize3) {
2028 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize3); 2030 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize3);
2029 } 2031 }
2030 2032
2031 // That's all folks! 2033 // That's all folks!
2032 2034
2033 } // namespace content 2035 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_storage_impl.cc ('k') | content/browser/appcache/appcache_update_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698