| 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 "webkit/dom_storage/dom_storage_area.h" | 5 #include "webkit/dom_storage/dom_storage_area.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 return map_->Length(); | 111 return map_->Length(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 NullableString16 DomStorageArea::Key(unsigned index) { | 114 NullableString16 DomStorageArea::Key(unsigned index) { |
| 115 if (is_shutdown_) | 115 if (is_shutdown_) |
| 116 return NullableString16(true); | 116 return NullableString16(true); |
| 117 InitialImportIfNeeded(); | 117 InitialImportIfNeeded(); |
| 118 return map_->Key(index); | 118 return map_->Key(index); |
| 119 } | 119 } |
| 120 | 120 |
| 121 NullableString16 DomStorageArea::GetItem(const string16& key) { | 121 NullableString16 DomStorageArea::GetItem(const base::string16& key) { |
| 122 if (is_shutdown_) | 122 if (is_shutdown_) |
| 123 return NullableString16(true); | 123 return NullableString16(true); |
| 124 InitialImportIfNeeded(); | 124 InitialImportIfNeeded(); |
| 125 return map_->GetItem(key); | 125 return map_->GetItem(key); |
| 126 } | 126 } |
| 127 | 127 |
| 128 bool DomStorageArea::SetItem(const string16& key, | 128 bool DomStorageArea::SetItem(const base::string16& key, |
| 129 const string16& value, | 129 const base::string16& value, |
| 130 NullableString16* old_value) { | 130 NullableString16* old_value) { |
| 131 if (is_shutdown_) | 131 if (is_shutdown_) |
| 132 return false; | 132 return false; |
| 133 InitialImportIfNeeded(); | 133 InitialImportIfNeeded(); |
| 134 if (!map_->HasOneRef()) | 134 if (!map_->HasOneRef()) |
| 135 map_ = map_->DeepCopy(); | 135 map_ = map_->DeepCopy(); |
| 136 bool success = map_->SetItem(key, value, old_value); | 136 bool success = map_->SetItem(key, value, old_value); |
| 137 if (success && backing_.get()) { | 137 if (success && backing_.get()) { |
| 138 CommitBatch* commit_batch = CreateCommitBatchIfNeeded(); | 138 CommitBatch* commit_batch = CreateCommitBatchIfNeeded(); |
| 139 commit_batch->changed_values[key] = NullableString16(value, false); | 139 commit_batch->changed_values[key] = NullableString16(value, false); |
| 140 } | 140 } |
| 141 return success; | 141 return success; |
| 142 } | 142 } |
| 143 | 143 |
| 144 bool DomStorageArea::RemoveItem(const string16& key, string16* old_value) { | 144 bool DomStorageArea::RemoveItem(const base::string16& key, |
| 145 base::string16* old_value) { |
| 145 if (is_shutdown_) | 146 if (is_shutdown_) |
| 146 return false; | 147 return false; |
| 147 InitialImportIfNeeded(); | 148 InitialImportIfNeeded(); |
| 148 if (!map_->HasOneRef()) | 149 if (!map_->HasOneRef()) |
| 149 map_ = map_->DeepCopy(); | 150 map_ = map_->DeepCopy(); |
| 150 bool success = map_->RemoveItem(key, old_value); | 151 bool success = map_->RemoveItem(key, old_value); |
| 151 if (success && backing_.get()) { | 152 if (success && backing_.get()) { |
| 152 CommitBatch* commit_batch = CreateCommitBatchIfNeeded(); | 153 CommitBatch* commit_batch = CreateCommitBatchIfNeeded(); |
| 153 commit_batch->changed_values[key] = NullableString16(true); | 154 commit_batch->changed_values[key] = NullableString16(true); |
| 154 } | 155 } |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 commit_batch_->clear_all_first, | 387 commit_batch_->clear_all_first, |
| 387 commit_batch_->changed_values); | 388 commit_batch_->changed_values); |
| 388 DCHECK(success); | 389 DCHECK(success); |
| 389 } | 390 } |
| 390 commit_batch_.reset(); | 391 commit_batch_.reset(); |
| 391 backing_.reset(); | 392 backing_.reset(); |
| 392 session_storage_backing_ = NULL; | 393 session_storage_backing_ = NULL; |
| 393 } | 394 } |
| 394 | 395 |
| 395 } // namespace dom_storage | 396 } // namespace dom_storage |
| OLD | NEW |