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 15 matching lines...) Expand all Loading... |
26 const base::FilePath::StringType file1_name = FILE_PATH_LITERAL("file1"); | 26 const base::FilePath::StringType file1_name = FILE_PATH_LITERAL("file1"); |
27 const base::FilePath::StringType file2_name = FILE_PATH_LITERAL("file2"); | 27 const base::FilePath::StringType file2_name = FILE_PATH_LITERAL("file2"); |
28 const base::FilePath::StringType file3_name = FILE_PATH_LITERAL("file3"); | 28 const base::FilePath::StringType file3_name = FILE_PATH_LITERAL("file3"); |
29 const int kFile1ID = 1; | 29 const int kFile1ID = 1; |
30 const int kFile2ID = 2; | 30 const int kFile2ID = 2; |
31 const int kFile3ID = 3; | 31 const int kFile3ID = 3; |
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 ~FakeBackend() override {} |
37 | 37 |
38 virtual void ReserveQuota( | 38 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 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 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 void IncrementDirtyCount(const GURL& origin, |
57 storage::FileSystemType type) override {} | 57 storage::FileSystemType type) override {} |
58 virtual void DecrementDirtyCount(const GURL& origin, | 58 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() {} |
(...skipping 165 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 |