Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IDBDatabase.h

Issue 2314933005: Align IndexedDB metadata rollback on transaction abort to spec. (Closed)
Patch Set: Addressed feedback. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 USING_GARBAGE_COLLECTED_MIXIN(IDBDatabase); 59 USING_GARBAGE_COLLECTED_MIXIN(IDBDatabase);
60 DEFINE_WRAPPERTYPEINFO(); 60 DEFINE_WRAPPERTYPEINFO();
61 61
62 public: 62 public:
63 static IDBDatabase* create(ExecutionContext*, 63 static IDBDatabase* create(ExecutionContext*,
64 std::unique_ptr<WebIDBDatabase>, 64 std::unique_ptr<WebIDBDatabase>,
65 IDBDatabaseCallbacks*); 65 IDBDatabaseCallbacks*);
66 ~IDBDatabase() override; 66 ~IDBDatabase() override;
67 DECLARE_VIRTUAL_TRACE(); 67 DECLARE_VIRTUAL_TRACE();
68 68
69 void setMetadata(const IDBDatabaseMetadata& metadata) { 69 // Overwrites the database metadata, including object store and index
70 m_metadata = metadata; 70 // metadata. Used to pass metadata to the database when it is opened.
71 } 71 void setMetadata(const IDBDatabaseMetadata&);
72 void indexCreated(int64_t objectStoreId, const IDBIndexMetadata&); 72 // Overwrites the database's own metadata, but does not change object store
73 void indexDeleted(int64_t objectStoreId, int64_t indexId); 73 // and index metadata. Used to revert the database's metadata when a
74 void indexRenamed(int64_t objectStoreId, 74 // versionchage transaction is aborted.
75 int64_t indexId, 75 void setDatabaseMetadata(const IDBDatabaseMetadata&);
76 const String& newName);
77 void transactionCreated(IDBTransaction*); 76 void transactionCreated(IDBTransaction*);
78 void transactionFinished(const IDBTransaction*); 77 void transactionFinished(const IDBTransaction*);
79 const String& getObjectStoreName(int64_t objectStoreId) const; 78 const String& getObjectStoreName(int64_t objectStoreId) const;
80 79
81 // Implement the IDL 80 // Implement the IDL
82 const String& name() const { return m_metadata.name; } 81 const String& name() const { return m_metadata.name; }
83 unsigned long long version() const { return m_metadata.version; } 82 unsigned long long version() const { return m_metadata.version; }
84 DOMStringList* objectStoreNames() const; 83 DOMStringList* objectStoreNames() const;
85 84
86 IDBObjectStore* createObjectStore(const String& name, 85 IDBObjectStore* createObjectStore(const String& name,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 118
120 bool isClosePending() const { return m_closePending; } 119 bool isClosePending() const { return m_closePending; }
121 void forceClose(); 120 void forceClose();
122 const IDBDatabaseMetadata& metadata() const { return m_metadata; } 121 const IDBDatabaseMetadata& metadata() const { return m_metadata; }
123 void enqueueEvent(Event*); 122 void enqueueEvent(Event*);
124 123
125 int64_t findObjectStoreId(const String& name) const; 124 int64_t findObjectStoreId(const String& name) const;
126 bool containsObjectStore(const String& name) const { 125 bool containsObjectStore(const String& name) const {
127 return findObjectStoreId(name) != IDBObjectStoreMetadata::InvalidId; 126 return findObjectStoreId(name) != IDBObjectStoreMetadata::InvalidId;
128 } 127 }
129 void objectStoreRenamed(int64_t storeId, const String& newName); 128 void renameObjectStore(int64_t storeId, const String& newName);
129 void revertObjectStoreCreation(int64_t objectStoreId);
130 void revertObjectStoreMetadata(RefPtr<IDBObjectStoreMetadata> oldMetadata);
130 131
131 // Will return nullptr if this database is stopped. 132 // Will return nullptr if this database is stopped.
132 WebIDBDatabase* backend() const { return m_backend.get(); } 133 WebIDBDatabase* backend() const { return m_backend.get(); }
133 134
134 static int64_t nextTransactionId(); 135 static int64_t nextTransactionId();
135 136
136 static const char indexDeletedErrorMessage[]; 137 static const char indexDeletedErrorMessage[];
137 static const char indexNameTakenErrorMessage[]; 138 static const char indexNameTakenErrorMessage[];
138 static const char isKeyCursorErrorMessage[]; 139 static const char isKeyCursorErrorMessage[];
139 static const char noKeyOrKeyRangeErrorMessage[]; 140 static const char noKeyOrKeyRangeErrorMessage[];
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 // Keep track of the versionchange events waiting to be fired on this 180 // Keep track of the versionchange events waiting to be fired on this
180 // database so that we can cancel them if the database closes. 181 // database so that we can cancel them if the database closes.
181 HeapVector<Member<Event>> m_enqueuedEvents; 182 HeapVector<Member<Event>> m_enqueuedEvents;
182 183
183 Member<IDBDatabaseCallbacks> m_databaseCallbacks; 184 Member<IDBDatabaseCallbacks> m_databaseCallbacks;
184 }; 185 };
185 186
186 } // namespace blink 187 } // namespace blink
187 188
188 #endif // IDBDatabase_h 189 #endif // IDBDatabase_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698