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 "webkit/browser/fileapi/quota/quota_reservation_manager.h" | 5 #include "webkit/browser/fileapi/quota/quota_reservation_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 EXPECT_EQ(kInitialFileSize + 20 + 30 + 40, fake_backend()->on_disk_usage()); | 287 EXPECT_EQ(kInitialFileSize + 20 + 30 + 40, fake_backend()->on_disk_usage()); |
288 | 288 |
289 reservation = NULL; | 289 reservation = NULL; |
290 | 290 |
291 EXPECT_EQ(kInitialFileSize + 20 + 30 + 40, fake_backend()->on_disk_usage()); | 291 EXPECT_EQ(kInitialFileSize + 20 + 30 + 40, fake_backend()->on_disk_usage()); |
292 } | 292 } |
293 | 293 |
294 TEST_F(QuotaReservationManagerTest, MultipleClient) { | 294 TEST_F(QuotaReservationManagerTest, MultipleClient) { |
295 scoped_refptr<QuotaReservation> reservation1 = | 295 scoped_refptr<QuotaReservation> reservation1 = |
296 reservation_manager()->CreateReservation(GURL(kOrigin), kType); | 296 reservation_manager()->CreateReservation(GURL(kOrigin), kType); |
297 RefreshReservation(reservation1, 10); | 297 RefreshReservation(reservation1.get(), 10); |
298 int64 cached_reserved_quota1 = reservation1->remaining_quota(); | 298 int64 cached_reserved_quota1 = reservation1->remaining_quota(); |
299 | 299 |
300 scoped_refptr<QuotaReservation> reservation2 = | 300 scoped_refptr<QuotaReservation> reservation2 = |
301 reservation_manager()->CreateReservation(GURL(kOrigin), kType); | 301 reservation_manager()->CreateReservation(GURL(kOrigin), kType); |
302 RefreshReservation(reservation2, 20); | 302 RefreshReservation(reservation2.get(), 20); |
303 int64 cached_reserved_quota2 = reservation2->remaining_quota(); | 303 int64 cached_reserved_quota2 = reservation2->remaining_quota(); |
304 | 304 |
305 scoped_ptr<FakeWriter> writer1( | 305 scoped_ptr<FakeWriter> writer1( |
306 new FakeWriter(reservation1->GetOpenFileHandle(file_path()))); | 306 new FakeWriter(reservation1->GetOpenFileHandle(file_path()))); |
307 | 307 |
308 scoped_ptr<FakeWriter> writer2( | 308 scoped_ptr<FakeWriter> writer2( |
309 new FakeWriter(reservation2->GetOpenFileHandle(file_path()))); | 309 new FakeWriter(reservation2->GetOpenFileHandle(file_path()))); |
310 | 310 |
311 cached_reserved_quota1 -= writer1->Write(kInitialFileSize + 10); | 311 cached_reserved_quota1 -= writer1->Write(kInitialFileSize + 10); |
312 EXPECT_LE(0, cached_reserved_quota1); | 312 EXPECT_LE(0, cached_reserved_quota1); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 | 358 |
359 EXPECT_EQ(kInitialFileSize + 10, GetFileSize(file_path())); | 359 EXPECT_EQ(kInitialFileSize + 10, GetFileSize(file_path())); |
360 EXPECT_EQ(kInitialFileSize + 15 + 20, fake_backend()->on_memory_usage()); | 360 EXPECT_EQ(kInitialFileSize + 15 + 20, fake_backend()->on_memory_usage()); |
361 EXPECT_EQ(kInitialFileSize + 10, fake_backend()->on_disk_usage()); | 361 EXPECT_EQ(kInitialFileSize + 10, fake_backend()->on_disk_usage()); |
362 | 362 |
363 reservation2 = NULL; | 363 reservation2 = NULL; |
364 EXPECT_EQ(kInitialFileSize + 10, fake_backend()->on_memory_usage()); | 364 EXPECT_EQ(kInitialFileSize + 10, fake_backend()->on_memory_usage()); |
365 } | 365 } |
366 | 366 |
367 } // namespace content | 367 } // namespace content |
OLD | NEW |