| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/indexeddb/IDBValue.h" | 5 #include "modules/indexeddb/IDBValue.h" |
| 6 | 6 |
| 7 #include "platform/blob/BlobData.h" | 7 #include "platform/blob/BlobData.h" |
| 8 #include "public/platform/WebBlobInfo.h" | 8 #include "public/platform/WebBlobInfo.h" |
| 9 #include "public/platform/modules/indexeddb/WebIDBValue.h" | 9 #include "public/platform/modules/indexeddb/WebIDBValue.h" |
| 10 #include "wtf/PtrUtil.h" | 10 #include "wtf/PtrUtil.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 IDBValue::IDBValue() = default; | 14 IDBValue::IDBValue() = default; |
| 15 | 15 |
| 16 IDBValue::IDBValue(const WebIDBValue& value) | 16 IDBValue::IDBValue(const WebIDBValue& value) |
| 17 : IDBValue(value.data, value.webBlobInfo, value.primaryKey, value.keyPath) { | 17 : IDBValue(value.data, value.webBlobInfo, value.primaryKey, value.keyPath) { |
| 18 } | 18 } |
| 19 | 19 |
| 20 IDBValue::IDBValue(PassRefPtr<SharedBuffer> data, | 20 IDBValue::IDBValue(PassRefPtr<SharedBuffer> data, |
| 21 const WebVector<WebBlobInfo>& webBlobInfo, | 21 const WebVector<WebBlobInfo>& webBlobInfo, |
| 22 IDBKey* primaryKey, | 22 IDBKey* primaryKey, |
| 23 const IDBKeyPath& keyPath) | 23 const IDBKeyPath& keyPath) |
| 24 : m_data(data), | 24 : m_data(data), |
| 25 m_blobData(wrapUnique(new Vector<RefPtr<BlobDataHandle>>())), | 25 m_blobData(makeUnique<Vector<RefPtr<BlobDataHandle>>>()), |
| 26 m_blobInfo(wrapUnique(new Vector<WebBlobInfo>(webBlobInfo.size()))), | 26 m_blobInfo(wrapUnique(new Vector<WebBlobInfo>(webBlobInfo.size()))), |
| 27 m_primaryKey(primaryKey && primaryKey->isValid() ? primaryKey : nullptr), | 27 m_primaryKey(primaryKey && primaryKey->isValid() ? primaryKey : nullptr), |
| 28 m_keyPath(keyPath) { | 28 m_keyPath(keyPath) { |
| 29 for (size_t i = 0; i < webBlobInfo.size(); ++i) { | 29 for (size_t i = 0; i < webBlobInfo.size(); ++i) { |
| 30 const WebBlobInfo& info = (*m_blobInfo)[i] = webBlobInfo[i]; | 30 const WebBlobInfo& info = (*m_blobInfo)[i] = webBlobInfo[i]; |
| 31 m_blobData->append( | 31 m_blobData->append( |
| 32 BlobDataHandle::create(info.uuid(), info.type(), info.size())); | 32 BlobDataHandle::create(info.uuid(), info.type(), info.size())); |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 | 35 |
| 36 IDBValue::IDBValue(const IDBValue* value, | 36 IDBValue::IDBValue(const IDBValue* value, |
| 37 IDBKey* primaryKey, | 37 IDBKey* primaryKey, |
| 38 const IDBKeyPath& keyPath) | 38 const IDBKeyPath& keyPath) |
| 39 : m_data(value->m_data), | 39 : m_data(value->m_data), |
| 40 m_blobData(wrapUnique(new Vector<RefPtr<BlobDataHandle>>())), | 40 m_blobData(makeUnique<Vector<RefPtr<BlobDataHandle>>>()), |
| 41 m_blobInfo( | 41 m_blobInfo( |
| 42 wrapUnique(new Vector<WebBlobInfo>(value->m_blobInfo->size()))), | 42 wrapUnique(new Vector<WebBlobInfo>(value->m_blobInfo->size()))), |
| 43 m_primaryKey(primaryKey), | 43 m_primaryKey(primaryKey), |
| 44 m_keyPath(keyPath) { | 44 m_keyPath(keyPath) { |
| 45 for (size_t i = 0; i < value->m_blobInfo->size(); ++i) { | 45 for (size_t i = 0; i < value->m_blobInfo->size(); ++i) { |
| 46 const WebBlobInfo& info = (*m_blobInfo)[i] = value->m_blobInfo->at(i); | 46 const WebBlobInfo& info = (*m_blobInfo)[i] = value->m_blobInfo->at(i); |
| 47 m_blobData->append( | 47 m_blobData->append( |
| 48 BlobDataHandle::create(info.uuid(), info.type(), info.size())); | 48 BlobDataHandle::create(info.uuid(), info.type(), info.size())); |
| 49 } | 49 } |
| 50 } | 50 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 75 | 75 |
| 76 const SharedBuffer* IDBValue::data() const { | 76 const SharedBuffer* IDBValue::data() const { |
| 77 return m_data.get(); | 77 return m_data.get(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool IDBValue::isNull() const { | 80 bool IDBValue::isNull() const { |
| 81 return !m_data.get(); | 81 return !m_data.get(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 } // namespace blink | 84 } // namespace blink |
| OLD | NEW |