| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 IDBAny* requestResult = idbRequest->resultAsAny(); | 111 IDBAny* requestResult = idbRequest->resultAsAny(); |
| 112 if (requestResult->getType() != IDBAny::DOMStringListType) { | 112 if (requestResult->getType() != IDBAny::DOMStringListType) { |
| 113 m_requestCallback->sendFailure("Unexpected result type."); | 113 m_requestCallback->sendFailure("Unexpected result type."); |
| 114 return; | 114 return; |
| 115 } | 115 } |
| 116 | 116 |
| 117 DOMStringList* databaseNamesList = requestResult->domStringList(); | 117 DOMStringList* databaseNamesList = requestResult->domStringList(); |
| 118 OwnPtr<protocol::Array<String>> databaseNames = protocol::Array<String>:
:create(); | 118 OwnPtr<protocol::Array<String>> databaseNames = protocol::Array<String>:
:create(); |
| 119 for (size_t i = 0; i < databaseNamesList->length(); ++i) | 119 for (size_t i = 0; i < databaseNamesList->length(); ++i) |
| 120 databaseNames->addItem(databaseNamesList->anonymousIndexedGetter(i))
; | 120 databaseNames->addItem(databaseNamesList->anonymousIndexedGetter(i))
; |
| 121 m_requestCallback->sendSuccess(databaseNames.release()); | 121 m_requestCallback->sendSuccess(std::move(databaseNames)); |
| 122 } | 122 } |
| 123 | 123 |
| 124 DEFINE_INLINE_VIRTUAL_TRACE() | 124 DEFINE_INLINE_VIRTUAL_TRACE() |
| 125 { | 125 { |
| 126 EventListener::trace(visitor); | 126 EventListener::trace(visitor); |
| 127 } | 127 } |
| 128 | 128 |
| 129 private: | 129 private: |
| 130 GetDatabaseNamesCallback(PassOwnPtr<RequestDatabaseNamesCallback> requestCal
lback, const String& securityOrigin) | 130 GetDatabaseNamesCallback(PassOwnPtr<RequestDatabaseNamesCallback> requestCal
lback, const String& securityOrigin) |
| 131 : EventListener(EventListener::CPPEventListenerType) | 131 : EventListener(EventListener::CPPEventListenerType) |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 break; | 279 break; |
| 280 case IDBKeyPath::StringType: | 280 case IDBKeyPath::StringType: |
| 281 keyPath = KeyPath::create().setType(KeyPath::TypeEnum::String).setString
(idbKeyPath.string()).build(); | 281 keyPath = KeyPath::create().setType(KeyPath::TypeEnum::String).setString
(idbKeyPath.string()).build(); |
| 282 break; | 282 break; |
| 283 case IDBKeyPath::ArrayType: { | 283 case IDBKeyPath::ArrayType: { |
| 284 keyPath = KeyPath::create().setType(KeyPath::TypeEnum::Array).build(); | 284 keyPath = KeyPath::create().setType(KeyPath::TypeEnum::Array).build(); |
| 285 OwnPtr<protocol::Array<String>> array = protocol::Array<String>::create(
); | 285 OwnPtr<protocol::Array<String>> array = protocol::Array<String>::create(
); |
| 286 const Vector<String>& stringArray = idbKeyPath.array(); | 286 const Vector<String>& stringArray = idbKeyPath.array(); |
| 287 for (size_t i = 0; i < stringArray.size(); ++i) | 287 for (size_t i = 0; i < stringArray.size(); ++i) |
| 288 array->addItem(stringArray[i]); | 288 array->addItem(stringArray[i]); |
| 289 keyPath->setArray(array.release()); | 289 keyPath->setArray(std::move(array)); |
| 290 break; | 290 break; |
| 291 } | 291 } |
| 292 default: | 292 default: |
| 293 ASSERT_NOT_REACHED(); | 293 ASSERT_NOT_REACHED(); |
| 294 } | 294 } |
| 295 | 295 |
| 296 return keyPath.release(); | 296 return keyPath; |
| 297 } | 297 } |
| 298 | 298 |
| 299 class DatabaseLoader final : public ExecutableWithDatabase { | 299 class DatabaseLoader final : public ExecutableWithDatabase { |
| 300 public: | 300 public: |
| 301 static PassRefPtr<DatabaseLoader> create(ScriptState* scriptState, PassOwnPt
r<RequestDatabaseCallback> requestCallback) | 301 static PassRefPtr<DatabaseLoader> create(ScriptState* scriptState, PassOwnPt
r<RequestDatabaseCallback> requestCallback) |
| 302 { | 302 { |
| 303 return adoptRef(new DatabaseLoader(scriptState, std::move(requestCallbac
k))); | 303 return adoptRef(new DatabaseLoader(scriptState, std::move(requestCallbac
k))); |
| 304 } | 304 } |
| 305 | 305 |
| 306 ~DatabaseLoader() override { } | 306 ~DatabaseLoader() override { } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 317 OwnPtr<protocol::Array<protocol::IndexedDB::ObjectStoreIndex>> index
es = protocol::Array<protocol::IndexedDB::ObjectStoreIndex>::create(); | 317 OwnPtr<protocol::Array<protocol::IndexedDB::ObjectStoreIndex>> index
es = protocol::Array<protocol::IndexedDB::ObjectStoreIndex>::create(); |
| 318 | 318 |
| 319 for (const auto& metadataMapEntry : objectStoreMetadata.indexes) { | 319 for (const auto& metadataMapEntry : objectStoreMetadata.indexes) { |
| 320 const IDBIndexMetadata& indexMetadata = metadataMapEntry.value; | 320 const IDBIndexMetadata& indexMetadata = metadataMapEntry.value; |
| 321 | 321 |
| 322 OwnPtr<ObjectStoreIndex> objectStoreIndex = ObjectStoreIndex::cr
eate() | 322 OwnPtr<ObjectStoreIndex> objectStoreIndex = ObjectStoreIndex::cr
eate() |
| 323 .setName(indexMetadata.name) | 323 .setName(indexMetadata.name) |
| 324 .setKeyPath(keyPathFromIDBKeyPath(indexMetadata.keyPath)) | 324 .setKeyPath(keyPathFromIDBKeyPath(indexMetadata.keyPath)) |
| 325 .setUnique(indexMetadata.unique) | 325 .setUnique(indexMetadata.unique) |
| 326 .setMultiEntry(indexMetadata.multiEntry).build(); | 326 .setMultiEntry(indexMetadata.multiEntry).build(); |
| 327 indexes->addItem(objectStoreIndex.release()); | 327 indexes->addItem(std::move(objectStoreIndex)); |
| 328 } | 328 } |
| 329 | 329 |
| 330 OwnPtr<ObjectStore> objectStore = ObjectStore::create() | 330 OwnPtr<ObjectStore> objectStore = ObjectStore::create() |
| 331 .setName(objectStoreMetadata.name) | 331 .setName(objectStoreMetadata.name) |
| 332 .setKeyPath(keyPathFromIDBKeyPath(objectStoreMetadata.keyPath)) | 332 .setKeyPath(keyPathFromIDBKeyPath(objectStoreMetadata.keyPath)) |
| 333 .setAutoIncrement(objectStoreMetadata.autoIncrement) | 333 .setAutoIncrement(objectStoreMetadata.autoIncrement) |
| 334 .setIndexes(indexes.release()).build(); | 334 .setIndexes(std::move(indexes)).build(); |
| 335 objectStores->addItem(objectStore.release()); | 335 objectStores->addItem(std::move(objectStore)); |
| 336 } | 336 } |
| 337 OwnPtr<DatabaseWithObjectStores> result = DatabaseWithObjectStores::crea
te() | 337 OwnPtr<DatabaseWithObjectStores> result = DatabaseWithObjectStores::crea
te() |
| 338 .setName(databaseMetadata.name) | 338 .setName(databaseMetadata.name) |
| 339 .setVersion(databaseMetadata.version) | 339 .setVersion(databaseMetadata.version) |
| 340 .setObjectStores(objectStores.release()).build(); | 340 .setObjectStores(std::move(objectStores)).build(); |
| 341 | 341 |
| 342 m_requestCallback->sendSuccess(result.release()); | 342 m_requestCallback->sendSuccess(std::move(result)); |
| 343 } | 343 } |
| 344 | 344 |
| 345 RequestCallback* getRequestCallback() override { return m_requestCallback.ge
t(); } | 345 RequestCallback* getRequestCallback() override { return m_requestCallback.ge
t(); } |
| 346 private: | 346 private: |
| 347 DatabaseLoader(ScriptState* scriptState, PassOwnPtr<RequestDatabaseCallback>
requestCallback) | 347 DatabaseLoader(ScriptState* scriptState, PassOwnPtr<RequestDatabaseCallback>
requestCallback) |
| 348 : ExecutableWithDatabase(scriptState) | 348 : ExecutableWithDatabase(scriptState) |
| 349 , m_requestCallback(std::move(requestCallback)) { } | 349 , m_requestCallback(std::move(requestCallback)) { } |
| 350 OwnPtr<RequestDatabaseCallback> m_requestCallback; | 350 OwnPtr<RequestDatabaseCallback> m_requestCallback; |
| 351 }; | 351 }; |
| 352 | 352 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 OwnPtr<protocol::Value> keyJsonValue = toProtocolValue(scriptState->cont
ext(), idbCursor->key(scriptState).v8Value()); | 472 OwnPtr<protocol::Value> keyJsonValue = toProtocolValue(scriptState->cont
ext(), idbCursor->key(scriptState).v8Value()); |
| 473 OwnPtr<protocol::Value> primaryKeyJsonValue = toProtocolValue(scriptStat
e->context(), idbCursor->primaryKey(scriptState).v8Value()); | 473 OwnPtr<protocol::Value> primaryKeyJsonValue = toProtocolValue(scriptStat
e->context(), idbCursor->primaryKey(scriptState).v8Value()); |
| 474 OwnPtr<protocol::Value> valueJsonValue = toProtocolValue(scriptState->co
ntext(), idbCursor->value(scriptState).v8Value()); | 474 OwnPtr<protocol::Value> valueJsonValue = toProtocolValue(scriptState->co
ntext(), idbCursor->value(scriptState).v8Value()); |
| 475 String16 key = keyJsonValue ? keyJsonValue->toJSONString() : errorMessag
e; | 475 String16 key = keyJsonValue ? keyJsonValue->toJSONString() : errorMessag
e; |
| 476 String16 value = valueJsonValue ? valueJsonValue->toJSONString() : error
Message; | 476 String16 value = valueJsonValue ? valueJsonValue->toJSONString() : error
Message; |
| 477 String primaryKey = primaryKeyJsonValue ? primaryKeyJsonValue->toJSONStr
ing() : errorMessage; | 477 String primaryKey = primaryKeyJsonValue ? primaryKeyJsonValue->toJSONStr
ing() : errorMessage; |
| 478 OwnPtr<DataEntry> dataEntry = DataEntry::create() | 478 OwnPtr<DataEntry> dataEntry = DataEntry::create() |
| 479 .setKey(key) | 479 .setKey(key) |
| 480 .setPrimaryKey(primaryKey) | 480 .setPrimaryKey(primaryKey) |
| 481 .setValue(value).build(); | 481 .setValue(value).build(); |
| 482 m_result->addItem(dataEntry.release()); | 482 m_result->addItem(std::move(dataEntry)); |
| 483 } | 483 } |
| 484 | 484 |
| 485 void end(bool hasMore) | 485 void end(bool hasMore) |
| 486 { | 486 { |
| 487 m_requestCallback->sendSuccess(m_result.release(), hasMore); | 487 m_requestCallback->sendSuccess(std::move(m_result), hasMore); |
| 488 } | 488 } |
| 489 | 489 |
| 490 DEFINE_INLINE_VIRTUAL_TRACE() | 490 DEFINE_INLINE_VIRTUAL_TRACE() |
| 491 { | 491 { |
| 492 EventListener::trace(visitor); | 492 EventListener::trace(visitor); |
| 493 } | 493 } |
| 494 | 494 |
| 495 private: | 495 private: |
| 496 OpenCursorCallback(ScriptState* scriptState, PassOwnPtr<RequestDataCallback>
requestCallback, int skipCount, unsigned pageSize) | 496 OpenCursorCallback(ScriptState* scriptState, PassOwnPtr<RequestDataCallback>
requestCallback, int skipCount, unsigned pageSize) |
| 497 : EventListener(EventListener::CPPEventListenerType) | 497 : EventListener(EventListener::CPPEventListenerType) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 IDBIndex* idbIndex = indexForObjectStore(idbObjectStore, m_indexName
); | 537 IDBIndex* idbIndex = indexForObjectStore(idbObjectStore, m_indexName
); |
| 538 if (!idbIndex) { | 538 if (!idbIndex) { |
| 539 m_requestCallback->sendFailure("Could not get index"); | 539 m_requestCallback->sendFailure("Could not get index"); |
| 540 return; | 540 return; |
| 541 } | 541 } |
| 542 | 542 |
| 543 idbRequest = idbIndex->openCursor(getScriptState(), m_idbKeyRange.ge
t(), WebIDBCursorDirectionNext); | 543 idbRequest = idbIndex->openCursor(getScriptState(), m_idbKeyRange.ge
t(), WebIDBCursorDirectionNext); |
| 544 } else { | 544 } else { |
| 545 idbRequest = idbObjectStore->openCursor(getScriptState(), m_idbKeyRa
nge.get(), WebIDBCursorDirectionNext); | 545 idbRequest = idbObjectStore->openCursor(getScriptState(), m_idbKeyRa
nge.get(), WebIDBCursorDirectionNext); |
| 546 } | 546 } |
| 547 OpenCursorCallback* openCursorCallback = OpenCursorCallback::create(getS
criptState(), m_requestCallback.release(), m_skipCount, m_pageSize); | 547 OpenCursorCallback* openCursorCallback = OpenCursorCallback::create(getS
criptState(), std::move(m_requestCallback), m_skipCount, m_pageSize); |
| 548 idbRequest->addEventListener(EventTypeNames::success, openCursorCallback
, false); | 548 idbRequest->addEventListener(EventTypeNames::success, openCursorCallback
, false); |
| 549 } | 549 } |
| 550 | 550 |
| 551 RequestCallback* getRequestCallback() override { return m_requestCallback.ge
t(); } | 551 RequestCallback* getRequestCallback() override { return m_requestCallback.ge
t(); } |
| 552 DataLoader(ScriptState* scriptState, PassOwnPtr<RequestDataCallback> request
Callback, const String& objectStoreName, const String& indexName, IDBKeyRange* i
dbKeyRange, int skipCount, unsigned pageSize) | 552 DataLoader(ScriptState* scriptState, PassOwnPtr<RequestDataCallback> request
Callback, const String& objectStoreName, const String& indexName, IDBKeyRange* i
dbKeyRange, int skipCount, unsigned pageSize) |
| 553 : ExecutableWithDatabase(scriptState) | 553 : ExecutableWithDatabase(scriptState) |
| 554 , m_requestCallback(std::move(requestCallback)) | 554 , m_requestCallback(std::move(requestCallback)) |
| 555 , m_objectStoreName(objectStoreName) | 555 , m_objectStoreName(objectStoreName) |
| 556 , m_indexName(indexName) | 556 , m_indexName(indexName) |
| 557 , m_idbKeyRange(idbKeyRange) | 557 , m_idbKeyRange(idbKeyRange) |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 } | 771 } |
| 772 | 772 |
| 773 TrackExceptionState exceptionState; | 773 TrackExceptionState exceptionState; |
| 774 idbObjectStore->clear(getScriptState(), exceptionState); | 774 idbObjectStore->clear(getScriptState(), exceptionState); |
| 775 ASSERT(!exceptionState.hadException()); | 775 ASSERT(!exceptionState.hadException()); |
| 776 if (exceptionState.hadException()) { | 776 if (exceptionState.hadException()) { |
| 777 ExceptionCode ec = exceptionState.code(); | 777 ExceptionCode ec = exceptionState.code(); |
| 778 m_requestCallback->sendFailure(String::format("Could not clear objec
t store '%s': %d", m_objectStoreName.utf8().data(), ec)); | 778 m_requestCallback->sendFailure(String::format("Could not clear objec
t store '%s': %d", m_objectStoreName.utf8().data(), ec)); |
| 779 return; | 779 return; |
| 780 } | 780 } |
| 781 idbTransaction->addEventListener(EventTypeNames::complete, ClearObjectSt
oreListener::create(m_requestCallback.release()), false); | 781 idbTransaction->addEventListener(EventTypeNames::complete, ClearObjectSt
oreListener::create(std::move(m_requestCallback)), false); |
| 782 } | 782 } |
| 783 | 783 |
| 784 RequestCallback* getRequestCallback() override { return m_requestCallback.ge
t(); } | 784 RequestCallback* getRequestCallback() override { return m_requestCallback.ge
t(); } |
| 785 private: | 785 private: |
| 786 const String m_objectStoreName; | 786 const String m_objectStoreName; |
| 787 OwnPtr<ClearObjectStoreCallback> m_requestCallback; | 787 OwnPtr<ClearObjectStoreCallback> m_requestCallback; |
| 788 }; | 788 }; |
| 789 | 789 |
| 790 void InspectorIndexedDBAgent::clearObjectStore(ErrorString* errorString, const S
tring& securityOrigin, const String& databaseName, const String& objectStoreName
, PassOwnPtr<ClearObjectStoreCallback> requestCallback) | 790 void InspectorIndexedDBAgent::clearObjectStore(ErrorString* errorString, const S
tring& securityOrigin, const String& databaseName, const String& objectStoreName
, PassOwnPtr<ClearObjectStoreCallback> requestCallback) |
| 791 { | 791 { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 805 clearObjectStore->start(idbFactory, document->getSecurityOrigin(), databaseN
ame); | 805 clearObjectStore->start(idbFactory, document->getSecurityOrigin(), databaseN
ame); |
| 806 } | 806 } |
| 807 | 807 |
| 808 DEFINE_TRACE(InspectorIndexedDBAgent) | 808 DEFINE_TRACE(InspectorIndexedDBAgent) |
| 809 { | 809 { |
| 810 visitor->trace(m_inspectedFrames); | 810 visitor->trace(m_inspectedFrames); |
| 811 InspectorBaseAgent::trace(visitor); | 811 InspectorBaseAgent::trace(visitor); |
| 812 } | 812 } |
| 813 | 813 |
| 814 } // namespace blink | 814 } // namespace blink |
| OLD | NEW |