| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderer_host/pepper/quota_reservation.h" | 5 #include "content/browser/renderer_host/pepper/quota_reservation.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/files/file.h" | 9 #include "base/files/file.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 class FakeBackend : public QuotaReservationManager::QuotaBackend { | 33 class FakeBackend : public QuotaReservationManager::QuotaBackend { |
| 34 public: | 34 public: |
| 35 FakeBackend() {} | 35 FakeBackend() {} |
| 36 virtual ~FakeBackend() {} | 36 virtual ~FakeBackend() {} |
| 37 | 37 |
| 38 virtual void ReserveQuota( | 38 virtual void ReserveQuota( |
| 39 const GURL& origin, | 39 const GURL& origin, |
| 40 storage::FileSystemType type, | 40 storage::FileSystemType type, |
| 41 int64 delta, | 41 int64 delta, |
| 42 const QuotaReservationManager::ReserveQuotaCallback& callback) OVERRIDE { | 42 const QuotaReservationManager::ReserveQuotaCallback& callback) override { |
| 43 base::MessageLoopProxy::current()->PostTask( | 43 base::MessageLoopProxy::current()->PostTask( |
| 44 FROM_HERE, | 44 FROM_HERE, |
| 45 base::Bind(base::IgnoreResult(callback), base::File::FILE_OK, delta)); | 45 base::Bind(base::IgnoreResult(callback), base::File::FILE_OK, delta)); |
| 46 } | 46 } |
| 47 | 47 |
| 48 virtual void ReleaseReservedQuota(const GURL& origin, | 48 virtual void ReleaseReservedQuota(const GURL& origin, |
| 49 storage::FileSystemType type, | 49 storage::FileSystemType type, |
| 50 int64 size) OVERRIDE {} | 50 int64 size) override {} |
| 51 | 51 |
| 52 virtual void CommitQuotaUsage(const GURL& origin, | 52 virtual void CommitQuotaUsage(const GURL& origin, |
| 53 storage::FileSystemType type, | 53 storage::FileSystemType type, |
| 54 int64 delta) OVERRIDE {} | 54 int64 delta) override {} |
| 55 | 55 |
| 56 virtual void IncrementDirtyCount(const GURL& origin, | 56 virtual void IncrementDirtyCount(const GURL& origin, |
| 57 storage::FileSystemType type) OVERRIDE {} | 57 storage::FileSystemType type) override {} |
| 58 virtual void DecrementDirtyCount(const GURL& origin, | 58 virtual void DecrementDirtyCount(const GURL& origin, |
| 59 storage::FileSystemType type) OVERRIDE {} | 59 storage::FileSystemType type) override {} |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 DISALLOW_COPY_AND_ASSIGN(FakeBackend); | 62 DISALLOW_COPY_AND_ASSIGN(FakeBackend); |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 } // namespace | 65 } // namespace |
| 66 | 66 |
| 67 class QuotaReservationTest : public testing::Test { | 67 class QuotaReservationTest : public testing::Test { |
| 68 public: | 68 public: |
| 69 QuotaReservationTest() {} | 69 QuotaReservationTest() {} |
| 70 virtual ~QuotaReservationTest() {} | 70 virtual ~QuotaReservationTest() {} |
| 71 | 71 |
| 72 virtual void SetUp() OVERRIDE { | 72 virtual void SetUp() override { |
| 73 ASSERT_TRUE(work_dir_.CreateUniqueTempDir()); | 73 ASSERT_TRUE(work_dir_.CreateUniqueTempDir()); |
| 74 | 74 |
| 75 reservation_manager_.reset(new QuotaReservationManager( | 75 reservation_manager_.reset(new QuotaReservationManager( |
| 76 scoped_ptr<QuotaReservationManager::QuotaBackend>(new FakeBackend))); | 76 scoped_ptr<QuotaReservationManager::QuotaBackend>(new FakeBackend))); |
| 77 } | 77 } |
| 78 | 78 |
| 79 virtual void TearDown() OVERRIDE { | 79 virtual void TearDown() override { |
| 80 reservation_manager_.reset(); | 80 reservation_manager_.reset(); |
| 81 base::RunLoop().RunUntilIdle(); | 81 base::RunLoop().RunUntilIdle(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 base::FilePath MakeFilePath(const base::FilePath::StringType& file_name) { | 84 base::FilePath MakeFilePath(const base::FilePath::StringType& file_name) { |
| 85 return work_dir_.path().Append(file_name); | 85 return work_dir_.path().Append(file_name); |
| 86 } | 86 } |
| 87 | 87 |
| 88 storage::FileSystemURL MakeFileSystemURL( | 88 storage::FileSystemURL MakeFileSystemURL( |
| 89 const base::FilePath::StringType& file_name) { | 89 const base::FilePath::StringType& file_name) { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 EXPECT_EQ(amount, reserved_quota); | 235 EXPECT_EQ(amount, reserved_quota); |
| 236 EXPECT_EQ(2U, file_growths.size()); | 236 EXPECT_EQ(2U, file_growths.size()); |
| 237 EXPECT_EQ(file1_size, file_growths[kFile1ID].max_written_offset); | 237 EXPECT_EQ(file1_size, file_growths[kFile1ID].max_written_offset); |
| 238 EXPECT_EQ(file3_size, file_growths[kFile3ID].max_written_offset); | 238 EXPECT_EQ(file3_size, file_growths[kFile3ID].max_written_offset); |
| 239 | 239 |
| 240 test->CloseFile(kFile1ID, ppapi::FileGrowth(file1_size, 0)); | 240 test->CloseFile(kFile1ID, ppapi::FileGrowth(file1_size, 0)); |
| 241 test->CloseFile(kFile3ID, ppapi::FileGrowth(file3_size, 0)); | 241 test->CloseFile(kFile3ID, ppapi::FileGrowth(file3_size, 0)); |
| 242 } | 242 } |
| 243 | 243 |
| 244 } // namespace content | 244 } // namespace content |
| OLD | NEW |