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

Side by Side Diff: Source/modules/indexeddb/IDBTransaction.cpp

Issue 18580013: IndexedDB: Make DOMException messages more useful. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Specific message for inactive transactions Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/modules/indexeddb/IDBRequest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // The first error to be set is the true cause of the 132 // The first error to be set is the true cause of the
133 // transaction abort. 133 // transaction abort.
134 if (!m_error) { 134 if (!m_error) {
135 m_error = error; 135 m_error = error;
136 } 136 }
137 } 137 }
138 138
139 PassRefPtr<IDBObjectStore> IDBTransaction::objectStore(const String& name, Excep tionState& es) 139 PassRefPtr<IDBObjectStore> IDBTransaction::objectStore(const String& name, Excep tionState& es)
140 { 140 {
141 if (m_state == Finished) { 141 if (m_state == Finished) {
142 es.throwDOMException(InvalidStateError); 142 es.throwDOMException(InvalidStateError, IDBDatabase::transactionFinished ErrorMessage);
143 return 0; 143 return 0;
144 } 144 }
145 145
146 IDBObjectStoreMap::iterator it = m_objectStoreMap.find(name); 146 IDBObjectStoreMap::iterator it = m_objectStoreMap.find(name);
147 if (it != m_objectStoreMap.end()) 147 if (it != m_objectStoreMap.end())
148 return it->value; 148 return it->value;
149 149
150 if (!isVersionChange() && !m_objectStoreNames.contains(name)) { 150 if (!isVersionChange() && !m_objectStoreNames.contains(name)) {
151 es.throwDOMException(NotFoundError, IDBDatabase::notFoundErrorMessage); 151 es.throwDOMException(NotFoundError, IDBDatabase::noSuchObjectStoreErrorM essage);
152 return 0; 152 return 0;
153 } 153 }
154 154
155 int64_t objectStoreId = m_database->findObjectStoreId(name); 155 int64_t objectStoreId = m_database->findObjectStoreId(name);
156 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) { 156 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) {
157 ASSERT(isVersionChange()); 157 ASSERT(isVersionChange());
158 es.throwDOMException(NotFoundError, IDBDatabase::notFoundErrorMessage); 158 es.throwDOMException(NotFoundError, IDBDatabase::noSuchObjectStoreErrorM essage);
159 return 0; 159 return 0;
160 } 160 }
161 161
162 const IDBDatabaseMetadata& metadata = m_database->metadata(); 162 const IDBDatabaseMetadata& metadata = m_database->metadata();
163 163
164 RefPtr<IDBObjectStore> objectStore = IDBObjectStore::create(metadata.objectS tores.get(objectStoreId), this); 164 RefPtr<IDBObjectStore> objectStore = IDBObjectStore::create(metadata.objectS tores.get(objectStoreId), this);
165 objectStoreCreated(name, objectStore); 165 objectStoreCreated(name, objectStore);
166 return objectStore.release(); 166 return objectStore.release();
167 } 167 }
168 168
(...skipping 28 matching lines...) Expand all
197 ASSERT(active != (m_state == Active)); 197 ASSERT(active != (m_state == Active));
198 m_state = active ? Active : Inactive; 198 m_state = active ? Active : Inactive;
199 199
200 if (!active && m_requestList.isEmpty()) 200 if (!active && m_requestList.isEmpty())
201 backendDB()->commit(m_id); 201 backendDB()->commit(m_id);
202 } 202 }
203 203
204 void IDBTransaction::abort(ExceptionState& es) 204 void IDBTransaction::abort(ExceptionState& es)
205 { 205 {
206 if (m_state == Finishing || m_state == Finished) { 206 if (m_state == Finishing || m_state == Finished) {
207 es.throwDOMException(InvalidStateError); 207 es.throwDOMException(InvalidStateError, IDBDatabase::transactionFinished ErrorMessage);
208 return; 208 return;
209 } 209 }
210 210
211 m_state = Finishing; 211 m_state = Finishing;
212 212
213 if (!m_contextStopped) { 213 if (!m_contextStopped) {
214 while (!m_requestList.isEmpty()) { 214 while (!m_requestList.isEmpty()) {
215 RefPtr<IDBRequest> request = *m_requestList.begin(); 215 RefPtr<IDBRequest> request = *m_requestList.begin();
216 m_requestList.remove(request); 216 m_requestList.remove(request);
217 request->abort(); 217 request->abort();
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 { 444 {
445 return &m_eventTargetData; 445 return &m_eventTargetData;
446 } 446 }
447 447
448 IDBDatabaseBackendInterface* IDBTransaction::backendDB() const 448 IDBDatabaseBackendInterface* IDBTransaction::backendDB() const
449 { 449 {
450 return db()->backend(); 450 return db()->backend();
451 } 451 }
452 452
453 } // namespace WebCore 453 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/indexeddb/IDBRequest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698