OLD | NEW |
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 typedef WebCore::InspectorBackendDispatcher::IndexedDBCommandHandler::ClearObjec
tStoreCallback ClearObjectStoreCallback; | 77 typedef WebCore::InspectorBackendDispatcher::IndexedDBCommandHandler::ClearObjec
tStoreCallback ClearObjectStoreCallback; |
78 | 78 |
79 namespace WebCore { | 79 namespace WebCore { |
80 | 80 |
81 namespace IndexedDBAgentState { | 81 namespace IndexedDBAgentState { |
82 static const char indexedDBAgentEnabled[] = "indexedDBAgentEnabled"; | 82 static const char indexedDBAgentEnabled[] = "indexedDBAgentEnabled"; |
83 }; | 83 }; |
84 | 84 |
85 namespace { | 85 namespace { |
86 | 86 |
87 class GetDatabaseNamesCallback : public EventListener { | 87 class GetDatabaseNamesCallback FINAL : public EventListener { |
88 WTF_MAKE_NONCOPYABLE(GetDatabaseNamesCallback); | 88 WTF_MAKE_NONCOPYABLE(GetDatabaseNamesCallback); |
89 public: | 89 public: |
90 static PassRefPtr<GetDatabaseNamesCallback> create(PassRefPtr<RequestDatabas
eNamesCallback> requestCallback, const String& securityOrigin) | 90 static PassRefPtr<GetDatabaseNamesCallback> create(PassRefPtr<RequestDatabas
eNamesCallback> requestCallback, const String& securityOrigin) |
91 { | 91 { |
92 return adoptRef(new GetDatabaseNamesCallback(requestCallback, securityOr
igin)); | 92 return adoptRef(new GetDatabaseNamesCallback(requestCallback, securityOr
igin)); |
93 } | 93 } |
94 | 94 |
95 virtual ~GetDatabaseNamesCallback() { } | 95 virtual ~GetDatabaseNamesCallback() { } |
96 | 96 |
97 virtual bool operator==(const EventListener& other) OVERRIDE | 97 virtual bool operator==(const EventListener& other) OVERRIDE |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 : m_context(context) { } | 137 : m_context(context) { } |
138 virtual ~ExecutableWithDatabase() { }; | 138 virtual ~ExecutableWithDatabase() { }; |
139 void start(IDBFactory*, SecurityOrigin*, const String& databaseName); | 139 void start(IDBFactory*, SecurityOrigin*, const String& databaseName); |
140 virtual void execute(PassRefPtr<IDBDatabase>) = 0; | 140 virtual void execute(PassRefPtr<IDBDatabase>) = 0; |
141 virtual RequestCallback* requestCallback() = 0; | 141 virtual RequestCallback* requestCallback() = 0; |
142 ExecutionContext* context() { return m_context; }; | 142 ExecutionContext* context() { return m_context; }; |
143 private: | 143 private: |
144 ExecutionContext* m_context; | 144 ExecutionContext* m_context; |
145 }; | 145 }; |
146 | 146 |
147 class OpenDatabaseCallback : public EventListener { | 147 class OpenDatabaseCallback FINAL : public EventListener { |
148 public: | 148 public: |
149 static PassRefPtr<OpenDatabaseCallback> create(ExecutableWithDatabase* execu
tableWithDatabase) | 149 static PassRefPtr<OpenDatabaseCallback> create(ExecutableWithDatabase* execu
tableWithDatabase) |
150 { | 150 { |
151 return adoptRef(new OpenDatabaseCallback(executableWithDatabase)); | 151 return adoptRef(new OpenDatabaseCallback(executableWithDatabase)); |
152 } | 152 } |
153 | 153 |
154 virtual ~OpenDatabaseCallback() { } | 154 virtual ~OpenDatabaseCallback() { } |
155 | 155 |
156 virtual bool operator==(const EventListener& other) OVERRIDE | 156 virtual bool operator==(const EventListener& other) OVERRIDE |
157 { | 157 { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 keyPath->setArray(array); | 244 keyPath->setArray(array); |
245 break; | 245 break; |
246 } | 246 } |
247 default: | 247 default: |
248 ASSERT_NOT_REACHED(); | 248 ASSERT_NOT_REACHED(); |
249 } | 249 } |
250 | 250 |
251 return keyPath.release(); | 251 return keyPath.release(); |
252 } | 252 } |
253 | 253 |
254 class DatabaseLoader : public ExecutableWithDatabase { | 254 class DatabaseLoader FINAL : public ExecutableWithDatabase { |
255 public: | 255 public: |
256 static PassRefPtr<DatabaseLoader> create(ExecutionContext* context, PassRefP
tr<RequestDatabaseCallback> requestCallback) | 256 static PassRefPtr<DatabaseLoader> create(ExecutionContext* context, PassRefP
tr<RequestDatabaseCallback> requestCallback) |
257 { | 257 { |
258 return adoptRef(new DatabaseLoader(context, requestCallback)); | 258 return adoptRef(new DatabaseLoader(context, requestCallback)); |
259 } | 259 } |
260 | 260 |
261 virtual ~DatabaseLoader() { } | 261 virtual ~DatabaseLoader() { } |
262 | 262 |
263 virtual void execute(PassRefPtr<IDBDatabase> prpDatabase) | 263 virtual void execute(PassRefPtr<IDBDatabase> prpDatabase) OVERRIDE |
264 { | 264 { |
265 RefPtr<IDBDatabase> idbDatabase = prpDatabase; | 265 RefPtr<IDBDatabase> idbDatabase = prpDatabase; |
266 if (!requestCallback()->isActive()) | 266 if (!requestCallback()->isActive()) |
267 return; | 267 return; |
268 | 268 |
269 const IDBDatabaseMetadata databaseMetadata = idbDatabase->metadata(); | 269 const IDBDatabaseMetadata databaseMetadata = idbDatabase->metadata(); |
270 | 270 |
271 RefPtr<TypeBuilder::Array<TypeBuilder::IndexedDB::ObjectStore> > objectS
tores = TypeBuilder::Array<TypeBuilder::IndexedDB::ObjectStore>::create(); | 271 RefPtr<TypeBuilder::Array<TypeBuilder::IndexedDB::ObjectStore> > objectS
tores = TypeBuilder::Array<TypeBuilder::IndexedDB::ObjectStore>::create(); |
272 | 272 |
273 for (IDBDatabaseMetadata::ObjectStoreMap::const_iterator it = databaseMe
tadata.objectStores.begin(); it != databaseMetadata.objectStores.end(); ++it) { | 273 for (IDBDatabaseMetadata::ObjectStoreMap::const_iterator it = databaseMe
tadata.objectStores.begin(); it != databaseMetadata.objectStores.end(); ++it) { |
(...skipping 21 matching lines...) Expand all Loading... |
295 } | 295 } |
296 RefPtr<DatabaseWithObjectStores> result = DatabaseWithObjectStores::crea
te() | 296 RefPtr<DatabaseWithObjectStores> result = DatabaseWithObjectStores::crea
te() |
297 .setName(databaseMetadata.name) | 297 .setName(databaseMetadata.name) |
298 .setIntVersion(databaseMetadata.intVersion) | 298 .setIntVersion(databaseMetadata.intVersion) |
299 .setVersion(databaseMetadata.version) | 299 .setVersion(databaseMetadata.version) |
300 .setObjectStores(objectStores); | 300 .setObjectStores(objectStores); |
301 | 301 |
302 m_requestCallback->sendSuccess(result); | 302 m_requestCallback->sendSuccess(result); |
303 } | 303 } |
304 | 304 |
305 virtual RequestCallback* requestCallback() { return m_requestCallback.get();
} | 305 virtual RequestCallback* requestCallback() OVERRIDE { return m_requestCallba
ck.get(); } |
306 private: | 306 private: |
307 DatabaseLoader(ExecutionContext* context, PassRefPtr<RequestDatabaseCallback
> requestCallback) | 307 DatabaseLoader(ExecutionContext* context, PassRefPtr<RequestDatabaseCallback
> requestCallback) |
308 : ExecutableWithDatabase(context) | 308 : ExecutableWithDatabase(context) |
309 , m_requestCallback(requestCallback) { } | 309 , m_requestCallback(requestCallback) { } |
310 RefPtr<RequestDatabaseCallback> m_requestCallback; | 310 RefPtr<RequestDatabaseCallback> m_requestCallback; |
311 }; | 311 }; |
312 | 312 |
313 static PassRefPtr<IDBKey> idbKeyFromInspectorObject(JSONObject* key) | 313 static PassRefPtr<IDBKey> idbKeyFromInspectorObject(JSONObject* key) |
314 { | 314 { |
315 RefPtr<IDBKey> idbKey; | 315 RefPtr<IDBKey> idbKey; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 if (!keyRange->getBoolean("upperOpen", &upperOpen)) | 376 if (!keyRange->getBoolean("upperOpen", &upperOpen)) |
377 return 0; | 377 return 0; |
378 IDBKeyRange::UpperBoundType upperBoundType = upperOpen ? IDBKeyRange::UpperB
oundOpen : IDBKeyRange::UpperBoundClosed; | 378 IDBKeyRange::UpperBoundType upperBoundType = upperOpen ? IDBKeyRange::UpperB
oundOpen : IDBKeyRange::UpperBoundClosed; |
379 | 379 |
380 RefPtr<IDBKeyRange> idbKeyRange = IDBKeyRange::create(idbLower, idbUpper, lo
werBoundType, upperBoundType); | 380 RefPtr<IDBKeyRange> idbKeyRange = IDBKeyRange::create(idbLower, idbUpper, lo
werBoundType, upperBoundType); |
381 return idbKeyRange.release(); | 381 return idbKeyRange.release(); |
382 } | 382 } |
383 | 383 |
384 class DataLoader; | 384 class DataLoader; |
385 | 385 |
386 class OpenCursorCallback : public EventListener { | 386 class OpenCursorCallback FINAL : public EventListener { |
387 public: | 387 public: |
388 static PassRefPtr<OpenCursorCallback> create(InjectedScript injectedScript,
PassRefPtr<RequestDataCallback> requestCallback, int skipCount, unsigned pageSiz
e) | 388 static PassRefPtr<OpenCursorCallback> create(InjectedScript injectedScript,
PassRefPtr<RequestDataCallback> requestCallback, int skipCount, unsigned pageSiz
e) |
389 { | 389 { |
390 return adoptRef(new OpenCursorCallback(injectedScript, requestCallback,
skipCount, pageSize)); | 390 return adoptRef(new OpenCursorCallback(injectedScript, requestCallback,
skipCount, pageSize)); |
391 } | 391 } |
392 | 392 |
393 virtual ~OpenCursorCallback() { } | 393 virtual ~OpenCursorCallback() { } |
394 | 394 |
395 virtual bool operator==(const EventListener& other) OVERRIDE | 395 virtual bool operator==(const EventListener& other) OVERRIDE |
396 { | 396 { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 { | 464 { |
465 m_result = Array<DataEntry>::create(); | 465 m_result = Array<DataEntry>::create(); |
466 } | 466 } |
467 InjectedScript m_injectedScript; | 467 InjectedScript m_injectedScript; |
468 RefPtr<RequestDataCallback> m_requestCallback; | 468 RefPtr<RequestDataCallback> m_requestCallback; |
469 int m_skipCount; | 469 int m_skipCount; |
470 unsigned m_pageSize; | 470 unsigned m_pageSize; |
471 RefPtr<Array<DataEntry> > m_result; | 471 RefPtr<Array<DataEntry> > m_result; |
472 }; | 472 }; |
473 | 473 |
474 class DataLoader : public ExecutableWithDatabase { | 474 class DataLoader FINAL : public ExecutableWithDatabase { |
475 public: | 475 public: |
476 static PassRefPtr<DataLoader> create(ExecutionContext* context, PassRefPtr<R
equestDataCallback> requestCallback, const InjectedScript& injectedScript, const
String& objectStoreName, const String& indexName, PassRefPtr<IDBKeyRange> idbKe
yRange, int skipCount, unsigned pageSize) | 476 static PassRefPtr<DataLoader> create(ExecutionContext* context, PassRefPtr<R
equestDataCallback> requestCallback, const InjectedScript& injectedScript, const
String& objectStoreName, const String& indexName, PassRefPtr<IDBKeyRange> idbKe
yRange, int skipCount, unsigned pageSize) |
477 { | 477 { |
478 return adoptRef(new DataLoader(context, requestCallback, injectedScript,
objectStoreName, indexName, idbKeyRange, skipCount, pageSize)); | 478 return adoptRef(new DataLoader(context, requestCallback, injectedScript,
objectStoreName, indexName, idbKeyRange, skipCount, pageSize)); |
479 } | 479 } |
480 | 480 |
481 virtual ~DataLoader() { } | 481 virtual ~DataLoader() { } |
482 | 482 |
483 virtual void execute(PassRefPtr<IDBDatabase> prpDatabase) | 483 virtual void execute(PassRefPtr<IDBDatabase> prpDatabase) OVERRIDE |
484 { | 484 { |
485 RefPtr<IDBDatabase> idbDatabase = prpDatabase; | 485 RefPtr<IDBDatabase> idbDatabase = prpDatabase; |
486 if (!requestCallback()->isActive()) | 486 if (!requestCallback()->isActive()) |
487 return; | 487 return; |
488 RefPtr<IDBTransaction> idbTransaction = transactionForDatabase(context()
, idbDatabase.get(), m_objectStoreName); | 488 RefPtr<IDBTransaction> idbTransaction = transactionForDatabase(context()
, idbDatabase.get(), m_objectStoreName); |
489 if (!idbTransaction) { | 489 if (!idbTransaction) { |
490 m_requestCallback->sendFailure("Could not get transaction"); | 490 m_requestCallback->sendFailure("Could not get transaction"); |
491 return; | 491 return; |
492 } | 492 } |
493 RefPtr<IDBObjectStore> idbObjectStore = objectStoreForTransaction(idbTra
nsaction.get(), m_objectStoreName); | 493 RefPtr<IDBObjectStore> idbObjectStore = objectStoreForTransaction(idbTra
nsaction.get(), m_objectStoreName); |
(...skipping 12 matching lines...) Expand all Loading... |
506 return; | 506 return; |
507 } | 507 } |
508 | 508 |
509 idbRequest = idbIndex->openCursor(context(), PassRefPtr<IDBKeyRange>
(m_idbKeyRange), IndexedDB::CursorNext); | 509 idbRequest = idbIndex->openCursor(context(), PassRefPtr<IDBKeyRange>
(m_idbKeyRange), IndexedDB::CursorNext); |
510 } else { | 510 } else { |
511 idbRequest = idbObjectStore->openCursor(context(), PassRefPtr<IDBKey
Range>(m_idbKeyRange), IndexedDB::CursorNext); | 511 idbRequest = idbObjectStore->openCursor(context(), PassRefPtr<IDBKey
Range>(m_idbKeyRange), IndexedDB::CursorNext); |
512 } | 512 } |
513 idbRequest->addEventListener(EventTypeNames::success, openCursorCallback
, false); | 513 idbRequest->addEventListener(EventTypeNames::success, openCursorCallback
, false); |
514 } | 514 } |
515 | 515 |
516 virtual RequestCallback* requestCallback() { return m_requestCallback.get();
} | 516 virtual RequestCallback* requestCallback() OVERRIDE { return m_requestCallba
ck.get(); } |
517 DataLoader(ExecutionContext* executionContext, PassRefPtr<RequestDataCallbac
k> requestCallback, const InjectedScript& injectedScript, const String& objectSt
oreName, const String& indexName, PassRefPtr<IDBKeyRange> idbKeyRange, int skipC
ount, unsigned pageSize) | 517 DataLoader(ExecutionContext* executionContext, PassRefPtr<RequestDataCallbac
k> requestCallback, const InjectedScript& injectedScript, const String& objectSt
oreName, const String& indexName, PassRefPtr<IDBKeyRange> idbKeyRange, int skipC
ount, unsigned pageSize) |
518 : ExecutableWithDatabase(executionContext) | 518 : ExecutableWithDatabase(executionContext) |
519 , m_requestCallback(requestCallback) | 519 , m_requestCallback(requestCallback) |
520 , m_injectedScript(injectedScript) | 520 , m_injectedScript(injectedScript) |
521 , m_objectStoreName(objectStoreName) | 521 , m_objectStoreName(objectStoreName) |
522 , m_indexName(indexName) | 522 , m_indexName(indexName) |
523 , m_idbKeyRange(idbKeyRange) | 523 , m_idbKeyRange(idbKeyRange) |
524 , m_skipCount(skipCount) | 524 , m_skipCount(skipCount) |
525 , m_pageSize(pageSize) { } | 525 , m_pageSize(pageSize) { } |
526 RefPtr<RequestDataCallback> m_requestCallback; | 526 RefPtr<RequestDataCallback> m_requestCallback; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 // FIXME: This should probably use ScriptState/ScriptScope instead of V8 API | 659 // FIXME: This should probably use ScriptState/ScriptScope instead of V8 API |
660 v8::HandleScope handleScope(toIsolate(frame)); | 660 v8::HandleScope handleScope(toIsolate(frame)); |
661 v8::Handle<v8::Context> context = document->frame()->script().mainWorldConte
xt(); | 661 v8::Handle<v8::Context> context = document->frame()->script().mainWorldConte
xt(); |
662 ASSERT(!context.IsEmpty()); | 662 ASSERT(!context.IsEmpty()); |
663 v8::Context::Scope contextScope(context); | 663 v8::Context::Scope contextScope(context); |
664 | 664 |
665 RefPtr<DataLoader> dataLoader = DataLoader::create(document, requestCallback
, injectedScript, objectStoreName, indexName, idbKeyRange, skipCount, pageSize); | 665 RefPtr<DataLoader> dataLoader = DataLoader::create(document, requestCallback
, injectedScript, objectStoreName, indexName, idbKeyRange, skipCount, pageSize); |
666 dataLoader->start(idbFactory, document->securityOrigin(), databaseName); | 666 dataLoader->start(idbFactory, document->securityOrigin(), databaseName); |
667 } | 667 } |
668 | 668 |
669 class ClearObjectStoreListener : public EventListener { | 669 class ClearObjectStoreListener FINAL : public EventListener { |
670 WTF_MAKE_NONCOPYABLE(ClearObjectStoreListener); | 670 WTF_MAKE_NONCOPYABLE(ClearObjectStoreListener); |
671 public: | 671 public: |
672 static PassRefPtr<ClearObjectStoreListener> create(PassRefPtr<ClearObjectSto
reCallback> requestCallback) | 672 static PassRefPtr<ClearObjectStoreListener> create(PassRefPtr<ClearObjectSto
reCallback> requestCallback) |
673 { | 673 { |
674 return adoptRef(new ClearObjectStoreListener(requestCallback)); | 674 return adoptRef(new ClearObjectStoreListener(requestCallback)); |
675 } | 675 } |
676 | 676 |
677 virtual ~ClearObjectStoreListener() { } | 677 virtual ~ClearObjectStoreListener() { } |
678 | 678 |
679 virtual bool operator==(const EventListener& other) OVERRIDE | 679 virtual bool operator==(const EventListener& other) OVERRIDE |
(...skipping 16 matching lines...) Expand all Loading... |
696 ClearObjectStoreListener(PassRefPtr<ClearObjectStoreCallback> requestCallbac
k) | 696 ClearObjectStoreListener(PassRefPtr<ClearObjectStoreCallback> requestCallbac
k) |
697 : EventListener(EventListener::CPPEventListenerType) | 697 : EventListener(EventListener::CPPEventListenerType) |
698 , m_requestCallback(requestCallback) | 698 , m_requestCallback(requestCallback) |
699 { | 699 { |
700 } | 700 } |
701 | 701 |
702 RefPtr<ClearObjectStoreCallback> m_requestCallback; | 702 RefPtr<ClearObjectStoreCallback> m_requestCallback; |
703 }; | 703 }; |
704 | 704 |
705 | 705 |
706 class ClearObjectStore : public ExecutableWithDatabase { | 706 class ClearObjectStore FINAL : public ExecutableWithDatabase { |
707 public: | 707 public: |
708 static PassRefPtr<ClearObjectStore> create(ExecutionContext* context, const
String& objectStoreName, PassRefPtr<ClearObjectStoreCallback> requestCallback) | 708 static PassRefPtr<ClearObjectStore> create(ExecutionContext* context, const
String& objectStoreName, PassRefPtr<ClearObjectStoreCallback> requestCallback) |
709 { | 709 { |
710 return adoptRef(new ClearObjectStore(context, objectStoreName, requestCa
llback)); | 710 return adoptRef(new ClearObjectStore(context, objectStoreName, requestCa
llback)); |
711 } | 711 } |
712 | 712 |
713 ClearObjectStore(ExecutionContext* context, const String& objectStoreName, P
assRefPtr<ClearObjectStoreCallback> requestCallback) | 713 ClearObjectStore(ExecutionContext* context, const String& objectStoreName, P
assRefPtr<ClearObjectStoreCallback> requestCallback) |
714 : ExecutableWithDatabase(context) | 714 : ExecutableWithDatabase(context) |
715 , m_objectStoreName(objectStoreName) | 715 , m_objectStoreName(objectStoreName) |
716 , m_requestCallback(requestCallback) | 716 , m_requestCallback(requestCallback) |
717 { | 717 { |
718 } | 718 } |
719 | 719 |
720 virtual void execute(PassRefPtr<IDBDatabase> prpDatabase) | 720 virtual void execute(PassRefPtr<IDBDatabase> prpDatabase) OVERRIDE |
721 { | 721 { |
722 RefPtr<IDBDatabase> idbDatabase = prpDatabase; | 722 RefPtr<IDBDatabase> idbDatabase = prpDatabase; |
723 if (!requestCallback()->isActive()) | 723 if (!requestCallback()->isActive()) |
724 return; | 724 return; |
725 RefPtr<IDBTransaction> idbTransaction = transactionForDatabase(context()
, idbDatabase.get(), m_objectStoreName, IDBTransaction::modeReadWrite()); | 725 RefPtr<IDBTransaction> idbTransaction = transactionForDatabase(context()
, idbDatabase.get(), m_objectStoreName, IDBTransaction::modeReadWrite()); |
726 if (!idbTransaction) { | 726 if (!idbTransaction) { |
727 m_requestCallback->sendFailure("Could not get transaction"); | 727 m_requestCallback->sendFailure("Could not get transaction"); |
728 return; | 728 return; |
729 } | 729 } |
730 RefPtr<IDBObjectStore> idbObjectStore = objectStoreForTransaction(idbTra
nsaction.get(), m_objectStoreName); | 730 RefPtr<IDBObjectStore> idbObjectStore = objectStoreForTransaction(idbTra
nsaction.get(), m_objectStoreName); |
731 if (!idbObjectStore) { | 731 if (!idbObjectStore) { |
732 m_requestCallback->sendFailure("Could not get object store"); | 732 m_requestCallback->sendFailure("Could not get object store"); |
733 return; | 733 return; |
734 } | 734 } |
735 | 735 |
736 TrackExceptionState exceptionState; | 736 TrackExceptionState exceptionState; |
737 RefPtr<IDBRequest> idbRequest = idbObjectStore->clear(context(), excepti
onState); | 737 RefPtr<IDBRequest> idbRequest = idbObjectStore->clear(context(), excepti
onState); |
738 ASSERT(!exceptionState.hadException()); | 738 ASSERT(!exceptionState.hadException()); |
739 if (exceptionState.hadException()) { | 739 if (exceptionState.hadException()) { |
740 ExceptionCode ec = exceptionState.code(); | 740 ExceptionCode ec = exceptionState.code(); |
741 m_requestCallback->sendFailure(String::format("Could not clear objec
t store '%s': %d", m_objectStoreName.utf8().data(), ec)); | 741 m_requestCallback->sendFailure(String::format("Could not clear objec
t store '%s': %d", m_objectStoreName.utf8().data(), ec)); |
742 return; | 742 return; |
743 } | 743 } |
744 idbTransaction->addEventListener(EventTypeNames::complete, ClearObjectSt
oreListener::create(m_requestCallback), false); | 744 idbTransaction->addEventListener(EventTypeNames::complete, ClearObjectSt
oreListener::create(m_requestCallback), false); |
745 } | 745 } |
746 | 746 |
747 virtual RequestCallback* requestCallback() { return m_requestCallback.get();
} | 747 virtual RequestCallback* requestCallback() OVERRIDE { return m_requestCallba
ck.get(); } |
748 private: | 748 private: |
749 const String m_objectStoreName; | 749 const String m_objectStoreName; |
750 RefPtr<ClearObjectStoreCallback> m_requestCallback; | 750 RefPtr<ClearObjectStoreCallback> m_requestCallback; |
751 }; | 751 }; |
752 | 752 |
753 void InspectorIndexedDBAgent::clearObjectStore(ErrorString* errorString, const S
tring& securityOrigin, const String& databaseName, const String& objectStoreName
, PassRefPtr<ClearObjectStoreCallback> requestCallback) | 753 void InspectorIndexedDBAgent::clearObjectStore(ErrorString* errorString, const S
tring& securityOrigin, const String& databaseName, const String& objectStoreName
, PassRefPtr<ClearObjectStoreCallback> requestCallback) |
754 { | 754 { |
755 Frame* frame = m_pageAgent->findFrameWithSecurityOrigin(securityOrigin); | 755 Frame* frame = m_pageAgent->findFrameWithSecurityOrigin(securityOrigin); |
756 Document* document = assertDocument(errorString, frame); | 756 Document* document = assertDocument(errorString, frame); |
757 if (!document) | 757 if (!document) |
758 return; | 758 return; |
759 IDBFactory* idbFactory = assertIDBFactory(errorString, document); | 759 IDBFactory* idbFactory = assertIDBFactory(errorString, document); |
760 if (!idbFactory) | 760 if (!idbFactory) |
761 return; | 761 return; |
762 | 762 |
763 // FIXME: This should probably use ScriptState/ScriptScope instead of V8 API | 763 // FIXME: This should probably use ScriptState/ScriptScope instead of V8 API |
764 v8::HandleScope handleScope(toIsolate(frame)); | 764 v8::HandleScope handleScope(toIsolate(frame)); |
765 v8::Handle<v8::Context> context = document->frame()->script().mainWorldConte
xt(); | 765 v8::Handle<v8::Context> context = document->frame()->script().mainWorldConte
xt(); |
766 ASSERT(!context.IsEmpty()); | 766 ASSERT(!context.IsEmpty()); |
767 v8::Context::Scope contextScope(context); | 767 v8::Context::Scope contextScope(context); |
768 | 768 |
769 RefPtr<ClearObjectStore> clearObjectStore = ClearObjectStore::create(documen
t, objectStoreName, requestCallback); | 769 RefPtr<ClearObjectStore> clearObjectStore = ClearObjectStore::create(documen
t, objectStoreName, requestCallback); |
770 clearObjectStore->start(idbFactory, document->securityOrigin(), databaseName
); | 770 clearObjectStore->start(idbFactory, document->securityOrigin(), databaseName
); |
771 } | 771 } |
772 | 772 |
773 } // namespace WebCore | 773 } // namespace WebCore |
OLD | NEW |