| 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 26 matching lines...) Expand all Loading... |
| 37 #include "modules/indexeddb/IDBObjectStore.h" | 37 #include "modules/indexeddb/IDBObjectStore.h" |
| 38 #include "modules/indexeddb/IDBTransaction.h" | 38 #include "modules/indexeddb/IDBTransaction.h" |
| 39 #include "modules/indexeddb/IndexedDB.h" | 39 #include "modules/indexeddb/IndexedDB.h" |
| 40 #include "wtf/PassRefPtr.h" | 40 #include "wtf/PassRefPtr.h" |
| 41 #include "wtf/RefCounted.h" | 41 #include "wtf/RefCounted.h" |
| 42 #include "wtf/RefPtr.h" | 42 #include "wtf/RefPtr.h" |
| 43 | 43 |
| 44 namespace WebCore { | 44 namespace WebCore { |
| 45 | 45 |
| 46 class DOMError; | 46 class DOMError; |
| 47 class ExceptionState; |
| 47 class ScriptExecutionContext; | 48 class ScriptExecutionContext; |
| 48 | 49 |
| 49 typedef int ExceptionCode; | |
| 50 | |
| 51 class IDBDatabase : public RefCounted<IDBDatabase>, public ScriptWrappable, publ
ic EventTarget, public ActiveDOMObject { | 50 class IDBDatabase : public RefCounted<IDBDatabase>, public ScriptWrappable, publ
ic EventTarget, public ActiveDOMObject { |
| 52 public: | 51 public: |
| 53 static PassRefPtr<IDBDatabase> create(ScriptExecutionContext*, PassRefPtr<ID
BDatabaseBackendInterface>, PassRefPtr<IDBDatabaseCallbacks>); | 52 static PassRefPtr<IDBDatabase> create(ScriptExecutionContext*, PassRefPtr<ID
BDatabaseBackendInterface>, PassRefPtr<IDBDatabaseCallbacks>); |
| 54 ~IDBDatabase(); | 53 ~IDBDatabase(); |
| 55 | 54 |
| 56 void setMetadata(const IDBDatabaseMetadata& metadata) { m_metadata = metadat
a; } | 55 void setMetadata(const IDBDatabaseMetadata& metadata) { m_metadata = metadat
a; } |
| 57 void indexCreated(int64_t objectStoreId, const IDBIndexMetadata&); | 56 void indexCreated(int64_t objectStoreId, const IDBIndexMetadata&); |
| 58 void indexDeleted(int64_t objectStoreId, int64_t indexId); | 57 void indexDeleted(int64_t objectStoreId, int64_t indexId); |
| 59 void transactionCreated(IDBTransaction*); | 58 void transactionCreated(IDBTransaction*); |
| 60 void transactionFinished(IDBTransaction*); | 59 void transactionFinished(IDBTransaction*); |
| 61 | 60 |
| 62 // Implement the IDL | 61 // Implement the IDL |
| 63 const String name() const { return m_metadata.name; } | 62 const String name() const { return m_metadata.name; } |
| 64 PassRefPtr<IDBAny> version() const; | 63 PassRefPtr<IDBAny> version() const; |
| 65 PassRefPtr<DOMStringList> objectStoreNames() const; | 64 PassRefPtr<DOMStringList> objectStoreNames() const; |
| 66 | 65 |
| 67 PassRefPtr<IDBObjectStore> createObjectStore(const String& name, const Dicti
onary&, ExceptionCode&); | 66 PassRefPtr<IDBObjectStore> createObjectStore(const String& name, const Dicti
onary&, ExceptionState&); |
| 68 PassRefPtr<IDBObjectStore> createObjectStore(const String& name, const IDBKe
yPath&, bool autoIncrement, ExceptionCode&); | 67 PassRefPtr<IDBObjectStore> createObjectStore(const String& name, const IDBKe
yPath&, bool autoIncrement, ExceptionState&); |
| 69 PassRefPtr<IDBTransaction> transaction(ScriptExecutionContext* context, Pass
RefPtr<DOMStringList> scope, const String& mode, ExceptionCode& ec) { return tra
nsaction(context, *scope, mode, ec); } | 68 PassRefPtr<IDBTransaction> transaction(ScriptExecutionContext* context, Pass
RefPtr<DOMStringList> scope, const String& mode, ExceptionState& es) { return tr
ansaction(context, *scope, mode, es); } |
| 70 PassRefPtr<IDBTransaction> transaction(ScriptExecutionContext*, const Vector
<String>&, const String& mode, ExceptionCode&); | 69 PassRefPtr<IDBTransaction> transaction(ScriptExecutionContext*, const Vector
<String>&, const String& mode, ExceptionState&); |
| 71 PassRefPtr<IDBTransaction> transaction(ScriptExecutionContext*, const String
&, const String& mode, ExceptionCode&); | 70 PassRefPtr<IDBTransaction> transaction(ScriptExecutionContext*, const String
&, const String& mode, ExceptionState&); |
| 72 void deleteObjectStore(const String& name, ExceptionCode&); | 71 void deleteObjectStore(const String& name, ExceptionState&); |
| 73 void close(); | 72 void close(); |
| 74 | 73 |
| 75 DEFINE_ATTRIBUTE_EVENT_LISTENER(abort); | 74 DEFINE_ATTRIBUTE_EVENT_LISTENER(abort); |
| 76 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 75 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
| 77 DEFINE_ATTRIBUTE_EVENT_LISTENER(versionchange); | 76 DEFINE_ATTRIBUTE_EVENT_LISTENER(versionchange); |
| 78 | 77 |
| 79 // IDBDatabaseCallbacks | 78 // IDBDatabaseCallbacks |
| 80 virtual void onVersionChange(int64_t oldVersion, int64_t newVersion); | 79 virtual void onVersionChange(int64_t oldVersion, int64_t newVersion); |
| 81 virtual void onAbort(int64_t, PassRefPtr<DOMError>); | 80 virtual void onAbort(int64_t, PassRefPtr<DOMError>); |
| 82 virtual void onComplete(int64_t); | 81 virtual void onComplete(int64_t); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 100 int64_t findObjectStoreId(const String& name) const; | 99 int64_t findObjectStoreId(const String& name) const; |
| 101 bool containsObjectStore(const String& name) const | 100 bool containsObjectStore(const String& name) const |
| 102 { | 101 { |
| 103 return findObjectStoreId(name) != IDBObjectStoreMetadata::InvalidId; | 102 return findObjectStoreId(name) != IDBObjectStoreMetadata::InvalidId; |
| 104 } | 103 } |
| 105 | 104 |
| 106 IDBDatabaseBackendInterface* backend() const { return m_backend.get(); } | 105 IDBDatabaseBackendInterface* backend() const { return m_backend.get(); } |
| 107 | 106 |
| 108 static int64_t nextTransactionId(); | 107 static int64_t nextTransactionId(); |
| 109 | 108 |
| 109 static const char notFoundErrorMessage[]; |
| 110 |
| 110 using RefCounted<IDBDatabase>::ref; | 111 using RefCounted<IDBDatabase>::ref; |
| 111 using RefCounted<IDBDatabase>::deref; | 112 using RefCounted<IDBDatabase>::deref; |
| 112 | 113 |
| 113 private: | 114 private: |
| 114 IDBDatabase(ScriptExecutionContext*, PassRefPtr<IDBDatabaseBackendInterface>
, PassRefPtr<IDBDatabaseCallbacks>); | 115 IDBDatabase(ScriptExecutionContext*, PassRefPtr<IDBDatabaseBackendInterface>
, PassRefPtr<IDBDatabaseCallbacks>); |
| 115 | 116 |
| 116 // EventTarget | 117 // EventTarget |
| 117 virtual void refEventTarget() { ref(); } | 118 virtual void refEventTarget() { ref(); } |
| 118 virtual void derefEventTarget() { deref(); } | 119 virtual void derefEventTarget() { deref(); } |
| 119 virtual EventTargetData* eventTargetData(); | 120 virtual EventTargetData* eventTargetData(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 135 // Keep track of the versionchange events waiting to be fired on this | 136 // Keep track of the versionchange events waiting to be fired on this |
| 136 // database so that we can cancel them if the database closes. | 137 // database so that we can cancel them if the database closes. |
| 137 Vector<RefPtr<Event> > m_enqueuedEvents; | 138 Vector<RefPtr<Event> > m_enqueuedEvents; |
| 138 | 139 |
| 139 RefPtr<IDBDatabaseCallbacks> m_databaseCallbacks; | 140 RefPtr<IDBDatabaseCallbacks> m_databaseCallbacks; |
| 140 }; | 141 }; |
| 141 | 142 |
| 142 } // namespace WebCore | 143 } // namespace WebCore |
| 143 | 144 |
| 144 #endif // IDBDatabase_h | 145 #endif // IDBDatabase_h |
| OLD | NEW |