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

Side by Side Diff: content/browser/cache_storage/cache_storage_cache_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_cache.h" 5 #include "content/browser/cache_storage/cache_storage_cache.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/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
15 #include "base/run_loop.h" 16 #include "base/run_loop.h"
16 #include "base/strings/string_split.h" 17 #include "base/strings/string_split.h"
17 #include "base/thread_task_runner_handle.h" 18 #include "base/thread_task_runner_handle.h"
18 #include "content/browser/fileapi/chrome_blob_storage_context.h" 19 #include "content/browser/fileapi/chrome_blob_storage_context.h"
(...skipping 29 matching lines...) Expand all
48 // The FileSystemContext and thread task runner are not actually used but a 49 // The FileSystemContext and thread task runner are not actually used but a
49 // task runner is needed to avoid a DCHECK in BlobURLRequestJob ctor. 50 // task runner is needed to avoid a DCHECK in BlobURLRequestJob ctor.
50 return make_scoped_ptr(new storage::BlobProtocolHandler( 51 return make_scoped_ptr(new storage::BlobProtocolHandler(
51 blob_storage_context, NULL, base::ThreadTaskRunnerHandle::Get().get())); 52 blob_storage_context, NULL, base::ThreadTaskRunnerHandle::Get().get()));
52 } 53 }
53 54
54 // A disk_cache::Backend wrapper that can delay operations. 55 // A disk_cache::Backend wrapper that can delay operations.
55 class DelayableBackend : public disk_cache::Backend { 56 class DelayableBackend : public disk_cache::Backend {
56 public: 57 public:
57 DelayableBackend(scoped_ptr<disk_cache::Backend> backend) 58 DelayableBackend(scoped_ptr<disk_cache::Backend> backend)
58 : backend_(backend.Pass()), delay_open_(false) {} 59 : backend_(std::move(backend)), delay_open_(false) {}
59 60
60 // disk_cache::Backend overrides 61 // disk_cache::Backend overrides
61 net::CacheType GetCacheType() const override { 62 net::CacheType GetCacheType() const override {
62 return backend_->GetCacheType(); 63 return backend_->GetCacheType();
63 } 64 }
64 int32_t GetEntryCount() const override { return backend_->GetEntryCount(); } 65 int32_t GetEntryCount() const override { return backend_->GetEntryCount(); }
65 int OpenEntry(const std::string& key, 66 int OpenEntry(const std::string& key,
66 disk_cache::Entry** entry, 67 disk_cache::Entry** entry,
67 const CompletionCallback& callback) override { 68 const CompletionCallback& callback) override {
68 if (delay_open_) { 69 if (delay_open_) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 228 }
228 229
229 void set_delay_backend_creation(bool delay) { 230 void set_delay_backend_creation(bool delay) {
230 delay_backend_creation_ = delay; 231 delay_backend_creation_ = delay;
231 } 232 }
232 233
233 // Swap the existing backend with a delayable one. The backend must have been 234 // Swap the existing backend with a delayable one. The backend must have been
234 // created before calling this. 235 // created before calling this.
235 DelayableBackend* UseDelayableBackend() { 236 DelayableBackend* UseDelayableBackend() {
236 EXPECT_TRUE(backend_); 237 EXPECT_TRUE(backend_);
237 DelayableBackend* delayable_backend = new DelayableBackend(backend_.Pass()); 238 DelayableBackend* delayable_backend =
239 new DelayableBackend(std::move(backend_));
238 backend_.reset(delayable_backend); 240 backend_.reset(delayable_backend);
239 return delayable_backend; 241 return delayable_backend;
240 } 242 }
241 243
242 private: 244 private:
243 ~TestCacheStorageCache() override {} 245 ~TestCacheStorageCache() override {}
244 246
245 bool delay_backend_creation_; 247 bool delay_backend_creation_;
246 ErrorCallback backend_creation_callback_; 248 ErrorCallback backend_creation_callback_;
247 249
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 if (run_loop) 441 if (run_loop)
440 run_loop->Quit(); 442 run_loop->Quit();
441 } 443 }
442 444
443 void ResponseAndErrorCallback( 445 void ResponseAndErrorCallback(
444 base::RunLoop* run_loop, 446 base::RunLoop* run_loop,
445 CacheStorageError error, 447 CacheStorageError error,
446 scoped_ptr<ServiceWorkerResponse> response, 448 scoped_ptr<ServiceWorkerResponse> response,
447 scoped_ptr<storage::BlobDataHandle> body_handle) { 449 scoped_ptr<storage::BlobDataHandle> body_handle) {
448 callback_error_ = error; 450 callback_error_ = error;
449 callback_response_ = response.Pass(); 451 callback_response_ = std::move(response);
450 callback_response_data_.reset(); 452 callback_response_data_.reset();
451 if (error == CACHE_STORAGE_OK && !callback_response_->blob_uuid.empty()) 453 if (error == CACHE_STORAGE_OK && !callback_response_->blob_uuid.empty())
452 callback_response_data_ = body_handle.Pass(); 454 callback_response_data_ = std::move(body_handle);
453 455
454 if (run_loop) 456 if (run_loop)
455 run_loop->Quit(); 457 run_loop->Quit();
456 } 458 }
457 459
458 void ResponsesAndErrorCallback( 460 void ResponsesAndErrorCallback(
459 const base::Closure& quit_closure, 461 const base::Closure& quit_closure,
460 scoped_ptr<CacheStorageCache::Responses>* responses_out, 462 scoped_ptr<CacheStorageCache::Responses>* responses_out,
461 scoped_ptr<CacheStorageCache::BlobDataHandles>* body_handles_out, 463 scoped_ptr<CacheStorageCache::BlobDataHandles>* body_handles_out,
462 CacheStorageError error, 464 CacheStorageError error,
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 EXPECT_EQ(1, sequence_out); 1016 EXPECT_EQ(1, sequence_out);
1015 close_loop2->Run(); 1017 close_loop2->Run();
1016 EXPECT_EQ(2, sequence_out); 1018 EXPECT_EQ(2, sequence_out);
1017 } 1019 }
1018 1020
1019 INSTANTIATE_TEST_CASE_P(CacheStorageCacheTest, 1021 INSTANTIATE_TEST_CASE_P(CacheStorageCacheTest,
1020 CacheStorageCacheTestP, 1022 CacheStorageCacheTestP,
1021 ::testing::Values(false, true)); 1023 ::testing::Values(false, true));
1022 1024
1023 } // namespace content 1025 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/cache_storage/cache_storage_cache.cc ('k') | content/browser/cache_storage/cache_storage_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698