| 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_host.h" | 5 #include "webkit/dom_storage/dom_storage_host.h" |
| 6 | 6 |
| 7 #include "googleurl/src/gurl.h" | 7 #include "googleurl/src/gurl.h" |
| 8 #include "webkit/dom_storage/dom_storage_area.h" | 8 #include "webkit/dom_storage/dom_storage_area.h" |
| 9 #include "webkit/dom_storage/dom_storage_context.h" | 9 #include "webkit/dom_storage/dom_storage_context.h" |
| 10 #include "webkit/dom_storage/dom_storage_namespace.h" | 10 #include "webkit/dom_storage/dom_storage_namespace.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 73 } |
| 74 | 74 |
| 75 NullableString16 DomStorageHost::GetAreaKey(int connection_id, unsigned index) { | 75 NullableString16 DomStorageHost::GetAreaKey(int connection_id, unsigned index) { |
| 76 DomStorageArea* area = GetOpenArea(connection_id); | 76 DomStorageArea* area = GetOpenArea(connection_id); |
| 77 if (!area) | 77 if (!area) |
| 78 return NullableString16(true); | 78 return NullableString16(true); |
| 79 return area->Key(index); | 79 return area->Key(index); |
| 80 } | 80 } |
| 81 | 81 |
| 82 NullableString16 DomStorageHost::GetAreaItem(int connection_id, | 82 NullableString16 DomStorageHost::GetAreaItem(int connection_id, |
| 83 const string16& key) { | 83 const base::string16& key) { |
| 84 DomStorageArea* area = GetOpenArea(connection_id); | 84 DomStorageArea* area = GetOpenArea(connection_id); |
| 85 if (!area) | 85 if (!area) |
| 86 return NullableString16(true); | 86 return NullableString16(true); |
| 87 return area->GetItem(key); | 87 return area->GetItem(key); |
| 88 } | 88 } |
| 89 | 89 |
| 90 bool DomStorageHost::SetAreaItem( | 90 bool DomStorageHost::SetAreaItem( |
| 91 int connection_id, const string16& key, | 91 int connection_id, const base::string16& key, |
| 92 const string16& value, const GURL& page_url, | 92 const base::string16& value, const GURL& page_url, |
| 93 NullableString16* old_value) { | 93 NullableString16* old_value) { |
| 94 DomStorageArea* area = GetOpenArea(connection_id); | 94 DomStorageArea* area = GetOpenArea(connection_id); |
| 95 if (!area) { | 95 if (!area) { |
| 96 // TODO(michaeln): Fix crbug/134003 and return false here. | 96 // TODO(michaeln): Fix crbug/134003 and return false here. |
| 97 // Until then return true to allow the renderer to operate | 97 // Until then return true to allow the renderer to operate |
| 98 // to a limited degree out of its cache. | 98 // to a limited degree out of its cache. |
| 99 return true; | 99 return true; |
| 100 } | 100 } |
| 101 if (!area->SetItem(key, value, old_value)) | 101 if (!area->SetItem(key, value, old_value)) |
| 102 return false; | 102 return false; |
| 103 if (old_value->is_null() || old_value->string() != value) | 103 if (old_value->is_null() || old_value->string() != value) |
| 104 context_->NotifyItemSet(area, key, value, *old_value, page_url); | 104 context_->NotifyItemSet(area, key, value, *old_value, page_url); |
| 105 return true; | 105 return true; |
| 106 } | 106 } |
| 107 | 107 |
| 108 bool DomStorageHost::RemoveAreaItem( | 108 bool DomStorageHost::RemoveAreaItem( |
| 109 int connection_id, const string16& key, const GURL& page_url, | 109 int connection_id, const base::string16& key, const GURL& page_url, |
| 110 string16* old_value) { | 110 base::string16* old_value) { |
| 111 DomStorageArea* area = GetOpenArea(connection_id); | 111 DomStorageArea* area = GetOpenArea(connection_id); |
| 112 if (!area) | 112 if (!area) |
| 113 return false; | 113 return false; |
| 114 if (!area->RemoveItem(key, old_value)) | 114 if (!area->RemoveItem(key, old_value)) |
| 115 return false; | 115 return false; |
| 116 context_->NotifyItemRemoved(area, key, *old_value, page_url); | 116 context_->NotifyItemRemoved(area, key, *old_value, page_url); |
| 117 return true; | 117 return true; |
| 118 } | 118 } |
| 119 | 119 |
| 120 bool DomStorageHost::ClearArea(int connection_id, const GURL& page_url) { | 120 bool DomStorageHost::ClearArea(int connection_id, const GURL& page_url) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 145 return NULL; | 145 return NULL; |
| 146 return found->second.area_; | 146 return found->second.area_; |
| 147 } | 147 } |
| 148 | 148 |
| 149 // NamespaceAndArea | 149 // NamespaceAndArea |
| 150 | 150 |
| 151 DomStorageHost::NamespaceAndArea::NamespaceAndArea() {} | 151 DomStorageHost::NamespaceAndArea::NamespaceAndArea() {} |
| 152 DomStorageHost::NamespaceAndArea::~NamespaceAndArea() {} | 152 DomStorageHost::NamespaceAndArea::~NamespaceAndArea() {} |
| 153 | 153 |
| 154 } // namespace dom_storage | 154 } // namespace dom_storage |
| OLD | NEW |