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

Side by Side Diff: content/browser/cache_storage/cache_storage_manager_unittest.cc

Issue 1545243002: Convert Pass()→std::move() in //content/browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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/cache_storage/cache_storage_manager.h" 5 #include "content/browser/cache_storage/cache_storage_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility>
9 10
10 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
11 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
12 #include "base/files/scoped_temp_dir.h" 13 #include "base/files/scoped_temp_dir.h"
13 #include "base/guid.h" 14 #include "base/guid.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/run_loop.h" 16 #include "base/run_loop.h"
16 #include "base/sha1.h" 17 #include "base/sha1.h"
17 #include "base/stl_util.h" 18 #include "base/stl_util.h"
18 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 callback_error_ = error; 129 callback_error_ = error;
129 run_loop->Quit(); 130 run_loop->Quit();
130 } 131 }
131 132
132 void CacheMatchCallback( 133 void CacheMatchCallback(
133 base::RunLoop* run_loop, 134 base::RunLoop* run_loop,
134 CacheStorageError error, 135 CacheStorageError error,
135 scoped_ptr<ServiceWorkerResponse> response, 136 scoped_ptr<ServiceWorkerResponse> response,
136 scoped_ptr<storage::BlobDataHandle> blob_data_handle) { 137 scoped_ptr<storage::BlobDataHandle> blob_data_handle) {
137 callback_error_ = error; 138 callback_error_ = error;
138 callback_cache_response_ = response.Pass(); 139 callback_cache_response_ = std::move(response);
139 callback_data_handle_ = blob_data_handle.Pass(); 140 callback_data_handle_ = std::move(blob_data_handle);
140 run_loop->Quit(); 141 run_loop->Quit();
141 } 142 }
142 143
143 bool Open(const GURL& origin, const std::string& cache_name) { 144 bool Open(const GURL& origin, const std::string& cache_name) {
144 base::RunLoop loop; 145 base::RunLoop loop;
145 cache_manager_->OpenCache( 146 cache_manager_->OpenCache(
146 origin, cache_name, 147 origin, cache_name,
147 base::Bind(&CacheStorageManagerTest::CacheAndErrorCallback, 148 base::Bind(&CacheStorageManagerTest::CacheAndErrorCallback,
148 base::Unretained(this), base::Unretained(&loop))); 149 base::Unretained(this), base::Unretained(&loop)));
149 loop.Run(); 150 loop.Run();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 190 }
190 191
191 bool StorageMatch(const GURL& origin, 192 bool StorageMatch(const GURL& origin,
192 const std::string& cache_name, 193 const std::string& cache_name,
193 const GURL& url) { 194 const GURL& url) {
194 scoped_ptr<ServiceWorkerFetchRequest> request( 195 scoped_ptr<ServiceWorkerFetchRequest> request(
195 new ServiceWorkerFetchRequest()); 196 new ServiceWorkerFetchRequest());
196 request->url = url; 197 request->url = url;
197 base::RunLoop loop; 198 base::RunLoop loop;
198 cache_manager_->MatchCache( 199 cache_manager_->MatchCache(
199 origin, cache_name, request.Pass(), 200 origin, cache_name, std::move(request),
200 base::Bind(&CacheStorageManagerTest::CacheMatchCallback, 201 base::Bind(&CacheStorageManagerTest::CacheMatchCallback,
201 base::Unretained(this), base::Unretained(&loop))); 202 base::Unretained(this), base::Unretained(&loop)));
202 loop.Run(); 203 loop.Run();
203 204
204 return callback_error_ == CACHE_STORAGE_OK; 205 return callback_error_ == CACHE_STORAGE_OK;
205 } 206 }
206 207
207 bool StorageMatchAll(const GURL& origin, const GURL& url) { 208 bool StorageMatchAll(const GURL& origin, const GURL& url) {
208 scoped_ptr<ServiceWorkerFetchRequest> request( 209 scoped_ptr<ServiceWorkerFetchRequest> request(
209 new ServiceWorkerFetchRequest()); 210 new ServiceWorkerFetchRequest());
210 request->url = url; 211 request->url = url;
211 base::RunLoop loop; 212 base::RunLoop loop;
212 cache_manager_->MatchAllCaches( 213 cache_manager_->MatchAllCaches(
213 origin, request.Pass(), 214 origin, std::move(request),
214 base::Bind(&CacheStorageManagerTest::CacheMatchCallback, 215 base::Bind(&CacheStorageManagerTest::CacheMatchCallback,
215 base::Unretained(this), base::Unretained(&loop))); 216 base::Unretained(this), base::Unretained(&loop)));
216 loop.Run(); 217 loop.Run();
217 218
218 return callback_error_ == CACHE_STORAGE_OK; 219 return callback_error_ == CACHE_STORAGE_OK;
219 } 220 }
220 221
221 bool CachePut(const scoped_refptr<CacheStorageCache>& cache, 222 bool CachePut(const scoped_refptr<CacheStorageCache>& cache,
222 const GURL& url) { 223 const GURL& url) {
223 ServiceWorkerFetchRequest request; 224 ServiceWorkerFetchRequest request;
(...skipping 24 matching lines...) Expand all
248 249
249 return callback_error_ == CACHE_STORAGE_OK; 250 return callback_error_ == CACHE_STORAGE_OK;
250 } 251 }
251 252
252 bool CacheMatch(const scoped_refptr<CacheStorageCache>& cache, 253 bool CacheMatch(const scoped_refptr<CacheStorageCache>& cache,
253 const GURL& url) { 254 const GURL& url) {
254 scoped_ptr<ServiceWorkerFetchRequest> request( 255 scoped_ptr<ServiceWorkerFetchRequest> request(
255 new ServiceWorkerFetchRequest()); 256 new ServiceWorkerFetchRequest());
256 request->url = url; 257 request->url = url;
257 base::RunLoop loop; 258 base::RunLoop loop;
258 cache->Match(request.Pass(), 259 cache->Match(std::move(request),
259 base::Bind(&CacheStorageManagerTest::CacheMatchCallback, 260 base::Bind(&CacheStorageManagerTest::CacheMatchCallback,
260 base::Unretained(this), base::Unretained(&loop))); 261 base::Unretained(this), base::Unretained(&loop)));
261 loop.Run(); 262 loop.Run();
262 263
263 return callback_error_ == CACHE_STORAGE_OK; 264 return callback_error_ == CACHE_STORAGE_OK;
264 } 265 }
265 266
266 CacheStorage* CacheStorageForOrigin(const GURL& origin) { 267 CacheStorage* CacheStorageForOrigin(const GURL& origin) {
267 return cache_manager_->FindOrCreateCacheStorage(origin); 268 return cache_manager_->FindOrCreateCacheStorage(origin);
268 } 269 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 } 464 }
464 465
465 TEST_F(CacheStorageManagerTest, StorageReuseCacheName) { 466 TEST_F(CacheStorageManagerTest, StorageReuseCacheName) {
466 // Deleting a cache and creating one with the same name and adding an entry 467 // Deleting a cache and creating one with the same name and adding an entry
467 // with the same URL should work. (see crbug.com/542668) 468 // with the same URL should work. (see crbug.com/542668)
468 const GURL kTestURL = GURL("http://example.com/foo"); 469 const GURL kTestURL = GURL("http://example.com/foo");
469 EXPECT_TRUE(Open(origin1_, "foo")); 470 EXPECT_TRUE(Open(origin1_, "foo"));
470 EXPECT_TRUE(CachePut(callback_cache_, kTestURL)); 471 EXPECT_TRUE(CachePut(callback_cache_, kTestURL));
471 EXPECT_TRUE(CacheMatch(callback_cache_, kTestURL)); 472 EXPECT_TRUE(CacheMatch(callback_cache_, kTestURL));
472 scoped_ptr<storage::BlobDataHandle> data_handle = 473 scoped_ptr<storage::BlobDataHandle> data_handle =
473 callback_data_handle_.Pass(); 474 std::move(callback_data_handle_);
474 475
475 EXPECT_TRUE(Delete(origin1_, "foo")); 476 EXPECT_TRUE(Delete(origin1_, "foo"));
476 // The cache is deleted but the handle to one of its entries is still 477 // The cache is deleted but the handle to one of its entries is still
477 // open. Creating a new cache in the same directory would fail on Windows. 478 // open. Creating a new cache in the same directory would fail on Windows.
478 EXPECT_TRUE(Open(origin1_, "foo")); 479 EXPECT_TRUE(Open(origin1_, "foo"));
479 EXPECT_TRUE(CachePut(callback_cache_, kTestURL)); 480 EXPECT_TRUE(CachePut(callback_cache_, kTestURL));
480 } 481 }
481 482
482 TEST_P(CacheStorageManagerTestP, StorageMatchAllEntryExistsTwice) { 483 TEST_P(CacheStorageManagerTestP, StorageMatchAllEntryExistsTwice) {
483 EXPECT_TRUE(Open(origin1_, "foo")); 484 EXPECT_TRUE(Open(origin1_, "foo"));
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 995
995 INSTANTIATE_TEST_CASE_P(CacheStorageManagerTests, 996 INSTANTIATE_TEST_CASE_P(CacheStorageManagerTests,
996 CacheStorageManagerTestP, 997 CacheStorageManagerTestP,
997 ::testing::Values(false, true)); 998 ::testing::Values(false, true));
998 999
999 INSTANTIATE_TEST_CASE_P(CacheStorageQuotaClientTests, 1000 INSTANTIATE_TEST_CASE_P(CacheStorageQuotaClientTests,
1000 CacheStorageQuotaClientTestP, 1001 CacheStorageQuotaClientTestP,
1001 ::testing::Values(false, true)); 1002 ::testing::Values(false, true));
1002 1003
1003 } // namespace content 1004 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698