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

Side by Side Diff: webkit/tools/test_shell/simple_dom_storage_system.cc

Issue 10408049: Fixup SimpleDomStorageSystem to no longer use obsolete WebKit API that required returns of previous… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 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/tools/test_shell/simple_dom_storage_system.h" 5 #include "webkit/tools/test_shell/simple_dom_storage_system.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "googleurl/src/gurl.h" 8 #include "googleurl/src/gurl.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" 9 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageArea.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageArea.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 class SimpleDomStorageSystem::AreaImpl : public WebStorageArea { 52 class SimpleDomStorageSystem::AreaImpl : public WebStorageArea {
53 public: 53 public:
54 AreaImpl(const base::WeakPtr<SimpleDomStorageSystem>& parent, 54 AreaImpl(const base::WeakPtr<SimpleDomStorageSystem>& parent,
55 int namespace_id, const GURL& origin); 55 int namespace_id, const GURL& origin);
56 virtual ~AreaImpl(); 56 virtual ~AreaImpl();
57 virtual unsigned length() OVERRIDE; 57 virtual unsigned length() OVERRIDE;
58 virtual WebString key(unsigned index) OVERRIDE; 58 virtual WebString key(unsigned index) OVERRIDE;
59 virtual WebString getItem(const WebString& key) OVERRIDE; 59 virtual WebString getItem(const WebString& key) OVERRIDE;
60 virtual void setItem(const WebString& key, const WebString& newValue, 60 virtual void setItem(const WebString& key, const WebString& newValue,
61 const WebURL&, Result&, WebString& oldValue) OVERRIDE; 61 const WebURL& pageUrl, Result&) OVERRIDE;
62 virtual void removeItem(const WebString& key, const WebURL& url, 62 virtual void removeItem(const WebString& key,
63 WebString& oldValue) OVERRIDE; 63 const WebURL& pageUrl) OVERRIDE;
64 virtual void clear(const WebURL& url, bool& somethingCleared) OVERRIDE; 64 virtual void clear(const WebURL& pageUrl) OVERRIDE;
65 65
66 private: 66 private:
67 DomStorageHost* Host() { 67 DomStorageHost* Host() {
68 if (!parent_.get()) 68 if (!parent_.get())
69 return NULL; 69 return NULL;
70 return parent_->host_.get(); 70 return parent_->host_.get();
71 } 71 }
72 72
73 base::WeakPtr<SimpleDomStorageSystem> parent_; 73 base::WeakPtr<SimpleDomStorageSystem> parent_;
74 int connection_id_; 74 int connection_id_;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 149 }
150 150
151 WebString SimpleDomStorageSystem::AreaImpl::getItem(const WebString& key) { 151 WebString SimpleDomStorageSystem::AreaImpl::getItem(const WebString& key) {
152 if (Host()) 152 if (Host())
153 return Host()->GetAreaItem(connection_id_, key); 153 return Host()->GetAreaItem(connection_id_, key);
154 return NullableString16(true); 154 return NullableString16(true);
155 } 155 }
156 156
157 void SimpleDomStorageSystem::AreaImpl::setItem( 157 void SimpleDomStorageSystem::AreaImpl::setItem(
158 const WebString& key, const WebString& newValue, 158 const WebString& key, const WebString& newValue,
159 const WebURL& pageUrl, Result& result, WebString& oldValue) { 159 const WebURL& pageUrl, Result& result) {
160 result = ResultBlockedByQuota; 160 result = ResultBlockedByQuota;
161 oldValue = NullableString16(true);
162 if (!Host()) 161 if (!Host())
163 return; 162 return;
164 163
165 AutoReset<AreaImpl*> auto_reset(&parent_->area_being_processed_, this); 164 AutoReset<AreaImpl*> auto_reset(&parent_->area_being_processed_, this);
166 NullableString16 old_value; 165 NullableString16 unused;
167 if (!Host()->SetAreaItem(connection_id_, key, newValue, pageUrl, 166 if (!Host()->SetAreaItem(connection_id_, key, newValue, pageUrl,
168 &old_value)) 167 &unused))
169 return; 168 return;
170 169
171 result = ResultOK; 170 result = ResultOK;
172 oldValue = old_value;
173 } 171 }
174 172
175 void SimpleDomStorageSystem::AreaImpl::removeItem( 173 void SimpleDomStorageSystem::AreaImpl::removeItem(
176 const WebString& key, const WebURL& pageUrl, WebString& oldValue) { 174 const WebString& key, const WebURL& pageUrl) {
177 oldValue = NullableString16(true);
178 if (!Host()) 175 if (!Host())
179 return; 176 return;
180 177
181 AutoReset<AreaImpl*> auto_reset(&parent_->area_being_processed_, this); 178 AutoReset<AreaImpl*> auto_reset(&parent_->area_being_processed_, this);
182 string16 old_value; 179 string16 notused;
183 if (!Host()->RemoveAreaItem(connection_id_, key, pageUrl, &old_value)) 180 Host()->RemoveAreaItem(connection_id_, key, pageUrl, &notused);
181 }
182
183 void SimpleDomStorageSystem::AreaImpl::clear(const WebURL& pageUrl) {
184 if (!Host())
184 return; 185 return;
185 186
186 oldValue = old_value; 187 AutoReset<AreaImpl*> auto_reset(&parent_->area_being_processed_, this);
187 } 188 Host()->ClearArea(connection_id_, pageUrl);
188
189 void SimpleDomStorageSystem::AreaImpl::clear(
190 const WebURL& pageUrl, bool& somethingCleared) {
191 if (Host()) {
192 AutoReset<AreaImpl*> auto_reset(&parent_->area_being_processed_, this);
193 somethingCleared = Host()->ClearArea(connection_id_, pageUrl);
194 return;
195 }
196 somethingCleared = false;
197 } 189 }
198 190
199 // SimpleDomStorageSystem ----------------------------- 191 // SimpleDomStorageSystem -----------------------------
200 192
201 SimpleDomStorageSystem* SimpleDomStorageSystem::g_instance_; 193 SimpleDomStorageSystem* SimpleDomStorageSystem::g_instance_;
202 194
203 SimpleDomStorageSystem::SimpleDomStorageSystem() 195 SimpleDomStorageSystem::SimpleDomStorageSystem()
204 : weak_factory_(this), 196 : weak_factory_(this),
205 context_(new DomStorageContext(FilePath(), FilePath(), NULL, NULL)), 197 context_(new DomStorageContext(FilePath(), FilePath(), NULL, NULL)),
206 host_(new DomStorageHost(context_)), 198 host_(new DomStorageHost(context_)),
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 key, 274 key,
283 old_value, 275 old_value,
284 new_value, 276 new_value,
285 area->origin(), 277 area->origin(),
286 page_url, 278 page_url,
287 session_namespace_for_event_dispatch, 279 session_namespace_for_event_dispatch,
288 area_being_processed_, 280 area_being_processed_,
289 true /* originatedInProcess */); 281 true /* originatedInProcess */);
290 } 282 }
291 } 283 }
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