コード例 #1
0
ファイル: IDBDatabase.cpp プロジェクト: vizcount/work
PassRefPtr<IDBObjectStore> IDBDatabase::createObjectStore(const String& name, const OptionsObject& options, ExceptionCode& ec)
{
    if (!m_setVersionTransaction) {
        ec = IDBDatabaseException::NOT_ALLOWED_ERR;
        return 0;
    }

    String keyPath;
    bool keyPathExists = options.getKeyStringWithUndefinedOrNullCheck("keyPath", keyPath);
    if (keyPathExists && !IDBIsValidKeyPath(keyPath)) {
        ec = IDBDatabaseException::NON_TRANSIENT_ERR;
        return 0;
    }

    bool autoIncrement = false;
    options.getKeyBool("autoIncrement", autoIncrement);
    // FIXME: Look up evictable and pass that on as well.

    RefPtr<IDBObjectStoreBackendInterface> objectStore = m_backend->createObjectStore(name, keyPath, autoIncrement, m_setVersionTransaction->backend(), ec);
    if (!objectStore) {
        ASSERT(ec);
        return 0;
    }
    return IDBObjectStore::create(objectStore.release(), m_setVersionTransaction.get());
}
コード例 #2
0
ファイル: IDBObjectStore.cpp プロジェクト: dslab-epfl/warr
PassRefPtr<IDBRequest> IDBObjectStore::openCursor(ScriptExecutionContext* context, const OptionsObject& options, ExceptionCode& ec)
{
    RefPtr<IDBKeyRange> range = options.getKeyKeyRange("range");

    // Converted to an unsigned short.
    int32_t direction = defaultDirection;
    options.getKeyInt32("direction", direction);
    if (direction != IDBCursor::NEXT && direction != IDBCursor::NEXT_NO_DUPLICATE && direction != IDBCursor::PREV && direction != IDBCursor::PREV_NO_DUPLICATE) {
        // FIXME: May need to change when specced: http://www.w3.org/Bugs/Public/show_bug.cgi?id=11406
        ec = IDBDatabaseException::CONSTRAINT_ERR;
        return 0;
    }

    RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), m_transaction.get());
    m_objectStore->openCursor(range, direction, request, m_transaction.get(), ec);
    if (ec)
        return 0;
    return request.release();
}
コード例 #3
0
ファイル: IDBObjectStore.cpp プロジェクト: dslab-epfl/warr
PassRefPtr<IDBIndex> IDBObjectStore::createIndex(const String& name, const String& keyPath, const OptionsObject& options, ExceptionCode& ec)
{
    bool unique = false;
    options.getKeyBool("unique", unique);

    RefPtr<IDBIndexBackendInterface> index = m_objectStore->createIndex(name, keyPath, unique, m_transaction.get(), ec);
    ASSERT(!index != !ec); // If we didn't get an index, we should have gotten an exception code. And vice versa.
    if (!index)
        return 0;
    return IDBIndex::create(index.release(), m_transaction.get());
}