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

Side by Side Diff: Source/WebKit/chromium/src/StorageAreaProxy.cpp

Issue 18548003: Rename ExceptionCode constants to use the names in the spec (2/3) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All Rights Reserved. 2 * Copyright (C) 2009 Google Inc. All Rights Reserved.
3 * (C) 2008 Apple Inc. 3 * (C) 2008 Apple Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 { 57 {
58 } 58 }
59 59
60 StorageAreaProxy::~StorageAreaProxy() 60 StorageAreaProxy::~StorageAreaProxy()
61 { 61 {
62 } 62 }
63 63
64 unsigned StorageAreaProxy::length(ExceptionCode& ec, Frame* frame) 64 unsigned StorageAreaProxy::length(ExceptionCode& ec, Frame* frame)
65 { 65 {
66 if (!canAccessStorage(frame)) { 66 if (!canAccessStorage(frame)) {
67 ec = SECURITY_ERR; 67 ec = SecurityError;
68 return 0; 68 return 0;
69 } 69 }
70 ec = 0; 70 ec = 0;
71 return m_storageArea->length(); 71 return m_storageArea->length();
72 } 72 }
73 73
74 String StorageAreaProxy::key(unsigned index, ExceptionCode& ec, Frame* frame) 74 String StorageAreaProxy::key(unsigned index, ExceptionCode& ec, Frame* frame)
75 { 75 {
76 if (!canAccessStorage(frame)) { 76 if (!canAccessStorage(frame)) {
77 ec = SECURITY_ERR; 77 ec = SecurityError;
78 return String(); 78 return String();
79 } 79 }
80 ec = 0; 80 ec = 0;
81 return m_storageArea->key(index); 81 return m_storageArea->key(index);
82 } 82 }
83 83
84 String StorageAreaProxy::getItem(const String& key, ExceptionCode& ec, Frame* fr ame) 84 String StorageAreaProxy::getItem(const String& key, ExceptionCode& ec, Frame* fr ame)
85 { 85 {
86 if (!canAccessStorage(frame)) { 86 if (!canAccessStorage(frame)) {
87 ec = SECURITY_ERR; 87 ec = SecurityError;
88 return String(); 88 return String();
89 } 89 }
90 ec = 0; 90 ec = 0;
91 return m_storageArea->getItem(key); 91 return m_storageArea->getItem(key);
92 } 92 }
93 93
94 void StorageAreaProxy::setItem(const String& key, const String& value, Exception Code& ec, Frame* frame) 94 void StorageAreaProxy::setItem(const String& key, const String& value, Exception Code& ec, Frame* frame)
95 { 95 {
96 if (!canAccessStorage(frame)) { 96 if (!canAccessStorage(frame)) {
97 ec = SECURITY_ERR; 97 ec = SecurityError;
98 return; 98 return;
99 } 99 }
100 WebKit::WebStorageArea::Result result = WebKit::WebStorageArea::ResultOK; 100 WebKit::WebStorageArea::Result result = WebKit::WebStorageArea::ResultOK;
101 m_storageArea->setItem(key, value, frame->document()->url(), result); 101 m_storageArea->setItem(key, value, frame->document()->url(), result);
102 ec = (result == WebKit::WebStorageArea::ResultOK) ? 0 : QUOTA_EXCEEDED_ERR; 102 ec = (result == WebKit::WebStorageArea::ResultOK) ? 0 : QUOTA_EXCEEDED_ERR;
103 } 103 }
104 104
105 void StorageAreaProxy::removeItem(const String& key, ExceptionCode& ec, Frame* f rame) 105 void StorageAreaProxy::removeItem(const String& key, ExceptionCode& ec, Frame* f rame)
106 { 106 {
107 if (!canAccessStorage(frame)) { 107 if (!canAccessStorage(frame)) {
108 ec = SECURITY_ERR; 108 ec = SecurityError;
109 return; 109 return;
110 } 110 }
111 ec = 0; 111 ec = 0;
112 m_storageArea->removeItem(key, frame->document()->url()); 112 m_storageArea->removeItem(key, frame->document()->url());
113 } 113 }
114 114
115 void StorageAreaProxy::clear(ExceptionCode& ec, Frame* frame) 115 void StorageAreaProxy::clear(ExceptionCode& ec, Frame* frame)
116 { 116 {
117 if (!canAccessStorage(frame)) { 117 if (!canAccessStorage(frame)) {
118 ec = SECURITY_ERR; 118 ec = SecurityError;
119 return; 119 return;
120 } 120 }
121 ec = 0; 121 ec = 0;
122 m_storageArea->clear(frame->document()->url()); 122 m_storageArea->clear(frame->document()->url());
123 } 123 }
124 124
125 bool StorageAreaProxy::contains(const String& key, ExceptionCode& ec, Frame* fra me) 125 bool StorageAreaProxy::contains(const String& key, ExceptionCode& ec, Frame* fra me)
126 { 126 {
127 if (!canAccessStorage(frame)) { 127 if (!canAccessStorage(frame)) {
128 ec = SECURITY_ERR; 128 ec = SecurityError;
129 return false; 129 return false;
130 } 130 }
131 return !getItem(key, ec, frame).isNull(); 131 return !getItem(key, ec, frame).isNull();
132 } 132 }
133 133
134 bool StorageAreaProxy::canAccessStorage(Frame* frame) 134 bool StorageAreaProxy::canAccessStorage(Frame* frame)
135 { 135 {
136 if (!frame || !frame->page()) 136 if (!frame || !frame->page())
137 return false; 137 return false;
138 if (m_canAccessStorageCachedFrame == frame) 138 if (m_canAccessStorageCachedFrame == frame)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 195 }
196 196
197 bool StorageAreaProxy::isEventSource(Storage* storage, WebKit::WebStorageArea* s ourceAreaInstance) 197 bool StorageAreaProxy::isEventSource(Storage* storage, WebKit::WebStorageArea* s ourceAreaInstance)
198 { 198 {
199 ASSERT(storage); 199 ASSERT(storage);
200 StorageAreaProxy* areaProxy = static_cast<StorageAreaProxy*>(storage->area() ); 200 StorageAreaProxy* areaProxy = static_cast<StorageAreaProxy*>(storage->area() );
201 return areaProxy->m_storageArea == sourceAreaInstance; 201 return areaProxy->m_storageArea == sourceAreaInstance;
202 } 202 }
203 203
204 } // namespace WebCore 204 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebKit/chromium/src/AssertMatchingEnums.cpp ('k') | Source/bindings/scripts/CodeGeneratorV8.pm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698