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

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IDBIndex.cpp

Issue 2276593002: Support renaming of IndexedDB indexes and object stores. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added tests for create rename in the same aborted transaction. Created 4 years, 3 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 IDBIndex::~IDBIndex() 58 IDBIndex::~IDBIndex()
59 { 59 {
60 } 60 }
61 61
62 DEFINE_TRACE(IDBIndex) 62 DEFINE_TRACE(IDBIndex)
63 { 63 {
64 visitor->trace(m_objectStore); 64 visitor->trace(m_objectStore);
65 visitor->trace(m_transaction); 65 visitor->trace(m_transaction);
66 } 66 }
67 67
68 void IDBIndex::setName(const String& name, ExceptionState& exceptionState)
69 {
70 if (!RuntimeEnabledFeatures::indexedDBExperimentalEnabled())
71 return;
72
73 IDB_TRACE("IDBIndex::setName");
74 if (!m_transaction->isVersionChange()) {
75 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::notVers ionChangeTransactionErrorMessage);
76 return;
77 }
78 if (isDeleted()) {
79 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe letedErrorMessage);
80 return;
81 }
82 if (m_transaction->isFinished() || m_transaction->isFinishing()) {
83 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage);
84 return;
85 }
86 if (!m_transaction->isActive()) {
87 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage);
88 return;
89 }
90
91 if (m_metadata.name == name)
92 return;
93 if (m_objectStore->containsIndex(name)) {
94 exceptionState.throwDOMException(ConstraintError, IDBDatabase::indexName TakenErrorMessage);
95 return;
96 }
97 if (!backendDB()) {
98 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
99 return;
100 }
101
102 backendDB()->renameIndex(m_transaction->id(), m_objectStore->id(), id(), nam e);
103 m_objectStore->indexWillBeRenamed(m_metadata.name, name);
104 m_metadata.name = name;
105 m_transaction->db()->indexRenamed(m_objectStore->id(), id(), name);
106 }
107
68 ScriptValue IDBIndex::keyPath(ScriptState* scriptState) const 108 ScriptValue IDBIndex::keyPath(ScriptState* scriptState) const
69 { 109 {
70 return ScriptValue::from(scriptState, m_metadata.keyPath); 110 return ScriptValue::from(scriptState, m_metadata.keyPath);
71 } 111 }
72 112
73 IDBRequest* IDBIndex::openCursor(ScriptState* scriptState, const ScriptValue& ra nge, const String& directionString, ExceptionState& exceptionState) 113 IDBRequest* IDBIndex::openCursor(ScriptState* scriptState, const ScriptValue& ra nge, const String& directionString, ExceptionState& exceptionState)
74 { 114 {
75 IDB_TRACE("IDBIndex::openCursor"); 115 IDB_TRACE("IDBIndex::openCursor");
76 if (isDeleted()) { 116 if (isDeleted()) {
77 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe letedErrorMessage); 117 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe letedErrorMessage);
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 { 307 {
268 return m_transaction->backendDB(); 308 return m_transaction->backendDB();
269 } 309 }
270 310
271 bool IDBIndex::isDeleted() const 311 bool IDBIndex::isDeleted() const
272 { 312 {
273 return m_deleted || m_objectStore->isDeleted(); 313 return m_deleted || m_objectStore->isDeleted();
274 } 314 }
275 315
276 } // namespace blink 316 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698