| 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 "storage/browser/fileapi/quota/quota_backend_impl.h" | 5 #include "storage/browser/fileapi/quota/quota_backend_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 } | 39 } |
| 40 | 40 |
| 41 class MockQuotaManagerProxy : public storage::QuotaManagerProxy { | 41 class MockQuotaManagerProxy : public storage::QuotaManagerProxy { |
| 42 public: | 42 public: |
| 43 MockQuotaManagerProxy() | 43 MockQuotaManagerProxy() |
| 44 : QuotaManagerProxy(NULL, NULL), | 44 : QuotaManagerProxy(NULL, NULL), |
| 45 storage_modified_count_(0), | 45 storage_modified_count_(0), |
| 46 usage_(0), quota_(0) {} | 46 usage_(0), quota_(0) {} |
| 47 | 47 |
| 48 // We don't mock them. | 48 // We don't mock them. |
| 49 virtual void NotifyOriginInUse(const GURL& origin) override {} | 49 void NotifyOriginInUse(const GURL& origin) override {} |
| 50 virtual void NotifyOriginNoLongerInUse(const GURL& origin) override {} | 50 void NotifyOriginNoLongerInUse(const GURL& origin) override {} |
| 51 virtual void SetUsageCacheEnabled(storage::QuotaClient::ID client_id, | 51 void SetUsageCacheEnabled(storage::QuotaClient::ID client_id, |
| 52 const GURL& origin, | 52 const GURL& origin, |
| 53 storage::StorageType type, | 53 storage::StorageType type, |
| 54 bool enabled) override {} | 54 bool enabled) override {} |
| 55 | 55 |
| 56 virtual void NotifyStorageModified(storage::QuotaClient::ID client_id, | 56 void NotifyStorageModified(storage::QuotaClient::ID client_id, |
| 57 const GURL& origin, | 57 const GURL& origin, |
| 58 storage::StorageType type, | 58 storage::StorageType type, |
| 59 int64 delta) override { | 59 int64 delta) override { |
| 60 ++storage_modified_count_; | 60 ++storage_modified_count_; |
| 61 usage_ += delta; | 61 usage_ += delta; |
| 62 ASSERT_LE(usage_, quota_); | 62 ASSERT_LE(usage_, quota_); |
| 63 } | 63 } |
| 64 | 64 |
| 65 virtual void GetUsageAndQuota( | 65 void GetUsageAndQuota(base::SequencedTaskRunner* original_task_runner, |
| 66 base::SequencedTaskRunner* original_task_runner, | 66 const GURL& origin, |
| 67 const GURL& origin, | 67 storage::StorageType type, |
| 68 storage::StorageType type, | 68 const GetUsageAndQuotaCallback& callback) override { |
| 69 const GetUsageAndQuotaCallback& callback) override { | |
| 70 callback.Run(storage::kQuotaStatusOk, usage_, quota_); | 69 callback.Run(storage::kQuotaStatusOk, usage_, quota_); |
| 71 } | 70 } |
| 72 | 71 |
| 73 int storage_modified_count() { return storage_modified_count_; } | 72 int storage_modified_count() { return storage_modified_count_; } |
| 74 int64 usage() { return usage_; } | 73 int64 usage() { return usage_; } |
| 75 void set_usage(int64 usage) { usage_ = usage; } | 74 void set_usage(int64 usage) { usage_ = usage; } |
| 76 void set_quota(int64 quota) { quota_ = quota; } | 75 void set_quota(int64 quota) { quota_ = quota; } |
| 77 | 76 |
| 78 protected: | 77 protected: |
| 79 virtual ~MockQuotaManagerProxy() {} | 78 ~MockQuotaManagerProxy() override {} |
| 80 | 79 |
| 81 private: | 80 private: |
| 82 int storage_modified_count_; | 81 int storage_modified_count_; |
| 83 int64 usage_; | 82 int64 usage_; |
| 84 int64 quota_; | 83 int64 quota_; |
| 85 | 84 |
| 86 DISALLOW_COPY_AND_ASSIGN(MockQuotaManagerProxy); | 85 DISALLOW_COPY_AND_ASSIGN(MockQuotaManagerProxy); |
| 87 }; | 86 }; |
| 88 | 87 |
| 89 } // namespace | 88 } // namespace |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 uint32 dirty = 0; | 262 uint32 dirty = 0; |
| 264 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty)); | 263 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty)); |
| 265 EXPECT_EQ(1u, dirty); | 264 EXPECT_EQ(1u, dirty); |
| 266 | 265 |
| 267 backend_->DecrementDirtyCount(GURL(kOrigin), type); | 266 backend_->DecrementDirtyCount(GURL(kOrigin), type); |
| 268 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty)); | 267 ASSERT_TRUE(file_system_usage_cache_.GetDirty(path, &dirty)); |
| 269 EXPECT_EQ(0u, dirty); | 268 EXPECT_EQ(0u, dirty); |
| 270 } | 269 } |
| 271 | 270 |
| 272 } // namespace content | 271 } // namespace content |
| OLD | NEW |