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

Side by Side Diff: Source/modules/storage/InspectorDOMStorageAgent.cpp

Issue 1055133003: Oilpan: have Storage objects reside on the heap by default. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: trivial cl footprint reduction Created 5 years, 8 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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. 3 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
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 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 return; 105 return;
106 m_isEnabled = false; 106 m_isEnabled = false;
107 m_state->setBoolean(DOMStorageAgentState::domStorageAgentEnabled, false); 107 m_state->setBoolean(DOMStorageAgentState::domStorageAgentEnabled, false);
108 if (StorageNamespaceController* controller = StorageNamespaceController::fro m(m_page)) 108 if (StorageNamespaceController* controller = StorageNamespaceController::fro m(m_page))
109 controller->setInspectorAgent(nullptr); 109 controller->setInspectorAgent(nullptr);
110 } 110 }
111 111
112 void InspectorDOMStorageAgent::getDOMStorageItems(ErrorString* errorString, cons t RefPtr<JSONObject>& storageId, RefPtr<TypeBuilder::Array<TypeBuilder::Array<St ring>>>& items) 112 void InspectorDOMStorageAgent::getDOMStorageItems(ErrorString* errorString, cons t RefPtr<JSONObject>& storageId, RefPtr<TypeBuilder::Array<TypeBuilder::Array<St ring>>>& items)
113 { 113 {
114 LocalFrame* frame; 114 LocalFrame* frame;
115 OwnPtrWillBeRawPtr<StorageArea> storageArea = findStorageArea(errorString, s torageId, frame); 115 StorageArea* storageArea = findStorageArea(errorString, storageId, frame);
116 if (!storageArea) 116 if (!storageArea)
117 return; 117 return;
118 118
119 RefPtr<TypeBuilder::Array<TypeBuilder::Array<String>>> storageItems = TypeBu ilder::Array<TypeBuilder::Array<String>>::create(); 119 RefPtr<TypeBuilder::Array<TypeBuilder::Array<String>>> storageItems = TypeBu ilder::Array<TypeBuilder::Array<String>>::create();
120 120
121 TrackExceptionState exceptionState; 121 TrackExceptionState exceptionState;
122 for (unsigned i = 0; i < storageArea->length(exceptionState, frame); ++i) { 122 for (unsigned i = 0; i < storageArea->length(exceptionState, frame); ++i) {
123 String name(storageArea->key(i, exceptionState, frame)); 123 String name(storageArea->key(i, exceptionState, frame));
124 if (hadException(exceptionState, errorString)) 124 if (hadException(exceptionState, errorString))
125 return; 125 return;
(...skipping 11 matching lines...) Expand all
137 static String toErrorString(ExceptionState& exceptionState) 137 static String toErrorString(ExceptionState& exceptionState)
138 { 138 {
139 if (exceptionState.hadException()) 139 if (exceptionState.hadException())
140 return DOMException::getErrorName(exceptionState.code()); 140 return DOMException::getErrorName(exceptionState.code());
141 return ""; 141 return "";
142 } 142 }
143 143
144 void InspectorDOMStorageAgent::setDOMStorageItem(ErrorString* errorString, const RefPtr<JSONObject>& storageId, const String& key, const String& value) 144 void InspectorDOMStorageAgent::setDOMStorageItem(ErrorString* errorString, const RefPtr<JSONObject>& storageId, const String& key, const String& value)
145 { 145 {
146 LocalFrame* frame; 146 LocalFrame* frame;
147 OwnPtrWillBeRawPtr<StorageArea> storageArea = findStorageArea(0, storageId, frame); 147 StorageArea* storageArea = findStorageArea(0, storageId, frame);
148 if (!storageArea) { 148 if (!storageArea) {
149 *errorString = "Storage not found"; 149 *errorString = "Storage not found";
150 return; 150 return;
151 } 151 }
152 152
153 TrackExceptionState exceptionState; 153 TrackExceptionState exceptionState;
154 storageArea->setItem(key, value, exceptionState, frame); 154 storageArea->setItem(key, value, exceptionState, frame);
155 *errorString = toErrorString(exceptionState); 155 *errorString = toErrorString(exceptionState);
156 } 156 }
157 157
158 void InspectorDOMStorageAgent::removeDOMStorageItem(ErrorString* errorString, co nst RefPtr<JSONObject>& storageId, const String& key) 158 void InspectorDOMStorageAgent::removeDOMStorageItem(ErrorString* errorString, co nst RefPtr<JSONObject>& storageId, const String& key)
159 { 159 {
160 LocalFrame* frame; 160 LocalFrame* frame;
161 OwnPtrWillBeRawPtr<StorageArea> storageArea = findStorageArea(0, storageId, frame); 161 StorageArea* storageArea = findStorageArea(0, storageId, frame);
162 if (!storageArea) { 162 if (!storageArea) {
163 *errorString = "Storage not found"; 163 *errorString = "Storage not found";
164 return; 164 return;
165 } 165 }
166 166
167 TrackExceptionState exceptionState; 167 TrackExceptionState exceptionState;
168 storageArea->removeItem(key, exceptionState, frame); 168 storageArea->removeItem(key, exceptionState, frame);
169 *errorString = toErrorString(exceptionState); 169 *errorString = toErrorString(exceptionState);
170 } 170 }
171 171
(...skipping 26 matching lines...) Expand all
198 for (Frame* frame = inspectedFrame; frame; frame = frame->tree().traverseNex t(inspectedFrame)) { 198 for (Frame* frame = inspectedFrame; frame; frame = frame->tree().traverseNex t(inspectedFrame)) {
199 if (!frame->isLocalFrame()) 199 if (!frame->isLocalFrame())
200 continue; 200 continue;
201 RefPtr<SecurityOrigin> documentOrigin = toLocalFrame(frame)->document()- >securityOrigin(); 201 RefPtr<SecurityOrigin> documentOrigin = toLocalFrame(frame)->document()- >securityOrigin();
202 if (documentOrigin->toRawString() == originRawString) 202 if (documentOrigin->toRawString() == originRawString)
203 return toLocalFrame(frame); 203 return toLocalFrame(frame);
204 } 204 }
205 return nullptr; 205 return nullptr;
206 } 206 }
207 207
208 PassOwnPtrWillBeRawPtr<StorageArea> InspectorDOMStorageAgent::findStorageArea(Er rorString* errorString, const RefPtr<JSONObject>& storageId, LocalFrame*& target Frame) 208 StorageArea* InspectorDOMStorageAgent::findStorageArea(ErrorString* errorString, const RefPtr<JSONObject>& storageId, LocalFrame*& targetFrame)
209 { 209 {
210 String securityOrigin; 210 String securityOrigin;
211 bool isLocalStorage = false; 211 bool isLocalStorage = false;
212 bool success = storageId->getString("securityOrigin", &securityOrigin); 212 bool success = storageId->getString("securityOrigin", &securityOrigin);
213 if (success) 213 if (success)
214 success = storageId->getBoolean("isLocalStorage", &isLocalStorage); 214 success = storageId->getBoolean("isLocalStorage", &isLocalStorage);
215 if (!success) { 215 if (!success) {
216 if (errorString) 216 if (errorString)
217 *errorString = "Invalid storageId format"; 217 *errorString = "Invalid storageId format";
218 return nullptr; 218 return nullptr;
219 } 219 }
220 220
221 if (!m_page->mainFrame()->isLocalFrame()) 221 if (!m_page->mainFrame()->isLocalFrame())
222 return nullptr; 222 return nullptr;
223 223
224 LocalFrame* frame = findFrameWithSecurityOrigin(m_page->deprecatedLocalMainF rame(), securityOrigin); 224 LocalFrame* frame = findFrameWithSecurityOrigin(m_page->deprecatedLocalMainF rame(), securityOrigin);
225 if (!frame) { 225 if (!frame) {
226 if (errorString) 226 if (errorString)
227 *errorString = "LocalFrame not found for the given security origin"; 227 *errorString = "LocalFrame not found for the given security origin";
228 return nullptr; 228 return nullptr;
229 } 229 }
230 targetFrame = frame; 230 targetFrame = frame;
231 231
232 if (isLocalStorage) 232 if (isLocalStorage)
233 return StorageNamespace::localStorageArea(frame->document()->securityOri gin()); 233 return StorageNamespace::localStorageArea(frame->document()->securityOri gin());
234 return StorageNamespaceController::from(m_page)->sessionStorage()->storageAr ea(frame->document()->securityOrigin()); 234 return StorageNamespaceController::from(m_page)->sessionStorage()->storageAr ea(frame->document()->securityOrigin());
235 } 235 }
236 236
237 } // namespace blink 237 } // namespace blink
238
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698