static JSObject* GetDataStoresStructuredCloneCallbacksRead(JSContext* aCx, JSStructuredCloneReader* aReader, uint32_t aTag, uint32_t aData, void* aClosure) { WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx); MOZ_ASSERT(workerPrivate); workerPrivate->AssertIsOnWorkerThread(); if (aTag != WORKER_DATA_STORES_TAG) { MOZ_ASSERT(false, "aTag must be WORKER_DATA_STORES_TAG!"); return nullptr; } NS_ASSERTION(!aData, "aData should be empty"); // Read the holder from the buffer, which points to the data store. nsMainThreadPtrHolder<DataStore>* dataStoreholder; if (!JS_ReadBytes(aReader, &dataStoreholder, sizeof(dataStoreholder))) { MOZ_ASSERT(false, "cannot read bytes for dataStoreholder!"); return nullptr; } // Protect workerStoreObj from moving GC during ~nsRefPtr. JS::Rooted<JSObject*> workerStoreObj(aCx, nullptr); { nsRefPtr<WorkerDataStore> workerStore = new WorkerDataStore(workerPrivate->GlobalScope()); nsMainThreadPtrHandle<DataStore> backingStore(dataStoreholder); // When we're on the worker thread, prepare a DataStoreChangeEventProxy. nsRefPtr<DataStoreChangeEventProxy> eventProxy = new DataStoreChangeEventProxy(workerPrivate, workerStore); // Add the DataStoreChangeEventProxy as an event listener on the main thread. nsRefPtr<DataStoreAddEventListenerRunnable> runnable = new DataStoreAddEventListenerRunnable(workerPrivate, backingStore, eventProxy); runnable->Dispatch(aCx); // Point WorkerDataStore to DataStore. workerStore->SetBackingDataStore(backingStore); JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx)); if (!global) { MOZ_ASSERT(false, "cannot get global!"); } else { workerStoreObj = workerStore->WrapObject(aCx); if (!JS_WrapObject(aCx, &workerStoreObj)) { MOZ_ASSERT(false, "cannot wrap object for workerStoreObj!"); workerStoreObj = nullptr; } } } return workerStoreObj; }
/*! \reimp */ void QUsbStorageGadgetProvider::addBackingStore(const QString &path) { QStringList bs = backingStore(); if (!bs.contains(path)) { bs.append(path); setValue("backingStore", qVariantFromValue(bs)); } }
void CoordinatedGraphicsScene::createBackingStoreIfNeeded(TextureMapperLayer* layer) { if (m_backingStores.contains(layer)) return; RefPtr<CoordinatedBackingStore> backingStore(CoordinatedBackingStore::create()); m_backingStores.add(layer, backingStore); layer->setBackingStore(backingStore); }
bool IDBIndexBackendImpl::addingKeyAllowed(const IDBKey* indexKey, const IDBKey* primaryKey) { if (!m_unique) return true; RefPtr<IDBKey> foundPrimaryKey; bool found = backingStore()->keyExistsInIndex(databaseId(), m_objectStoreBackend->id(), m_id, *indexKey, foundPrimaryKey); if (!found) return true; if (primaryKey && foundPrimaryKey->isEqual(primaryKey)) return true; return false; }
void CoordinatedGraphicsScene::createImageBacking(CoordinatedImageBackingID imageID) { ASSERT(!m_imageBackings.contains(imageID)); RefPtr<CoordinatedBackingStore> backingStore(CoordinatedBackingStore::create()); m_imageBackings.add(imageID, backingStore.release()); }
/*! \reimp */ void QUsbStorageGadgetProvider::removeBackingStore(const QString &path) { QStringList bs = backingStore(); bs.removeAll(path); setValue("backingStore", qVariantFromValue(bs)); }