OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 } | 282 } |
283 | 283 |
284 namespace { | 284 namespace { |
285 // This class creates the index keys for a given index by extracting | 285 // This class creates the index keys for a given index by extracting |
286 // them from the SerializedScriptValue, for all the existing values in | 286 // them from the SerializedScriptValue, for all the existing values in |
287 // the objectStore. It only needs to be kept alive by virtue of being | 287 // the objectStore. It only needs to be kept alive by virtue of being |
288 // a listener on an IDBRequest object, in the same way that JavaScript | 288 // a listener on an IDBRequest object, in the same way that JavaScript |
289 // cursor success handlers are kept alive. | 289 // cursor success handlers are kept alive. |
290 class IndexPopulator : public EventListener { | 290 class IndexPopulator : public EventListener { |
291 public: | 291 public: |
292 static PassRefPtr<IndexPopulator> create(PassRefPtr<IDBDatabaseBackendInterf
ace> backend, int64_t transactionId, int64_t objectStoreId, const IDBIndexMetada
ta& indexMetadata) | 292 static PassRefPtr<IndexPopulator> create(IDBDatabaseBackendInterface* backen
d, int64_t transactionId, int64_t objectStoreId, const IDBIndexMetadata& indexMe
tadata) |
293 { | 293 { |
294 return adoptRef(new IndexPopulator(backend, transactionId, objectStoreId
, indexMetadata)); | 294 return adoptRef(new IndexPopulator(backend, transactionId, objectStoreId
, indexMetadata)); |
295 } | 295 } |
296 | 296 |
297 virtual bool operator==(const EventListener& other) | 297 virtual bool operator==(const EventListener& other) |
298 { | 298 { |
299 return this == &other; | 299 return this == &other; |
300 } | 300 } |
301 | 301 |
302 private: | 302 private: |
303 IndexPopulator(PassRefPtr<IDBDatabaseBackendInterface> backend, int64_t tran
sactionId, int64_t objectStoreId, const IDBIndexMetadata& indexMetadata) | 303 IndexPopulator(IDBDatabaseBackendInterface* backend, int64_t transactionId,
int64_t objectStoreId, const IDBIndexMetadata& indexMetadata) |
304 : EventListener(CPPEventListenerType) | 304 : EventListener(CPPEventListenerType) |
305 , m_databaseBackend(backend) | 305 , m_databaseBackend(backend) |
306 , m_transactionId(transactionId) | 306 , m_transactionId(transactionId) |
307 , m_objectStoreId(objectStoreId) | 307 , m_objectStoreId(objectStoreId) |
308 , m_indexMetadata(indexMetadata) | 308 , m_indexMetadata(indexMetadata) |
309 { | 309 { |
310 } | 310 } |
311 | 311 |
312 virtual void handleEvent(ScriptExecutionContext*, Event* event) | 312 virtual void handleEvent(ScriptExecutionContext*, Event* event) |
313 { | 313 { |
(...skipping 23 matching lines...) Expand all Loading... |
337 m_databaseBackend->setIndexKeys(m_transactionId, m_objectStoreId, pr
imaryKey, indexIds, indexKeysList); | 337 m_databaseBackend->setIndexKeys(m_transactionId, m_objectStoreId, pr
imaryKey, indexIds, indexKeysList); |
338 } else { | 338 } else { |
339 // Now that we are done indexing, tell the backend to go | 339 // Now that we are done indexing, tell the backend to go |
340 // back to processing tasks of type NormalTask. | 340 // back to processing tasks of type NormalTask. |
341 m_databaseBackend->setIndexesReady(m_transactionId, m_objectStoreId,
indexIds); | 341 m_databaseBackend->setIndexesReady(m_transactionId, m_objectStoreId,
indexIds); |
342 m_databaseBackend.clear(); | 342 m_databaseBackend.clear(); |
343 } | 343 } |
344 | 344 |
345 } | 345 } |
346 | 346 |
347 RefPtr<IDBDatabaseBackendInterface> m_databaseBackend; | 347 Persistent<IDBDatabaseBackendInterface> m_databaseBackend; |
348 const int64_t m_transactionId; | 348 const int64_t m_transactionId; |
349 const int64_t m_objectStoreId; | 349 const int64_t m_objectStoreId; |
350 const IDBIndexMetadata m_indexMetadata; | 350 const IDBIndexMetadata m_indexMetadata; |
351 }; | 351 }; |
352 } | 352 } |
353 | 353 |
354 PassRefPtr<IDBIndex> IDBObjectStore::createIndex(ScriptExecutionContext* context
, const String& name, const IDBKeyPath& keyPath, const Dictionary& options, Exce
ptionCode& ec) | 354 PassRefPtr<IDBIndex> IDBObjectStore::createIndex(ScriptExecutionContext* context
, const String& name, const IDBKeyPath& keyPath, const Dictionary& options, Exce
ptionCode& ec) |
355 { | 355 { |
356 bool unique = false; | 356 bool unique = false; |
357 options.get("unique", unique); | 357 options.get("unique", unique); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 } | 556 } |
557 return IDBIndexMetadata::InvalidId; | 557 return IDBIndexMetadata::InvalidId; |
558 } | 558 } |
559 | 559 |
560 IDBDatabaseBackendInterface* IDBObjectStore::backendDB() const | 560 IDBDatabaseBackendInterface* IDBObjectStore::backendDB() const |
561 { | 561 { |
562 return m_transaction->backendDB(); | 562 return m_transaction->backendDB(); |
563 } | 563 } |
564 | 564 |
565 } // namespace WebCore | 565 } // namespace WebCore |
OLD | NEW |