Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: webkit/browser/dom_storage/dom_storage_host.cc

Issue 19756002: Undo band-aid which was ignoring wrong SessionStorage association. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "url/gurl.h" 7 #include "url/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 12 matching lines...) Expand all
23 connections_.clear(); // Clear prior to releasing the context_ 23 connections_.clear(); // Clear prior to releasing the context_
24 } 24 }
25 25
26 bool DomStorageHost::OpenStorageArea(int connection_id, int namespace_id, 26 bool DomStorageHost::OpenStorageArea(int connection_id, int namespace_id,
27 const GURL& origin) { 27 const GURL& origin) {
28 DCHECK(!GetOpenArea(connection_id)); 28 DCHECK(!GetOpenArea(connection_id));
29 if (GetOpenArea(connection_id)) 29 if (GetOpenArea(connection_id))
30 return false; // Indicates the renderer gave us very bad data. 30 return false; // Indicates the renderer gave us very bad data.
31 NamespaceAndArea references; 31 NamespaceAndArea references;
32 references.namespace_ = context_->GetStorageNamespace(namespace_id); 32 references.namespace_ = context_->GetStorageNamespace(namespace_id);
33 if (!references.namespace_.get()) { 33 if (!references.namespace_.get())
34 // TODO(michaeln): Fix crbug/134003 and return false here. 34 return false;
35 // Until then return true to avoid crashing the renderer for
36 // sending a bad message.
37 return true;
38 }
39 references.area_ = references.namespace_->OpenStorageArea(origin); 35 references.area_ = references.namespace_->OpenStorageArea(origin);
40 DCHECK(references.area_.get()); 36 DCHECK(references.area_.get());
41 connections_[connection_id] = references; 37 connections_[connection_id] = references;
42 return true; 38 return true;
43 } 39 }
44 40
45 void DomStorageHost::CloseStorageArea(int connection_id) { 41 void DomStorageHost::CloseStorageArea(int connection_id) {
46 AreaMap::iterator found = connections_.find(connection_id); 42 AreaMap::iterator found = connections_.find(connection_id);
47 if (found == connections_.end()) 43 if (found == connections_.end())
48 return; 44 return;
49 found->second.namespace_->CloseStorageArea(found->second.area_.get()); 45 found->second.namespace_->CloseStorageArea(found->second.area_.get());
50 connections_.erase(found); 46 connections_.erase(found);
51 } 47 }
52 48
53 bool DomStorageHost::ExtractAreaValues( 49 bool DomStorageHost::ExtractAreaValues(
54 int connection_id, ValuesMap* map) { 50 int connection_id, ValuesMap* map) {
55 map->clear(); 51 map->clear();
56 DomStorageArea* area = GetOpenArea(connection_id); 52 DomStorageArea* area = GetOpenArea(connection_id);
57 if (!area) { 53 if (!area)
58 // TODO(michaeln): Fix crbug/134003 and return false here. 54 return false;
59 // Until then return true to avoid crashing the renderer
60 // for sending a bad message.
61 return true;
62 }
63 if (!area->IsLoadedInMemory()) { 55 if (!area->IsLoadedInMemory()) {
64 DomStorageNamespace* ns = GetNamespace(connection_id); 56 DomStorageNamespace* ns = GetNamespace(connection_id);
65 DCHECK(ns); 57 DCHECK(ns);
66 if (ns->CountInMemoryAreas() > kMaxInMemoryAreas) { 58 if (ns->CountInMemoryAreas() > kMaxInMemoryAreas) {
67 ns->PurgeMemory(DomStorageNamespace::PURGE_UNOPENED); 59 ns->PurgeMemory(DomStorageNamespace::PURGE_UNOPENED);
68 if (ns->CountInMemoryAreas() > kMaxInMemoryAreas) 60 if (ns->CountInMemoryAreas() > kMaxInMemoryAreas)
69 ns->PurgeMemory(DomStorageNamespace::PURGE_AGGRESSIVE); 61 ns->PurgeMemory(DomStorageNamespace::PURGE_AGGRESSIVE);
70 } 62 }
71 } 63 }
72 area->ExtractValues(map); 64 area->ExtractValues(map);
(...skipping 21 matching lines...) Expand all
94 if (!area) 86 if (!area)
95 return base::NullableString16(); 87 return base::NullableString16();
96 return area->GetItem(key); 88 return area->GetItem(key);
97 } 89 }
98 90
99 bool DomStorageHost::SetAreaItem( 91 bool DomStorageHost::SetAreaItem(
100 int connection_id, const base::string16& key, 92 int connection_id, const base::string16& key,
101 const base::string16& value, const GURL& page_url, 93 const base::string16& value, const GURL& page_url,
102 base::NullableString16* old_value) { 94 base::NullableString16* old_value) {
103 DomStorageArea* area = GetOpenArea(connection_id); 95 DomStorageArea* area = GetOpenArea(connection_id);
104 if (!area) { 96 if (!area)
105 // TODO(michaeln): Fix crbug/134003 and return false here. 97 return false;
106 // Until then return true to allow the renderer to operate
107 // to a limited degree out of its cache.
108 return true;
109 }
110 if (!area->SetItem(key, value, old_value)) 98 if (!area->SetItem(key, value, old_value))
111 return false; 99 return false;
112 if (old_value->is_null() || old_value->string() != value) 100 if (old_value->is_null() || old_value->string() != value)
113 context_->NotifyItemSet(area, key, value, *old_value, page_url); 101 context_->NotifyItemSet(area, key, value, *old_value, page_url);
114 return true; 102 return true;
115 } 103 }
116 104
117 bool DomStorageHost::RemoveAreaItem( 105 bool DomStorageHost::RemoveAreaItem(
118 int connection_id, const base::string16& key, const GURL& page_url, 106 int connection_id, const base::string16& key, const GURL& page_url,
119 base::string16* old_value) { 107 base::string16* old_value) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 return NULL; 149 return NULL;
162 return found->second.namespace_.get(); 150 return found->second.namespace_.get();
163 } 151 }
164 152
165 // NamespaceAndArea 153 // NamespaceAndArea
166 154
167 DomStorageHost::NamespaceAndArea::NamespaceAndArea() {} 155 DomStorageHost::NamespaceAndArea::NamespaceAndArea() {}
168 DomStorageHost::NamespaceAndArea::~NamespaceAndArea() {} 156 DomStorageHost::NamespaceAndArea::~NamespaceAndArea() {}
169 157
170 } // namespace dom_storage 158 } // namespace dom_storage
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698