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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 } | 112 } |
113 | 113 |
114 IDBRequest* idbRequest = static_cast<IDBRequest*>(event->target()); | 114 IDBRequest* idbRequest = static_cast<IDBRequest*>(event->target()); |
115 IDBAny* requestResult = idbRequest->resultAsAny(); | 115 IDBAny* requestResult = idbRequest->resultAsAny(); |
116 if (requestResult->type() != IDBAny::DOMStringListType) { | 116 if (requestResult->type() != IDBAny::DOMStringListType) { |
117 m_requestCallback->sendFailure("Unexpected result type."); | 117 m_requestCallback->sendFailure("Unexpected result type."); |
118 return; | 118 return; |
119 } | 119 } |
120 | 120 |
121 RefPtrWillBeRawPtr<DOMStringList> databaseNamesList = requestResult->dom
StringList(); | 121 RefPtrWillBeRawPtr<DOMStringList> databaseNamesList = requestResult->dom
StringList(); |
122 RefPtr<TypeBuilder::Array<String> > databaseNames = TypeBuilder::Array<S
tring>::create(); | 122 RefPtr<TypeBuilder::Array<String>> databaseNames = TypeBuilder::Array<St
ring>::create(); |
123 for (size_t i = 0; i < databaseNamesList->length(); ++i) | 123 for (size_t i = 0; i < databaseNamesList->length(); ++i) |
124 databaseNames->addItem(databaseNamesList->item(i)); | 124 databaseNames->addItem(databaseNamesList->item(i)); |
125 m_requestCallback->sendSuccess(databaseNames.release()); | 125 m_requestCallback->sendSuccess(databaseNames.release()); |
126 } | 126 } |
127 | 127 |
128 private: | 128 private: |
129 GetDatabaseNamesCallback(PassRefPtrWillBeRawPtr<RequestDatabaseNamesCallback
> requestCallback, const String& securityOrigin) | 129 GetDatabaseNamesCallback(PassRefPtrWillBeRawPtr<RequestDatabaseNamesCallback
> requestCallback, const String& securityOrigin) |
130 : EventListener(EventListener::CPPEventListenerType) | 130 : EventListener(EventListener::CPPEventListenerType) |
131 , m_requestCallback(requestCallback) | 131 , m_requestCallback(requestCallback) |
132 , m_securityOrigin(securityOrigin) { } | 132 , m_securityOrigin(securityOrigin) { } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 switch (idbKeyPath.type()) { | 236 switch (idbKeyPath.type()) { |
237 case IDBKeyPath::NullType: | 237 case IDBKeyPath::NullType: |
238 keyPath = KeyPath::create().setType(KeyPath::Type::Null); | 238 keyPath = KeyPath::create().setType(KeyPath::Type::Null); |
239 break; | 239 break; |
240 case IDBKeyPath::StringType: | 240 case IDBKeyPath::StringType: |
241 keyPath = KeyPath::create().setType(KeyPath::Type::String); | 241 keyPath = KeyPath::create().setType(KeyPath::Type::String); |
242 keyPath->setString(idbKeyPath.string()); | 242 keyPath->setString(idbKeyPath.string()); |
243 break; | 243 break; |
244 case IDBKeyPath::ArrayType: { | 244 case IDBKeyPath::ArrayType: { |
245 keyPath = KeyPath::create().setType(KeyPath::Type::Array); | 245 keyPath = KeyPath::create().setType(KeyPath::Type::Array); |
246 RefPtr<TypeBuilder::Array<String> > array = TypeBuilder::Array<String>::
create(); | 246 RefPtr<TypeBuilder::Array<String>> array = TypeBuilder::Array<String>::c
reate(); |
247 const Vector<String>& stringArray = idbKeyPath.array(); | 247 const Vector<String>& stringArray = idbKeyPath.array(); |
248 for (size_t i = 0; i < stringArray.size(); ++i) | 248 for (size_t i = 0; i < stringArray.size(); ++i) |
249 array->addItem(stringArray[i]); | 249 array->addItem(stringArray[i]); |
250 keyPath->setArray(array); | 250 keyPath->setArray(array); |
251 break; | 251 break; |
252 } | 252 } |
253 default: | 253 default: |
254 ASSERT_NOT_REACHED(); | 254 ASSERT_NOT_REACHED(); |
255 } | 255 } |
256 | 256 |
257 return keyPath.release(); | 257 return keyPath.release(); |
258 } | 258 } |
259 | 259 |
260 class DatabaseLoader final : public ExecutableWithDatabase { | 260 class DatabaseLoader final : public ExecutableWithDatabase { |
261 public: | 261 public: |
262 static PassRefPtr<DatabaseLoader> create(ScriptState* scriptState, PassRefPt
rWillBeRawPtr<RequestDatabaseCallback> requestCallback) | 262 static PassRefPtr<DatabaseLoader> create(ScriptState* scriptState, PassRefPt
rWillBeRawPtr<RequestDatabaseCallback> requestCallback) |
263 { | 263 { |
264 return adoptRef(new DatabaseLoader(scriptState, requestCallback)); | 264 return adoptRef(new DatabaseLoader(scriptState, requestCallback)); |
265 } | 265 } |
266 | 266 |
267 virtual ~DatabaseLoader() { } | 267 virtual ~DatabaseLoader() { } |
268 | 268 |
269 virtual void execute(IDBDatabase* idbDatabase) override | 269 virtual void execute(IDBDatabase* idbDatabase) override |
270 { | 270 { |
271 if (!requestCallback()->isActive()) | 271 if (!requestCallback()->isActive()) |
272 return; | 272 return; |
273 | 273 |
274 const IDBDatabaseMetadata databaseMetadata = idbDatabase->metadata(); | 274 const IDBDatabaseMetadata databaseMetadata = idbDatabase->metadata(); |
275 | 275 |
276 RefPtr<TypeBuilder::Array<TypeBuilder::IndexedDB::ObjectStore> > objectS
tores = TypeBuilder::Array<TypeBuilder::IndexedDB::ObjectStore>::create(); | 276 RefPtr<TypeBuilder::Array<TypeBuilder::IndexedDB::ObjectStore>> objectSt
ores = TypeBuilder::Array<TypeBuilder::IndexedDB::ObjectStore>::create(); |
277 | 277 |
278 for (const auto& storeMapEntry : databaseMetadata.objectStores) { | 278 for (const auto& storeMapEntry : databaseMetadata.objectStores) { |
279 const IDBObjectStoreMetadata& objectStoreMetadata = storeMapEntry.va
lue; | 279 const IDBObjectStoreMetadata& objectStoreMetadata = storeMapEntry.va
lue; |
280 | 280 |
281 RefPtr<TypeBuilder::Array<TypeBuilder::IndexedDB::ObjectStoreIndex>
> indexes = TypeBuilder::Array<TypeBuilder::IndexedDB::ObjectStoreIndex>::create
(); | 281 RefPtr<TypeBuilder::Array<TypeBuilder::IndexedDB::ObjectStoreIndex>>
indexes = TypeBuilder::Array<TypeBuilder::IndexedDB::ObjectStoreIndex>::create(
); |
282 | 282 |
283 for (const auto& metadataMapEntry : objectStoreMetadata.indexes) { | 283 for (const auto& metadataMapEntry : objectStoreMetadata.indexes) { |
284 const IDBIndexMetadata& indexMetadata = metadataMapEntry.value; | 284 const IDBIndexMetadata& indexMetadata = metadataMapEntry.value; |
285 | 285 |
286 RefPtr<ObjectStoreIndex> objectStoreIndex = ObjectStoreIndex::cr
eate() | 286 RefPtr<ObjectStoreIndex> objectStoreIndex = ObjectStoreIndex::cr
eate() |
287 .setName(indexMetadata.name) | 287 .setName(indexMetadata.name) |
288 .setKeyPath(keyPathFromIDBKeyPath(indexMetadata.keyPath)) | 288 .setKeyPath(keyPathFromIDBKeyPath(indexMetadata.keyPath)) |
289 .setUnique(indexMetadata.unique) | 289 .setUnique(indexMetadata.unique) |
290 .setMultiEntry(indexMetadata.multiEntry); | 290 .setMultiEntry(indexMetadata.multiEntry); |
291 indexes->addItem(objectStoreIndex); | 291 indexes->addItem(objectStoreIndex); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 , m_skipCount(skipCount) | 479 , m_skipCount(skipCount) |
480 , m_pageSize(pageSize) | 480 , m_pageSize(pageSize) |
481 { | 481 { |
482 m_result = Array<DataEntry>::create(); | 482 m_result = Array<DataEntry>::create(); |
483 } | 483 } |
484 | 484 |
485 RefPtr<ScriptState> m_scriptState; | 485 RefPtr<ScriptState> m_scriptState; |
486 RefPtrWillBePersistent<RequestDataCallback> m_requestCallback; | 486 RefPtrWillBePersistent<RequestDataCallback> m_requestCallback; |
487 int m_skipCount; | 487 int m_skipCount; |
488 unsigned m_pageSize; | 488 unsigned m_pageSize; |
489 RefPtr<Array<DataEntry> > m_result; | 489 RefPtr<Array<DataEntry>> m_result; |
490 }; | 490 }; |
491 | 491 |
492 class DataLoader final : public ExecutableWithDatabase { | 492 class DataLoader final : public ExecutableWithDatabase { |
493 public: | 493 public: |
494 static PassRefPtr<DataLoader> create(ScriptState* scriptState, PassRefPtrWil
lBeRawPtr<RequestDataCallback> requestCallback, const String& objectStoreName, c
onst String& indexName, IDBKeyRange* idbKeyRange, int skipCount, unsigned pageSi
ze) | 494 static PassRefPtr<DataLoader> create(ScriptState* scriptState, PassRefPtrWil
lBeRawPtr<RequestDataCallback> requestCallback, const String& objectStoreName, c
onst String& indexName, IDBKeyRange* idbKeyRange, int skipCount, unsigned pageSi
ze) |
495 { | 495 { |
496 return adoptRef(new DataLoader(scriptState, requestCallback, objectStore
Name, indexName, idbKeyRange, skipCount, pageSize)); | 496 return adoptRef(new DataLoader(scriptState, requestCallback, objectStore
Name, indexName, idbKeyRange, skipCount, pageSize)); |
497 } | 497 } |
498 | 498 |
499 virtual ~DataLoader() { } | 499 virtual ~DataLoader() { } |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 clearObjectStore->start(idbFactory, document->securityOrigin(), databaseName
); | 786 clearObjectStore->start(idbFactory, document->securityOrigin(), databaseName
); |
787 } | 787 } |
788 | 788 |
789 void InspectorIndexedDBAgent::trace(Visitor* visitor) | 789 void InspectorIndexedDBAgent::trace(Visitor* visitor) |
790 { | 790 { |
791 visitor->trace(m_page); | 791 visitor->trace(m_page); |
792 InspectorBaseAgent::trace(visitor); | 792 InspectorBaseAgent::trace(visitor); |
793 } | 793 } |
794 | 794 |
795 } // namespace blink | 795 } // namespace blink |
OLD | NEW |