| 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 27 matching lines...) Expand all Loading... |
| 38 #include "modules/indexeddb/IDBTransaction.h" | 38 #include "modules/indexeddb/IDBTransaction.h" |
| 39 #include "wtf/PassRefPtr.h" | 39 #include "wtf/PassRefPtr.h" |
| 40 #include "wtf/RefCounted.h" | 40 #include "wtf/RefCounted.h" |
| 41 #include "wtf/RefPtr.h" | 41 #include "wtf/RefPtr.h" |
| 42 #include "wtf/text/WTFString.h" | 42 #include "wtf/text/WTFString.h" |
| 43 | 43 |
| 44 namespace WebCore { | 44 namespace WebCore { |
| 45 | 45 |
| 46 class DOMStringList; | 46 class DOMStringList; |
| 47 class IDBAny; | 47 class IDBAny; |
| 48 class ExceptionState; |
| 48 | 49 |
| 49 class IDBObjectStore : public ScriptWrappable, public RefCounted<IDBObjectStore>
{ | 50 class IDBObjectStore : public ScriptWrappable, public RefCounted<IDBObjectStore>
{ |
| 50 public: | 51 public: |
| 51 static PassRefPtr<IDBObjectStore> create(const IDBObjectStoreMetadata& metad
ata, IDBTransaction* transaction) | 52 static PassRefPtr<IDBObjectStore> create(const IDBObjectStoreMetadata& metad
ata, IDBTransaction* transaction) |
| 52 { | 53 { |
| 53 return adoptRef(new IDBObjectStore(metadata, transaction)); | 54 return adoptRef(new IDBObjectStore(metadata, transaction)); |
| 54 } | 55 } |
| 55 ~IDBObjectStore() { } | 56 ~IDBObjectStore() { } |
| 56 | 57 |
| 57 // Implement the IDBObjectStore IDL | 58 // Implement the IDBObjectStore IDL |
| 58 int64_t id() const { return m_metadata.id; } | 59 int64_t id() const { return m_metadata.id; } |
| 59 const String name() const { return m_metadata.name; } | 60 const String name() const { return m_metadata.name; } |
| 60 PassRefPtr<IDBAny> keyPathAny() const { return IDBAny::create(m_metadata.key
Path); } | 61 PassRefPtr<IDBAny> keyPathAny() const { return IDBAny::create(m_metadata.key
Path); } |
| 61 const IDBKeyPath keyPath() const { return m_metadata.keyPath; } | 62 const IDBKeyPath keyPath() const { return m_metadata.keyPath; } |
| 62 PassRefPtr<DOMStringList> indexNames() const; | 63 PassRefPtr<DOMStringList> indexNames() const; |
| 63 PassRefPtr<IDBTransaction> transaction() const { return m_transaction; } | 64 PassRefPtr<IDBTransaction> transaction() const { return m_transaction; } |
| 64 bool autoIncrement() const { return m_metadata.autoIncrement; } | 65 bool autoIncrement() const { return m_metadata.autoIncrement; } |
| 65 | 66 |
| 66 PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, PassRefPt
r<IDBKeyRange> range, const String& direction, ExceptionCode& ec) { return openC
ursor(context, range, direction, IDBDatabaseBackendInterface::NormalTask, ec); } | 67 PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, PassRefPt
r<IDBKeyRange> range, const String& direction, ExceptionState& es) { return open
Cursor(context, range, direction, IDBDatabaseBackendInterface::NormalTask, es);
} |
| 67 PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext*, const ScriptValue
& key, const String& direction, ExceptionCode&); | 68 PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext*, const ScriptValue
& key, const String& direction, ExceptionState&); |
| 68 PassRefPtr<IDBRequest> get(ScriptExecutionContext*, const ScriptValue& key,
ExceptionCode&); | 69 PassRefPtr<IDBRequest> get(ScriptExecutionContext*, const ScriptValue& key,
ExceptionState&); |
| 69 PassRefPtr<IDBRequest> get(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>,
ExceptionCode&); | 70 PassRefPtr<IDBRequest> get(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>,
ExceptionState&); |
| 70 PassRefPtr<IDBRequest> add(ScriptState*, ScriptValue&, const ScriptValue& ke
y, ExceptionCode&); | 71 PassRefPtr<IDBRequest> add(ScriptState*, ScriptValue&, const ScriptValue& ke
y, ExceptionState&); |
| 71 PassRefPtr<IDBRequest> put(ScriptState*, ScriptValue&, const ScriptValue& ke
y, ExceptionCode&); | 72 PassRefPtr<IDBRequest> put(ScriptState*, ScriptValue&, const ScriptValue& ke
y, ExceptionState&); |
| 72 PassRefPtr<IDBRequest> deleteFunction(ScriptExecutionContext*, PassRefPtr<ID
BKeyRange>, ExceptionCode&); | 73 PassRefPtr<IDBRequest> deleteFunction(ScriptExecutionContext*, PassRefPtr<ID
BKeyRange>, ExceptionState&); |
| 73 PassRefPtr<IDBRequest> deleteFunction(ScriptExecutionContext*, const ScriptV
alue& key, ExceptionCode&); | 74 PassRefPtr<IDBRequest> deleteFunction(ScriptExecutionContext*, const ScriptV
alue& key, ExceptionState&); |
| 74 PassRefPtr<IDBRequest> clear(ScriptExecutionContext*, ExceptionCode&); | 75 PassRefPtr<IDBRequest> clear(ScriptExecutionContext*, ExceptionState&); |
| 75 | 76 |
| 76 PassRefPtr<IDBIndex> createIndex(ScriptExecutionContext* context, const Stri
ng& name, const String& keyPath, const Dictionary& options, ExceptionCode& ec) {
return createIndex(context, name, IDBKeyPath(keyPath), options, ec); } | 77 PassRefPtr<IDBIndex> createIndex(ScriptExecutionContext* context, const Stri
ng& name, const String& keyPath, const Dictionary& options, ExceptionState& es)
{ return createIndex(context, name, IDBKeyPath(keyPath), options, es); } |
| 77 PassRefPtr<IDBIndex> createIndex(ScriptExecutionContext* context, const Stri
ng& name, const Vector<String>& keyPath, const Dictionary& options, ExceptionCod
e& ec) { return createIndex(context, name, IDBKeyPath(keyPath), options, ec); } | 78 PassRefPtr<IDBIndex> createIndex(ScriptExecutionContext* context, const Stri
ng& name, const Vector<String>& keyPath, const Dictionary& options, ExceptionSta
te& es) { return createIndex(context, name, IDBKeyPath(keyPath), options, es); } |
| 78 PassRefPtr<IDBIndex> index(const String& name, ExceptionCode&); | 79 PassRefPtr<IDBIndex> index(const String& name, ExceptionState&); |
| 79 void deleteIndex(const String& name, ExceptionCode&); | 80 void deleteIndex(const String& name, ExceptionState&); |
| 80 | 81 |
| 81 PassRefPtr<IDBRequest> count(ScriptExecutionContext*, PassRefPtr<IDBKeyRange
>, ExceptionCode&); | 82 PassRefPtr<IDBRequest> count(ScriptExecutionContext*, PassRefPtr<IDBKeyRange
>, ExceptionState&); |
| 82 PassRefPtr<IDBRequest> count(ScriptExecutionContext*, const ScriptValue& key
, ExceptionCode&); | 83 PassRefPtr<IDBRequest> count(ScriptExecutionContext*, const ScriptValue& key
, ExceptionState&); |
| 83 | 84 |
| 84 // Used by IDBCursor::update(): | 85 // Used by IDBCursor::update(): |
| 85 PassRefPtr<IDBRequest> put(IDBDatabaseBackendInterface::PutMode, PassRefPtr<
IDBAny> source, ScriptState*, ScriptValue&, PassRefPtr<IDBKey>, ExceptionCode&); | 86 PassRefPtr<IDBRequest> put(IDBDatabaseBackendInterface::PutMode, PassRefPtr<
IDBAny> source, ScriptState*, ScriptValue&, PassRefPtr<IDBKey>, ExceptionState&)
; |
| 86 | 87 |
| 87 void markDeleted() { m_deleted = true; } | 88 void markDeleted() { m_deleted = true; } |
| 88 bool isDeleted() const { return m_deleted; } | 89 bool isDeleted() const { return m_deleted; } |
| 89 void transactionFinished(); | 90 void transactionFinished(); |
| 90 | 91 |
| 91 IDBObjectStoreMetadata metadata() const { return m_metadata; } | 92 IDBObjectStoreMetadata metadata() const { return m_metadata; } |
| 92 void setMetadata(const IDBObjectStoreMetadata& metadata) { m_metadata = meta
data; } | 93 void setMetadata(const IDBObjectStoreMetadata& metadata) { m_metadata = meta
data; } |
| 93 | 94 |
| 94 typedef Vector<RefPtr<IDBKey> > IndexKeys; | 95 typedef Vector<RefPtr<IDBKey> > IndexKeys; |
| 95 typedef HashMap<String, IndexKeys> IndexKeyMap; | 96 typedef HashMap<String, IndexKeys> IndexKeyMap; |
| 96 | 97 |
| 97 IDBDatabaseBackendInterface* backendDB() const; | 98 IDBDatabaseBackendInterface* backendDB() const; |
| 98 | 99 |
| 99 private: | 100 private: |
| 100 IDBObjectStore(const IDBObjectStoreMetadata&, IDBTransaction*); | 101 IDBObjectStore(const IDBObjectStoreMetadata&, IDBTransaction*); |
| 101 | 102 |
| 102 PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext*, PassRefPtr<IDBKey
Range>, const String& direction, IDBDatabaseBackendInterface::TaskType, Exceptio
nCode&); | 103 PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext*, PassRefPtr<IDBKey
Range>, const String& direction, IDBDatabaseBackendInterface::TaskType, Exceptio
nState&); |
| 103 PassRefPtr<IDBIndex> createIndex(ScriptExecutionContext*, const String& name
, const IDBKeyPath&, const Dictionary&, ExceptionCode&); | 104 PassRefPtr<IDBIndex> createIndex(ScriptExecutionContext*, const String& name
, const IDBKeyPath&, const Dictionary&, ExceptionState&); |
| 104 PassRefPtr<IDBIndex> createIndex(ScriptExecutionContext*, const String& name
, const IDBKeyPath&, bool unique, bool multiEntry, ExceptionCode&); | 105 PassRefPtr<IDBIndex> createIndex(ScriptExecutionContext*, const String& name
, const IDBKeyPath&, bool unique, bool multiEntry, ExceptionState&); |
| 105 PassRefPtr<IDBRequest> put(IDBDatabaseBackendInterface::PutMode, PassRefPtr<
IDBAny> source, ScriptState*, ScriptValue&, const ScriptValue& key, ExceptionCod
e&); | 106 PassRefPtr<IDBRequest> put(IDBDatabaseBackendInterface::PutMode, PassRefPtr<
IDBAny> source, ScriptState*, ScriptValue&, const ScriptValue& key, ExceptionSta
te&); |
| 106 | 107 |
| 107 int64_t findIndexId(const String& name) const; | 108 int64_t findIndexId(const String& name) const; |
| 108 bool containsIndex(const String& name) const | 109 bool containsIndex(const String& name) const |
| 109 { | 110 { |
| 110 return findIndexId(name) != IDBIndexMetadata::InvalidId; | 111 return findIndexId(name) != IDBIndexMetadata::InvalidId; |
| 111 } | 112 } |
| 112 | 113 |
| 113 IDBObjectStoreMetadata m_metadata; | 114 IDBObjectStoreMetadata m_metadata; |
| 114 RefPtr<IDBTransaction> m_transaction; | 115 RefPtr<IDBTransaction> m_transaction; |
| 115 bool m_deleted; | 116 bool m_deleted; |
| 116 | 117 |
| 117 typedef HashMap<String, RefPtr<IDBIndex> > IDBIndexMap; | 118 typedef HashMap<String, RefPtr<IDBIndex> > IDBIndexMap; |
| 118 IDBIndexMap m_indexMap; | 119 IDBIndexMap m_indexMap; |
| 119 }; | 120 }; |
| 120 | 121 |
| 121 } // namespace WebCore | 122 } // namespace WebCore |
| 122 | 123 |
| 123 #endif // IDBObjectStore_h | 124 #endif // IDBObjectStore_h |
| OLD | NEW |