| 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 #ifndef WEBKIT_DOM_STORAGE_DOM_STORAGE_MAP_H_ | 5 #ifndef WEBKIT_DOM_STORAGE_DOM_STORAGE_MAP_H_ |
| 6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_MAP_H_ | 6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_MAP_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 public: | 23 public: |
| 24 DomStorageMap(size_t quota); | 24 DomStorageMap(size_t quota); |
| 25 | 25 |
| 26 unsigned Length() const; | 26 unsigned Length() const; |
| 27 NullableString16 Key(unsigned index); | 27 NullableString16 Key(unsigned index); |
| 28 NullableString16 GetItem(const string16& key) const; | 28 NullableString16 GetItem(const string16& key) const; |
| 29 bool SetItem(const string16& key, const string16& value, | 29 bool SetItem(const string16& key, const string16& value, |
| 30 NullableString16* old_value); | 30 NullableString16* old_value); |
| 31 bool RemoveItem(const string16& key, string16* old_value); | 31 bool RemoveItem(const string16& key, string16* old_value); |
| 32 | 32 |
| 33 // Replaces values_ with |map|. Returns true on success, false | 33 // Swaps this instances values_ with |map|. |
| 34 // if the swap was prevented because |map| would exceed this | 34 // Note: to grandfather in pre-existing files that are overbudget, |
| 35 // DomStorageMap's quota_. | 35 // this method does not do quota checking. |
| 36 bool SwapValues(ValuesMap* map); | 36 void SwapValues(ValuesMap* map); |
| 37 |
| 38 // Creates a new instance of DomStorageMap containing |
| 39 // a deep copy of values_. |
| 37 DomStorageMap* DeepCopy() const; | 40 DomStorageMap* DeepCopy() const; |
| 38 | 41 |
| 39 size_t bytes_used() const { return bytes_used_; } | 42 size_t bytes_used() const { return bytes_used_; } |
| 40 | 43 |
| 41 private: | 44 private: |
| 42 friend class base::RefCountedThreadSafe<DomStorageMap>; | 45 friend class base::RefCountedThreadSafe<DomStorageMap>; |
| 43 ~DomStorageMap(); | 46 ~DomStorageMap(); |
| 44 | 47 |
| 45 void ResetKeyIterator(); | 48 void ResetKeyIterator(); |
| 46 | 49 |
| 47 ValuesMap values_; | 50 ValuesMap values_; |
| 48 ValuesMap::const_iterator key_iterator_; | 51 ValuesMap::const_iterator key_iterator_; |
| 49 unsigned last_key_index_; | 52 unsigned last_key_index_; |
| 50 size_t bytes_used_; | 53 size_t bytes_used_; |
| 51 size_t quota_; | 54 size_t quota_; |
| 52 }; | 55 }; |
| 53 | 56 |
| 54 } // namespace dom_storage | 57 } // namespace dom_storage |
| 55 | 58 |
| 56 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_MAP_H_ | 59 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_MAP_H_ |
| OLD | NEW |