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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 IDB_TRACE("IDBIndex::setName"); |
| 71 if (!m_transaction->isVersionChange()) { |
| 72 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::notVers
ionChangeTransactionErrorMessage); |
| 73 return; |
| 74 } |
| 75 if (isDeleted()) { |
| 76 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe
letedErrorMessage); |
| 77 return; |
| 78 } |
| 79 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
| 80 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
| 81 return; |
| 82 } |
| 83 if (!m_transaction->isActive()) { |
| 84 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
| 85 return; |
| 86 } |
| 87 |
| 88 if (m_metadata.name == name) |
| 89 return; |
| 90 if (m_objectStore->containsIndex(name)) { |
| 91 exceptionState.throwDOMException(ConstraintError, IDBDatabase::indexName
TakenErrorMessage); |
| 92 return; |
| 93 } |
| 94 if (!backendDB()) { |
| 95 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas
eClosedErrorMessage); |
| 96 return; |
| 97 } |
| 98 |
| 99 backendDB()->renameIndex(m_transaction->id(), m_objectStore->id(), id(), nam
e); |
| 100 m_objectStore->indexWillBeRenamed(m_metadata.name, name); |
| 101 m_metadata.name = name; |
| 102 m_transaction->db()->indexRenamed(m_objectStore->id(), id(), name); |
| 103 } |
| 104 |
68 ScriptValue IDBIndex::keyPath(ScriptState* scriptState) const | 105 ScriptValue IDBIndex::keyPath(ScriptState* scriptState) const |
69 { | 106 { |
70 return ScriptValue::from(scriptState, m_metadata.keyPath); | 107 return ScriptValue::from(scriptState, m_metadata.keyPath); |
71 } | 108 } |
72 | 109 |
73 IDBRequest* IDBIndex::openCursor(ScriptState* scriptState, const ScriptValue& ra
nge, const String& directionString, ExceptionState& exceptionState) | 110 IDBRequest* IDBIndex::openCursor(ScriptState* scriptState, const ScriptValue& ra
nge, const String& directionString, ExceptionState& exceptionState) |
74 { | 111 { |
75 IDB_TRACE("IDBIndex::openCursor"); | 112 IDB_TRACE("IDBIndex::openCursor"); |
76 if (isDeleted()) { | 113 if (isDeleted()) { |
77 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe
letedErrorMessage); | 114 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe
letedErrorMessage); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 { | 304 { |
268 return m_transaction->backendDB(); | 305 return m_transaction->backendDB(); |
269 } | 306 } |
270 | 307 |
271 bool IDBIndex::isDeleted() const | 308 bool IDBIndex::isDeleted() const |
272 { | 309 { |
273 return m_deleted || m_objectStore->isDeleted(); | 310 return m_deleted || m_objectStore->isDeleted(); |
274 } | 311 } |
275 | 312 |
276 } // namespace blink | 313 } // namespace blink |
OLD | NEW |