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

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

Issue 10533093: Implement WebStorageArea::containsItem(key) in chrome and drt/test_shell. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 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 | « webkit/dom_storage/dom_storage_map.cc ('k') | 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 base::WeakPtr<SimpleDomStorageSystem> parent_; 48 base::WeakPtr<SimpleDomStorageSystem> parent_;
49 int namespace_id_; 49 int namespace_id_;
50 }; 50 };
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();
jochen (gone - plz use gerrit) 2012/06/25 15:21:26 just wondering, why did you remove the OVERRIDEs?
58 virtual WebString key(unsigned index) OVERRIDE; 58 virtual WebString key(unsigned index);
59 virtual WebString getItem(const WebString& key) OVERRIDE; 59 virtual WebString getItem(const WebString& key);
60 virtual bool containsItem(const WebString& key);
60 virtual void setItem(const WebString& key, const WebString& newValue, 61 virtual void setItem(const WebString& key, const WebString& newValue,
61 const WebURL& pageUrl, Result&) OVERRIDE; 62 const WebURL& pageUrl, Result&);
62 virtual void removeItem(const WebString& key, 63 virtual void removeItem(const WebString& key,
63 const WebURL& pageUrl) OVERRIDE; 64 const WebURL& pageUrl);
64 virtual void clear(const WebURL& pageUrl) OVERRIDE; 65 virtual void clear(const WebURL& pageUrl);
65 66
66 private: 67 private:
67 DomStorageHost* Host() { 68 DomStorageHost* Host() {
68 if (!parent_.get()) 69 if (!parent_.get())
69 return NULL; 70 return NULL;
70 return parent_->host_.get(); 71 return parent_->host_.get();
71 } 72 }
72 73
73 base::WeakPtr<SimpleDomStorageSystem> parent_; 74 base::WeakPtr<SimpleDomStorageSystem> parent_;
74 int connection_id_; 75 int connection_id_;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 return Host()->GetAreaKey(connection_id_, index); 148 return Host()->GetAreaKey(connection_id_, index);
148 return NullableString16(true); 149 return NullableString16(true);
149 } 150 }
150 151
151 WebString SimpleDomStorageSystem::AreaImpl::getItem(const WebString& key) { 152 WebString SimpleDomStorageSystem::AreaImpl::getItem(const WebString& key) {
152 if (Host()) 153 if (Host())
153 return Host()->GetAreaItem(connection_id_, key); 154 return Host()->GetAreaItem(connection_id_, key);
154 return NullableString16(true); 155 return NullableString16(true);
155 } 156 }
156 157
158 bool SimpleDomStorageSystem::AreaImpl::containsItem(const WebString& key) {
159 return !getItem(key).isNull();
160 }
161
157 void SimpleDomStorageSystem::AreaImpl::setItem( 162 void SimpleDomStorageSystem::AreaImpl::setItem(
158 const WebString& key, const WebString& newValue, 163 const WebString& key, const WebString& newValue,
159 const WebURL& pageUrl, Result& result) { 164 const WebURL& pageUrl, Result& result) {
160 result = ResultBlockedByQuota; 165 result = ResultBlockedByQuota;
161 if (!Host()) 166 if (!Host())
162 return; 167 return;
163 168
164 AutoReset<AreaImpl*> auto_reset(&parent_->area_being_processed_, this); 169 AutoReset<AreaImpl*> auto_reset(&parent_->area_being_processed_, this);
165 NullableString16 unused; 170 NullableString16 unused;
166 if (!Host()->SetAreaItem(connection_id_, key, newValue, pageUrl, 171 if (!Host()->SetAreaItem(connection_id_, key, newValue, pageUrl,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 key, 279 key,
275 old_value, 280 old_value,
276 new_value, 281 new_value,
277 area->origin(), 282 area->origin(),
278 page_url, 283 page_url,
279 session_namespace_for_event_dispatch, 284 session_namespace_for_event_dispatch,
280 area_being_processed_, 285 area_being_processed_,
281 true /* originatedInProcess */); 286 true /* originatedInProcess */);
282 } 287 }
283 } 288 }
OLDNEW
« no previous file with comments | « webkit/dom_storage/dom_storage_map.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698