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

Side by Side Diff: Source/core/inspector/InspectorIndexedDBAgent.cpp

Issue 72363002: Rename es => exceptionState in other than bindings/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Retry Created 7 years, 1 month 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 virtual void handleEvent(ExecutionContext*, Event* event) OVERRIDE 102 virtual void handleEvent(ExecutionContext*, Event* event) OVERRIDE
103 { 103 {
104 if (!m_requestCallback->isActive()) 104 if (!m_requestCallback->isActive())
105 return; 105 return;
106 if (event->type() != EventTypeNames::success) { 106 if (event->type() != EventTypeNames::success) {
107 m_requestCallback->sendFailure("Unexpected event type."); 107 m_requestCallback->sendFailure("Unexpected event type.");
108 return; 108 return;
109 } 109 }
110 110
111 IDBRequest* idbRequest = static_cast<IDBRequest*>(event->target()); 111 IDBRequest* idbRequest = static_cast<IDBRequest*>(event->target());
112 TrackExceptionState es; 112 TrackExceptionState exceptionState;
113 RefPtr<IDBAny> requestResult = idbRequest->result(es); 113 RefPtr<IDBAny> requestResult = idbRequest->result(exceptionState);
114 if (es.hadException()) { 114 if (exceptionState.hadException()) {
115 m_requestCallback->sendFailure("Could not get result in callback."); 115 m_requestCallback->sendFailure("Could not get result in callback.");
116 return; 116 return;
117 } 117 }
118 if (requestResult->type() != IDBAny::DOMStringListType) { 118 if (requestResult->type() != IDBAny::DOMStringListType) {
119 m_requestCallback->sendFailure("Unexpected result type."); 119 m_requestCallback->sendFailure("Unexpected result type.");
120 return; 120 return;
121 } 121 }
122 122
123 RefPtr<DOMStringList> databaseNamesList = requestResult->domStringList() ; 123 RefPtr<DOMStringList> databaseNamesList = requestResult->domStringList() ;
124 RefPtr<TypeBuilder::Array<String> > databaseNames = TypeBuilder::Array<S tring>::create(); 124 RefPtr<TypeBuilder::Array<String> > databaseNames = TypeBuilder::Array<S tring>::create();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 164 }
165 165
166 virtual void handleEvent(ExecutionContext*, Event* event) OVERRIDE 166 virtual void handleEvent(ExecutionContext*, Event* event) OVERRIDE
167 { 167 {
168 if (event->type() != EventTypeNames::success) { 168 if (event->type() != EventTypeNames::success) {
169 m_executableWithDatabase->requestCallback()->sendFailure("Unexpected event type."); 169 m_executableWithDatabase->requestCallback()->sendFailure("Unexpected event type.");
170 return; 170 return;
171 } 171 }
172 172
173 IDBOpenDBRequest* idbOpenDBRequest = static_cast<IDBOpenDBRequest*>(even t->target()); 173 IDBOpenDBRequest* idbOpenDBRequest = static_cast<IDBOpenDBRequest*>(even t->target());
174 TrackExceptionState es; 174 TrackExceptionState exceptionState;
175 RefPtr<IDBAny> requestResult = idbOpenDBRequest->result(es); 175 RefPtr<IDBAny> requestResult = idbOpenDBRequest->result(exceptionState);
176 if (es.hadException()) { 176 if (exceptionState.hadException()) {
177 m_executableWithDatabase->requestCallback()->sendFailure("Could not get result in callback."); 177 m_executableWithDatabase->requestCallback()->sendFailure("Could not get result in callback.");
178 return; 178 return;
179 } 179 }
180 if (requestResult->type() != IDBAny::IDBDatabaseType) { 180 if (requestResult->type() != IDBAny::IDBDatabaseType) {
181 m_executableWithDatabase->requestCallback()->sendFailure("Unexpected result type."); 181 m_executableWithDatabase->requestCallback()->sendFailure("Unexpected result type.");
182 return; 182 return;
183 } 183 }
184 184
185 RefPtr<IDBDatabase> idbDatabase = requestResult->idbDatabase(); 185 RefPtr<IDBDatabase> idbDatabase = requestResult->idbDatabase();
186 m_executableWithDatabase->execute(idbDatabase); 186 m_executableWithDatabase->execute(idbDatabase);
187 IDBPendingTransactionMonitor::deactivateNewTransactions(); 187 IDBPendingTransactionMonitor::deactivateNewTransactions();
188 idbDatabase->close(); 188 idbDatabase->close();
189 } 189 }
190 190
191 private: 191 private:
192 OpenDatabaseCallback(ExecutableWithDatabase* executableWithDatabase) 192 OpenDatabaseCallback(ExecutableWithDatabase* executableWithDatabase)
193 : EventListener(EventListener::CPPEventListenerType) 193 : EventListener(EventListener::CPPEventListenerType)
194 , m_executableWithDatabase(executableWithDatabase) { } 194 , m_executableWithDatabase(executableWithDatabase) { }
195 RefPtr<ExecutableWithDatabase> m_executableWithDatabase; 195 RefPtr<ExecutableWithDatabase> m_executableWithDatabase;
196 }; 196 };
197 197
198 void ExecutableWithDatabase::start(IDBFactory* idbFactory, SecurityOrigin*, cons t String& databaseName) 198 void ExecutableWithDatabase::start(IDBFactory* idbFactory, SecurityOrigin*, cons t String& databaseName)
199 { 199 {
200 RefPtr<OpenDatabaseCallback> callback = OpenDatabaseCallback::create(this); 200 RefPtr<OpenDatabaseCallback> callback = OpenDatabaseCallback::create(this);
201 TrackExceptionState es; 201 TrackExceptionState exceptionState;
202 RefPtr<IDBOpenDBRequest> idbOpenDBRequest = idbFactory->open(context(), data baseName, es); 202 RefPtr<IDBOpenDBRequest> idbOpenDBRequest = idbFactory->open(context(), data baseName, exceptionState);
203 if (es.hadException()) { 203 if (exceptionState.hadException()) {
204 requestCallback()->sendFailure("Could not open database."); 204 requestCallback()->sendFailure("Could not open database.");
205 return; 205 return;
206 } 206 }
207 idbOpenDBRequest->addEventListener(EventTypeNames::success, callback, false) ; 207 idbOpenDBRequest->addEventListener(EventTypeNames::success, callback, false) ;
208 } 208 }
209 209
210 static PassRefPtr<IDBTransaction> transactionForDatabase(ExecutionContext* execu tionContext, IDBDatabase* idbDatabase, const String& objectStoreName, const Stri ng& mode = IDBTransaction::modeReadOnly()) 210 static PassRefPtr<IDBTransaction> transactionForDatabase(ExecutionContext* execu tionContext, IDBDatabase* idbDatabase, const String& objectStoreName, const Stri ng& mode = IDBTransaction::modeReadOnly())
211 { 211 {
212 TrackExceptionState es; 212 TrackExceptionState exceptionState;
213 RefPtr<IDBTransaction> idbTransaction = idbDatabase->transaction(executionCo ntext, objectStoreName, mode, es); 213 RefPtr<IDBTransaction> idbTransaction = idbDatabase->transaction(executionCo ntext, objectStoreName, mode, exceptionState);
214 if (es.hadException()) 214 if (exceptionState.hadException())
215 return 0; 215 return 0;
216 return idbTransaction; 216 return idbTransaction;
217 } 217 }
218 218
219 static PassRefPtr<IDBObjectStore> objectStoreForTransaction(IDBTransaction* idbT ransaction, const String& objectStoreName) 219 static PassRefPtr<IDBObjectStore> objectStoreForTransaction(IDBTransaction* idbT ransaction, const String& objectStoreName)
220 { 220 {
221 TrackExceptionState es; 221 TrackExceptionState exceptionState;
222 RefPtr<IDBObjectStore> idbObjectStore = idbTransaction->objectStore(objectSt oreName, es); 222 RefPtr<IDBObjectStore> idbObjectStore = idbTransaction->objectStore(objectSt oreName, exceptionState);
223 if (es.hadException()) 223 if (exceptionState.hadException())
224 return 0; 224 return 0;
225 return idbObjectStore; 225 return idbObjectStore;
226 } 226 }
227 227
228 static PassRefPtr<IDBIndex> indexForObjectStore(IDBObjectStore* idbObjectStore, const String& indexName) 228 static PassRefPtr<IDBIndex> indexForObjectStore(IDBObjectStore* idbObjectStore, const String& indexName)
229 { 229 {
230 TrackExceptionState es; 230 TrackExceptionState exceptionState;
231 RefPtr<IDBIndex> idbIndex = idbObjectStore->index(indexName, es); 231 RefPtr<IDBIndex> idbIndex = idbObjectStore->index(indexName, exceptionState) ;
232 if (es.hadException()) 232 if (exceptionState.hadException())
233 return 0; 233 return 0;
234 return idbIndex; 234 return idbIndex;
235 } 235 }
236 236
237 static PassRefPtr<KeyPath> keyPathFromIDBKeyPath(const IDBKeyPath& idbKeyPath) 237 static PassRefPtr<KeyPath> keyPathFromIDBKeyPath(const IDBKeyPath& idbKeyPath)
238 { 238 {
239 RefPtr<KeyPath> keyPath; 239 RefPtr<KeyPath> keyPath;
240 switch (idbKeyPath.type()) { 240 switch (idbKeyPath.type()) {
241 case IDBKeyPath::NullType: 241 case IDBKeyPath::NullType:
242 keyPath = KeyPath::create().setType(KeyPath::Type::Null); 242 keyPath = KeyPath::create().setType(KeyPath::Type::Null);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 } 408 }
409 409
410 virtual void handleEvent(ExecutionContext* context, Event* event) OVERRIDE 410 virtual void handleEvent(ExecutionContext* context, Event* event) OVERRIDE
411 { 411 {
412 if (event->type() != EventTypeNames::success) { 412 if (event->type() != EventTypeNames::success) {
413 m_requestCallback->sendFailure("Unexpected event type."); 413 m_requestCallback->sendFailure("Unexpected event type.");
414 return; 414 return;
415 } 415 }
416 416
417 IDBRequest* idbRequest = static_cast<IDBRequest*>(event->target()); 417 IDBRequest* idbRequest = static_cast<IDBRequest*>(event->target());
418 TrackExceptionState es; 418 TrackExceptionState exceptionState;
419 RefPtr<IDBAny> requestResult = idbRequest->result(es); 419 RefPtr<IDBAny> requestResult = idbRequest->result(exceptionState);
420 if (es.hadException()) { 420 if (exceptionState.hadException()) {
421 m_requestCallback->sendFailure("Could not get result in callback."); 421 m_requestCallback->sendFailure("Could not get result in callback.");
422 return; 422 return;
423 } 423 }
424 if (requestResult->type() == IDBAny::ScriptValueType) { 424 if (requestResult->type() == IDBAny::ScriptValueType) {
425 end(false); 425 end(false);
426 return; 426 return;
427 } 427 }
428 if (requestResult->type() != IDBAny::IDBCursorWithValueType) { 428 if (requestResult->type() != IDBAny::IDBCursorWithValueType) {
429 m_requestCallback->sendFailure("Unexpected result type."); 429 m_requestCallback->sendFailure("Unexpected result type.");
430 return; 430 return;
431 } 431 }
432 432
433 RefPtr<IDBCursorWithValue> idbCursor = requestResult->idbCursorWithValue (); 433 RefPtr<IDBCursorWithValue> idbCursor = requestResult->idbCursorWithValue ();
434 434
435 if (m_skipCount) { 435 if (m_skipCount) {
436 TrackExceptionState es; 436 TrackExceptionState exceptionState;
437 idbCursor->advance(m_skipCount, es); 437 idbCursor->advance(m_skipCount, exceptionState);
438 if (es.hadException()) 438 if (exceptionState.hadException())
439 m_requestCallback->sendFailure("Could not advance cursor."); 439 m_requestCallback->sendFailure("Could not advance cursor.");
440 m_skipCount = 0; 440 m_skipCount = 0;
441 return; 441 return;
442 } 442 }
443 443
444 if (m_result->length() == m_pageSize) { 444 if (m_result->length() == m_pageSize) {
445 end(true); 445 end(true);
446 return; 446 return;
447 } 447 }
448 448
449 // Continue cursor before making injected script calls, otherwise transa ction might be finished. 449 // Continue cursor before making injected script calls, otherwise transa ction might be finished.
450 idbCursor->continueFunction(0, es); 450 idbCursor->continueFunction(0, exceptionState);
451 if (es.hadException()) { 451 if (exceptionState.hadException()) {
452 m_requestCallback->sendFailure("Could not continue cursor."); 452 m_requestCallback->sendFailure("Could not continue cursor.");
453 return; 453 return;
454 } 454 }
455 455
456 RefPtr<DataEntry> dataEntry = DataEntry::create() 456 RefPtr<DataEntry> dataEntry = DataEntry::create()
457 .setKey(m_injectedScript.wrapObject(idbCursor->key(context), String( ))) 457 .setKey(m_injectedScript.wrapObject(idbCursor->key(context), String( )))
458 .setPrimaryKey(m_injectedScript.wrapObject(idbCursor->primaryKey(con text), String())) 458 .setPrimaryKey(m_injectedScript.wrapObject(idbCursor->primaryKey(con text), String()))
459 .setValue(m_injectedScript.wrapObject(idbCursor->value(context), Str ing())); 459 .setValue(m_injectedScript.wrapObject(idbCursor->value(context), Str ing()));
460 m_result->addItem(dataEntry); 460 m_result->addItem(dataEntry);
461 461
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 IDBFactory* idbFactory = assertIDBFactory(errorString, document); 616 IDBFactory* idbFactory = assertIDBFactory(errorString, document);
617 if (!idbFactory) 617 if (!idbFactory)
618 return; 618 return;
619 619
620 // FIXME: This should probably use ScriptState/ScriptScope instead of V8 API 620 // FIXME: This should probably use ScriptState/ScriptScope instead of V8 API
621 v8::HandleScope handleScope(toIsolate(frame)); 621 v8::HandleScope handleScope(toIsolate(frame));
622 v8::Handle<v8::Context> context = document->frame()->script().mainWorldConte xt(); 622 v8::Handle<v8::Context> context = document->frame()->script().mainWorldConte xt();
623 ASSERT(!context.IsEmpty()); 623 ASSERT(!context.IsEmpty());
624 v8::Context::Scope contextScope(context); 624 v8::Context::Scope contextScope(context);
625 625
626 TrackExceptionState es; 626 TrackExceptionState exceptionState;
627 RefPtr<IDBRequest> idbRequest = idbFactory->getDatabaseNames(document, es); 627 RefPtr<IDBRequest> idbRequest = idbFactory->getDatabaseNames(document, excep tionState);
628 if (es.hadException()) { 628 if (exceptionState.hadException()) {
629 requestCallback->sendFailure("Could not obtain database names."); 629 requestCallback->sendFailure("Could not obtain database names.");
630 return; 630 return;
631 } 631 }
632 idbRequest->addEventListener(EventTypeNames::success, GetDatabaseNamesCallba ck::create(requestCallback, document->securityOrigin()->toRawString()), false); 632 idbRequest->addEventListener(EventTypeNames::success, GetDatabaseNamesCallba ck::create(requestCallback, document->securityOrigin()->toRawString()), false);
633 } 633 }
634 634
635 void InspectorIndexedDBAgent::requestDatabase(ErrorString* errorString, const St ring& securityOrigin, const String& databaseName, PassRefPtr<RequestDatabaseCall back> requestCallback) 635 void InspectorIndexedDBAgent::requestDatabase(ErrorString* errorString, const St ring& securityOrigin, const String& databaseName, PassRefPtr<RequestDatabaseCall back> requestCallback)
636 { 636 {
637 Frame* frame = m_pageAgent->findFrameWithSecurityOrigin(securityOrigin); 637 Frame* frame = m_pageAgent->findFrameWithSecurityOrigin(securityOrigin);
638 Document* document = assertDocument(errorString, frame); 638 Document* document = assertDocument(errorString, frame);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 if (!idbTransaction) { 740 if (!idbTransaction) {
741 m_requestCallback->sendFailure("Could not get transaction"); 741 m_requestCallback->sendFailure("Could not get transaction");
742 return; 742 return;
743 } 743 }
744 RefPtr<IDBObjectStore> idbObjectStore = objectStoreForTransaction(idbTra nsaction.get(), m_objectStoreName); 744 RefPtr<IDBObjectStore> idbObjectStore = objectStoreForTransaction(idbTra nsaction.get(), m_objectStoreName);
745 if (!idbObjectStore) { 745 if (!idbObjectStore) {
746 m_requestCallback->sendFailure("Could not get object store"); 746 m_requestCallback->sendFailure("Could not get object store");
747 return; 747 return;
748 } 748 }
749 749
750 TrackExceptionState es; 750 TrackExceptionState exceptionState;
751 RefPtr<IDBRequest> idbRequest = idbObjectStore->clear(context(), es); 751 RefPtr<IDBRequest> idbRequest = idbObjectStore->clear(context(), excepti onState);
752 ASSERT(!es.hadException()); 752 ASSERT(!exceptionState.hadException());
753 if (es.hadException()) { 753 if (exceptionState.hadException()) {
754 ExceptionCode ec = es.code(); 754 ExceptionCode ec = exceptionState.code();
755 m_requestCallback->sendFailure(String::format("Could not clear objec t store '%s': %d", m_objectStoreName.utf8().data(), ec)); 755 m_requestCallback->sendFailure(String::format("Could not clear objec t store '%s': %d", m_objectStoreName.utf8().data(), ec));
756 return; 756 return;
757 } 757 }
758 idbTransaction->addEventListener(EventTypeNames::complete, ClearObjectSt oreListener::create(m_requestCallback), false); 758 idbTransaction->addEventListener(EventTypeNames::complete, ClearObjectSt oreListener::create(m_requestCallback), false);
759 } 759 }
760 760
761 virtual RequestCallback* requestCallback() { return m_requestCallback.get(); } 761 virtual RequestCallback* requestCallback() { return m_requestCallback.get(); }
762 private: 762 private:
763 const String m_objectStoreName; 763 const String m_objectStoreName;
764 RefPtr<ClearObjectStoreCallback> m_requestCallback; 764 RefPtr<ClearObjectStoreCallback> m_requestCallback;
(...skipping 13 matching lines...) Expand all
778 v8::HandleScope handleScope(toIsolate(frame)); 778 v8::HandleScope handleScope(toIsolate(frame));
779 v8::Handle<v8::Context> context = document->frame()->script().mainWorldConte xt(); 779 v8::Handle<v8::Context> context = document->frame()->script().mainWorldConte xt();
780 ASSERT(!context.IsEmpty()); 780 ASSERT(!context.IsEmpty());
781 v8::Context::Scope contextScope(context); 781 v8::Context::Scope contextScope(context);
782 782
783 RefPtr<ClearObjectStore> clearObjectStore = ClearObjectStore::create(documen t, objectStoreName, requestCallback); 783 RefPtr<ClearObjectStore> clearObjectStore = ClearObjectStore::create(documen t, objectStoreName, requestCallback);
784 clearObjectStore->start(idbFactory, document->securityOrigin(), databaseName ); 784 clearObjectStore->start(idbFactory, document->securityOrigin(), databaseName );
785 } 785 }
786 786
787 } // namespace WebCore 787 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorHistory.cpp ('k') | Source/core/inspector/InspectorStyleSheet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698