| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/json/json_writer.h" | 5 #include "base/json/json_writer.h" |
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/extensions/api/storage/settings_backend.h" | 9 #include "chrome/browser/extensions/api/storage/settings_backend.h" |
| 10 #include "chrome/browser/extensions/api/storage/settings_storage_quota_enforcer.
h" | 10 #include "chrome/browser/extensions/api/storage/settings_storage_quota_enforcer.
h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 size_t quota_bytes, size_t quota_bytes_per_item, size_t max_items) { | 55 size_t quota_bytes, size_t quota_bytes_per_item, size_t max_items) { |
| 56 ASSERT_TRUE(storage_.get() == NULL); | 56 ASSERT_TRUE(storage_.get() == NULL); |
| 57 SettingsStorageQuotaEnforcer::Limits limits = | 57 SettingsStorageQuotaEnforcer::Limits limits = |
| 58 { quota_bytes, quota_bytes_per_item, max_items }; | 58 { quota_bytes, quota_bytes_per_item, max_items }; |
| 59 storage_.reset(new SettingsStorageQuotaEnforcer(limits, delegate_)); | 59 storage_.reset(new SettingsStorageQuotaEnforcer(limits, delegate_)); |
| 60 } | 60 } |
| 61 | 61 |
| 62 // Returns whether the settings in |storage_| and |delegate_| are the same as | 62 // Returns whether the settings in |storage_| and |delegate_| are the same as |
| 63 // |settings|. | 63 // |settings|. |
| 64 bool SettingsEqual(const DictionaryValue& settings) { | 64 bool SettingsEqual(const DictionaryValue& settings) { |
| 65 return settings.Equals(storage_->Get()->settings().get()) && | 65 return settings.Equals(&storage_->Get()->settings()) && |
| 66 settings.Equals(delegate_->Get()->settings().get()); | 66 settings.Equals(&delegate_->Get()->settings()); |
| 67 } | 67 } |
| 68 | 68 |
| 69 // Values with different serialized sizes. | 69 // Values with different serialized sizes. |
| 70 scoped_ptr<Value> byte_value_1_; | 70 scoped_ptr<Value> byte_value_1_; |
| 71 scoped_ptr<Value> byte_value_16_; | 71 scoped_ptr<Value> byte_value_16_; |
| 72 scoped_ptr<ListValue> byte_value_256_; | 72 scoped_ptr<ListValue> byte_value_256_; |
| 73 | 73 |
| 74 // Quota enforcing storage area being tested. | 74 // Quota enforcing storage area being tested. |
| 75 scoped_ptr<SettingsStorageQuotaEnforcer> storage_; | 75 scoped_ptr<SettingsStorageQuotaEnforcer> storage_; |
| 76 | 76 |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 | 589 |
| 590 storage_->Set(DEFAULTS, "c", *byte_value_1_); | 590 storage_->Set(DEFAULTS, "c", *byte_value_1_); |
| 591 | 591 |
| 592 EXPECT_EQ(6u, storage_->GetBytesInUse()); | 592 EXPECT_EQ(6u, storage_->GetBytesInUse()); |
| 593 EXPECT_EQ(2u, storage_->GetBytesInUse("a")); | 593 EXPECT_EQ(2u, storage_->GetBytesInUse("a")); |
| 594 EXPECT_EQ(2u, storage_->GetBytesInUse("b")); | 594 EXPECT_EQ(2u, storage_->GetBytesInUse("b")); |
| 595 EXPECT_EQ(4u, storage_->GetBytesInUse(ab)); | 595 EXPECT_EQ(4u, storage_->GetBytesInUse(ab)); |
| 596 } | 596 } |
| 597 | 597 |
| 598 } // namespace extensions | 598 } // namespace extensions |
| OLD | NEW |