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

Side by Side Diff: content/browser/quota/quota_reservation_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 "storage/browser/fileapi/quota/quota_reservation_manager.h"
6
7 #include <stdint.h> 5 #include <stdint.h>
6 #include <utility>
8 7
9 #include "base/bind.h" 8 #include "base/bind.h"
10 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
11 #include "base/files/file.h" 10 #include "base/files/file.h"
12 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
13 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
14 #include "base/location.h" 13 #include "base/location.h"
15 #include "base/macros.h" 14 #include "base/macros.h"
16 #include "base/run_loop.h" 15 #include "base/run_loop.h"
17 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
18 #include "base/thread_task_runner_handle.h" 17 #include "base/thread_task_runner_handle.h"
19 #include "storage/browser/fileapi/quota/open_file_handle.h" 18 #include "storage/browser/fileapi/quota/open_file_handle.h"
20 #include "storage/browser/fileapi/quota/quota_reservation.h" 19 #include "storage/browser/fileapi/quota/quota_reservation.h"
20 #include "storage/browser/fileapi/quota/quota_reservation_manager.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 22
23 using storage::kFileSystemTypeTemporary; 23 using storage::kFileSystemTypeTemporary;
24 using storage::OpenFileHandle; 24 using storage::OpenFileHandle;
25 using storage::QuotaReservation; 25 using storage::QuotaReservation;
26 using storage::QuotaReservationManager; 26 using storage::QuotaReservationManager;
27 27
28 namespace content { 28 namespace content {
29 29
30 namespace { 30 namespace {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 private: 95 private:
96 int64_t on_memory_usage_; 96 int64_t on_memory_usage_;
97 int64_t on_disk_usage_; 97 int64_t on_disk_usage_;
98 98
99 DISALLOW_COPY_AND_ASSIGN(FakeBackend); 99 DISALLOW_COPY_AND_ASSIGN(FakeBackend);
100 }; 100 };
101 101
102 class FakeWriter { 102 class FakeWriter {
103 public: 103 public:
104 explicit FakeWriter(scoped_ptr<OpenFileHandle> handle) 104 explicit FakeWriter(scoped_ptr<OpenFileHandle> handle)
105 : handle_(handle.Pass()), 105 : handle_(std::move(handle)),
106 path_(handle_->platform_path()), 106 path_(handle_->platform_path()),
107 max_written_offset_(handle_->GetEstimatedFileSize()), 107 max_written_offset_(handle_->GetEstimatedFileSize()),
108 append_mode_write_amount_(0), 108 append_mode_write_amount_(0),
109 dirty_(false) { 109 dirty_(false) {}
110 }
111 110
112 ~FakeWriter() { 111 ~FakeWriter() {
113 if (handle_) 112 if (handle_)
114 EXPECT_FALSE(dirty_); 113 EXPECT_FALSE(dirty_);
115 } 114 }
116 115
117 int64_t Truncate(int64_t length) { 116 int64_t Truncate(int64_t length) {
118 int64_t consumed = 0; 117 int64_t consumed = 0;
119 118
120 if (max_written_offset_ < length) { 119 if (max_written_offset_ < length) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 public: 185 public:
187 QuotaReservationManagerTest() {} 186 QuotaReservationManagerTest() {}
188 ~QuotaReservationManagerTest() override {} 187 ~QuotaReservationManagerTest() override {}
189 188
190 void SetUp() override { 189 void SetUp() override {
191 ASSERT_TRUE(work_dir_.CreateUniqueTempDir()); 190 ASSERT_TRUE(work_dir_.CreateUniqueTempDir());
192 file_path_ = work_dir_.path().Append(FILE_PATH_LITERAL("hoge")); 191 file_path_ = work_dir_.path().Append(FILE_PATH_LITERAL("hoge"));
193 SetFileSize(file_path_, kInitialFileSize); 192 SetFileSize(file_path_, kInitialFileSize);
194 193
195 scoped_ptr<QuotaReservationManager::QuotaBackend> backend(new FakeBackend); 194 scoped_ptr<QuotaReservationManager::QuotaBackend> backend(new FakeBackend);
196 reservation_manager_.reset(new QuotaReservationManager(backend.Pass())); 195 reservation_manager_.reset(new QuotaReservationManager(std::move(backend)));
197 } 196 }
198 197
199 void TearDown() override { reservation_manager_.reset(); } 198 void TearDown() override { reservation_manager_.reset(); }
200 199
201 FakeBackend* fake_backend() { 200 FakeBackend* fake_backend() {
202 return static_cast<FakeBackend*>(reservation_manager_->backend_.get()); 201 return static_cast<FakeBackend*>(reservation_manager_->backend_.get());
203 } 202 }
204 203
205 QuotaReservationManager* reservation_manager() { 204 QuotaReservationManager* reservation_manager() {
206 return reservation_manager_.get(); 205 return reservation_manager_.get();
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 360
362 EXPECT_EQ(kInitialFileSize + 10, GetFileSize(file_path())); 361 EXPECT_EQ(kInitialFileSize + 10, GetFileSize(file_path()));
363 EXPECT_EQ(kInitialFileSize + 15 + 20, fake_backend()->on_memory_usage()); 362 EXPECT_EQ(kInitialFileSize + 15 + 20, fake_backend()->on_memory_usage());
364 EXPECT_EQ(kInitialFileSize + 10, fake_backend()->on_disk_usage()); 363 EXPECT_EQ(kInitialFileSize + 10, fake_backend()->on_disk_usage());
365 364
366 reservation2 = NULL; 365 reservation2 = NULL;
367 EXPECT_EQ(kInitialFileSize + 10, fake_backend()->on_memory_usage()); 366 EXPECT_EQ(kInitialFileSize + 10, fake_backend()->on_memory_usage());
368 } 367 }
369 368
370 } // namespace content 369 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/presentation/presentation_type_converters.h ('k') | content/browser/renderer_host/database_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698