| 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/browser/dom_storage/dom_storage_host.h" | 5 #include "webkit/browser/dom_storage/dom_storage_host.h" |
| 6 | 6 |
| 7 #include "googleurl/src/gurl.h" | 7 #include "googleurl/src/gurl.h" |
| 8 #include "webkit/browser/dom_storage/dom_storage_area.h" | 8 #include "webkit/browser/dom_storage/dom_storage_area.h" |
| 9 #include "webkit/browser/dom_storage/dom_storage_context.h" | 9 #include "webkit/browser/dom_storage/dom_storage_context.h" |
| 10 #include "webkit/browser/dom_storage/dom_storage_namespace.h" | 10 #include "webkit/browser/dom_storage/dom_storage_namespace.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 return true; | 73 return true; |
| 74 } | 74 } |
| 75 | 75 |
| 76 unsigned DomStorageHost::GetAreaLength(int connection_id) { | 76 unsigned DomStorageHost::GetAreaLength(int connection_id) { |
| 77 DomStorageArea* area = GetOpenArea(connection_id); | 77 DomStorageArea* area = GetOpenArea(connection_id); |
| 78 if (!area) | 78 if (!area) |
| 79 return 0; | 79 return 0; |
| 80 return area->Length(); | 80 return area->Length(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 NullableString16 DomStorageHost::GetAreaKey(int connection_id, unsigned index) { | 83 base::NullableString16 DomStorageHost::GetAreaKey(int connection_id, |
| 84 unsigned index) { |
| 84 DomStorageArea* area = GetOpenArea(connection_id); | 85 DomStorageArea* area = GetOpenArea(connection_id); |
| 85 if (!area) | 86 if (!area) |
| 86 return NullableString16(true); | 87 return base::NullableString16(true); |
| 87 return area->Key(index); | 88 return area->Key(index); |
| 88 } | 89 } |
| 89 | 90 |
| 90 NullableString16 DomStorageHost::GetAreaItem(int connection_id, | 91 base::NullableString16 DomStorageHost::GetAreaItem(int connection_id, |
| 91 const base::string16& key) { | 92 const base::string16& key) { |
| 92 DomStorageArea* area = GetOpenArea(connection_id); | 93 DomStorageArea* area = GetOpenArea(connection_id); |
| 93 if (!area) | 94 if (!area) |
| 94 return NullableString16(true); | 95 return base::NullableString16(true); |
| 95 return area->GetItem(key); | 96 return area->GetItem(key); |
| 96 } | 97 } |
| 97 | 98 |
| 98 bool DomStorageHost::SetAreaItem( | 99 bool DomStorageHost::SetAreaItem( |
| 99 int connection_id, const base::string16& key, | 100 int connection_id, const base::string16& key, |
| 100 const base::string16& value, const GURL& page_url, | 101 const base::string16& value, const GURL& page_url, |
| 101 NullableString16* old_value) { | 102 base::NullableString16* old_value) { |
| 102 DomStorageArea* area = GetOpenArea(connection_id); | 103 DomStorageArea* area = GetOpenArea(connection_id); |
| 103 if (!area) { | 104 if (!area) { |
| 104 // TODO(michaeln): Fix crbug/134003 and return false here. | 105 // TODO(michaeln): Fix crbug/134003 and return false here. |
| 105 // Until then return true to allow the renderer to operate | 106 // Until then return true to allow the renderer to operate |
| 106 // to a limited degree out of its cache. | 107 // to a limited degree out of its cache. |
| 107 return true; | 108 return true; |
| 108 } | 109 } |
| 109 if (!area->SetItem(key, value, old_value)) | 110 if (!area->SetItem(key, value, old_value)) |
| 110 return false; | 111 return false; |
| 111 if (old_value->is_null() || old_value->string() != value) | 112 if (old_value->is_null() || old_value->string() != value) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 return NULL; | 161 return NULL; |
| 161 return found->second.namespace_.get(); | 162 return found->second.namespace_.get(); |
| 162 } | 163 } |
| 163 | 164 |
| 164 // NamespaceAndArea | 165 // NamespaceAndArea |
| 165 | 166 |
| 166 DomStorageHost::NamespaceAndArea::NamespaceAndArea() {} | 167 DomStorageHost::NamespaceAndArea::NamespaceAndArea() {} |
| 167 DomStorageHost::NamespaceAndArea::~NamespaceAndArea() {} | 168 DomStorageHost::NamespaceAndArea::~NamespaceAndArea() {} |
| 168 | 169 |
| 169 } // namespace dom_storage | 170 } // namespace dom_storage |
| OLD | NEW |