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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 IDB_TRACE("IDBCursor::value"); | 118 IDB_TRACE("IDBCursor::value"); |
119 m_valueIsDirty = false; | 119 m_valueIsDirty = false; |
120 return m_currentValue; | 120 return m_currentValue; |
121 } | 121 } |
122 | 122 |
123 IDBAny* IDBCursor::source() const | 123 IDBAny* IDBCursor::source() const |
124 { | 124 { |
125 return m_source.get(); | 125 return m_source.get(); |
126 } | 126 } |
127 | 127 |
128 PassRefPtr<IDBRequest> IDBCursor::update(ScriptExecutionContext* context, Script
Value& value, ExceptionCode& ec) | 128 PassRefPtr<IDBRequest> IDBCursor::update(ScriptExecutionContext* context, PassRe
fPtr<SerializedScriptValue> prpValue, ExceptionCode& ec) |
129 { | 129 { |
130 IDB_TRACE("IDBCursor::update"); | 130 IDB_TRACE("IDBCursor::update"); |
| 131 RefPtr<SerializedScriptValue> value = prpValue; |
131 | 132 |
132 if (!m_gotValue || isKeyCursor()) { | 133 if (!m_gotValue || isKeyCursor()) { |
133 ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; | 134 ec = IDBDatabaseException::IDB_INVALID_STATE_ERR; |
134 return 0; | 135 return 0; |
135 } | 136 } |
136 if (!m_transaction->isActive()) { | 137 if (!m_transaction->isActive()) { |
137 ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; | 138 ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR; |
138 return 0; | 139 return 0; |
139 } | 140 } |
140 if (m_transaction->isReadOnly()) { | 141 if (m_transaction->isReadOnly()) { |
141 ec = IDBDatabaseException::READ_ONLY_ERR; | 142 ec = IDBDatabaseException::READ_ONLY_ERR; |
142 return 0; | 143 return 0; |
143 } | 144 } |
| 145 if (value->blobURLs().size() > 0) { |
| 146 // FIXME: Add Blob/File/FileList support |
| 147 ec = IDBDatabaseException::IDB_DATA_CLONE_ERR; |
| 148 return 0; |
| 149 } |
144 | 150 |
145 RefPtr<IDBObjectStore> objectStore = effectiveObjectStore(); | 151 RefPtr<IDBObjectStore> objectStore = effectiveObjectStore(); |
146 const IDBKeyPath& keyPath = objectStore->metadata().keyPath; | 152 const IDBKeyPath& keyPath = objectStore->metadata().keyPath; |
147 const bool usesInLineKeys = !keyPath.isNull(); | 153 const bool usesInLineKeys = !keyPath.isNull(); |
148 if (usesInLineKeys) { | 154 if (usesInLineKeys) { |
149 RefPtr<IDBKey> keyPathKey = createIDBKeyFromScriptValueAndKeyPath(value,
keyPath); | 155 RefPtr<IDBKey> keyPathKey = createIDBKeyFromSerializedValueAndKeyPath(va
lue, keyPath); |
150 if (!keyPathKey || !keyPathKey->isEqual(m_currentPrimaryKey.get())) { | 156 if (!keyPathKey || !keyPathKey->isEqual(m_currentPrimaryKey.get())) { |
151 ec = IDBDatabaseException::DATA_ERR; | 157 ec = IDBDatabaseException::DATA_ERR; |
152 return 0; | 158 return 0; |
153 } | 159 } |
154 } | 160 } |
155 | 161 |
156 return objectStore->put(IDBObjectStoreBackendInterface::CursorUpdate, IDBAny
::create(this), context, value, m_currentPrimaryKey, ec); | 162 return objectStore->put(IDBObjectStoreBackendInterface::CursorUpdate, IDBAny
::create(this), context, value, m_currentPrimaryKey, ec); |
157 } | 163 } |
158 | 164 |
159 void IDBCursor::advance(long count, ExceptionCode& ec) | 165 void IDBCursor::advance(long count, ExceptionCode& ec) |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 | 335 |
330 default: | 336 default: |
331 ec = NATIVE_TYPE_ERR; | 337 ec = NATIVE_TYPE_ERR; |
332 return IDBCursor::directionNext(); | 338 return IDBCursor::directionNext(); |
333 } | 339 } |
334 } | 340 } |
335 | 341 |
336 } // namespace WebCore | 342 } // namespace WebCore |
337 | 343 |
338 #endif // ENABLE(INDEXED_DATABASE) | 344 #endif // ENABLE(INDEXED_DATABASE) |
OLD | NEW |