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

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

Issue 1963293002: Replacing Indexed DB Chromium IPC with Mojo Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactoring after Passing URLRequestContextGetter. Created 4 years, 4 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 // 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 "modules/indexeddb/IDBMojoUtil.h"
7 #include "platform/blob/BlobData.h" 8 #include "platform/blob/BlobData.h"
8 #include "public/platform/WebBlobInfo.h" 9 #include "public/platform/WebBlobInfo.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(indexed_db::mojom::blink::ValuePtr value)
17 : IDBValue(value.data, value.webBlobInfo, value.primaryKey, value.keyPath) 17 : m_data(createData(value->data))
18 , m_blobData(new Vector<RefPtr<BlobDataHandle>>())
19 , m_blobInfo(new Vector<WebBlobInfo>(value->data.size()))
20 , m_primaryKey(createKey(value->primary_key))
21 , m_keyPath(createKeyPath(value->key_path))
18 { 22 {
23 WebIDBValue webValue = createValue(value);
24 setBlobData(webValue.webBlobInfo);
19 } 25 }
20 26
21 IDBValue::IDBValue(PassRefPtr<SharedBuffer> data, const WebVector<WebBlobInfo>& webBlobInfo, IDBKey* primaryKey, const IDBKeyPath& keyPath) 27 IDBValue::IDBValue(PassRefPtr<SharedBuffer> data, const WebVector<WebBlobInfo>& webBlobInfo, IDBKey* primaryKey, const IDBKeyPath& keyPath)
22 : m_data(data) 28 : m_data(data)
23 , m_blobData(wrapUnique(new Vector<RefPtr<BlobDataHandle>>())) 29 , m_blobData(wrapUnique(new Vector<RefPtr<BlobDataHandle>>()))
24 , m_blobInfo(wrapUnique(new Vector<WebBlobInfo>(webBlobInfo.size()))) 30 , m_blobInfo(wrapUnique(new Vector<WebBlobInfo>(webBlobInfo.size())))
25 , m_primaryKey(primaryKey && primaryKey->isValid() ? primaryKey : nullptr) 31 , m_primaryKey(primaryKey && primaryKey->isValid() ? primaryKey : nullptr)
26 , m_keyPath(keyPath) 32 , m_keyPath(keyPath)
27 { 33 {
28 for (size_t i = 0; i < webBlobInfo.size(); ++i) { 34 setBlobData(webBlobInfo);
29 const WebBlobInfo& info = (*m_blobInfo)[i] = webBlobInfo[i];
30 m_blobData->append(BlobDataHandle::create(info.uuid(), info.type(), info .size()));
31 }
32 } 35 }
33 36
34 IDBValue::IDBValue(const IDBValue* value, IDBKey* primaryKey, const IDBKeyPath& keyPath) 37 IDBValue::IDBValue(const IDBValue* value, IDBKey* primaryKey, const IDBKeyPath& keyPath)
35 : m_data(value->m_data) 38 : m_data(value->m_data)
36 , m_blobData(wrapUnique(new Vector<RefPtr<BlobDataHandle>>())) 39 , m_blobData(wrapUnique(new Vector<RefPtr<BlobDataHandle>>()))
37 , m_blobInfo(wrapUnique(new Vector<WebBlobInfo>(value->m_blobInfo->size()))) 40 , m_blobInfo(wrapUnique(new Vector<WebBlobInfo>(value->m_blobInfo->size())))
38 , m_primaryKey(primaryKey) 41 , m_primaryKey(primaryKey)
39 , m_keyPath(keyPath) 42 , m_keyPath(keyPath)
40 { 43 {
41 for (size_t i = 0; i < value->m_blobInfo->size(); ++i) { 44 for (size_t i = 0; i < value->m_blobInfo->size(); ++i) {
42 const WebBlobInfo& info = (*m_blobInfo)[i] = value->m_blobInfo->at(i); 45 const WebBlobInfo& info = (*m_blobInfo)[i] = value->m_blobInfo->at(i);
43 m_blobData->append(BlobDataHandle::create(info.uuid(), info.type(), info .size())); 46 m_blobData->append(BlobDataHandle::create(info.uuid(), info.type(), info .size()));
44 } 47 }
45 } 48 }
46 49
47 IDBValue::~IDBValue() {} 50 IDBValue::~IDBValue() {}
48 51
52 void IDBValue::setBlobData(const WebVector<WebBlobInfo>& webBlobInfo)
53 {
54 for (size_t i = 0; i < webBlobInfo.size(); ++i) {
55 const WebBlobInfo& info = (*m_blobInfo)[i] = webBlobInfo[i];
56 m_blobData->append(BlobDataHandle::create(info.uuid(), info.type(), info .size()));
57 }
58 }
59
49 PassRefPtr<IDBValue> IDBValue::create() 60 PassRefPtr<IDBValue> IDBValue::create()
50 { 61 {
51 return adoptRef(new IDBValue()); 62 return adoptRef(new IDBValue());
52 } 63 }
53 64
54 PassRefPtr<IDBValue> IDBValue::create(const WebIDBValue& value) 65 PassRefPtr<IDBValue> IDBValue::create(indexed_db::mojom::blink::ValuePtr value)
55 { 66 {
56 return adoptRef(new IDBValue(value)); 67 return adoptRef(new IDBValue(std::move(value)));
57 } 68 }
58 69
59 PassRefPtr<IDBValue> IDBValue::create(const IDBValue* value, IDBKey* primaryKey, const IDBKeyPath& keyPath) 70 PassRefPtr<IDBValue> IDBValue::create(const IDBValue* value, IDBKey* primaryKey, const IDBKeyPath& keyPath)
60 { 71 {
61 return adoptRef(new IDBValue(value, primaryKey, keyPath)); 72 return adoptRef(new IDBValue(value, primaryKey, keyPath));
62 } 73 }
63 74
64 Vector<String> IDBValue::getUUIDs() const 75 Vector<String> IDBValue::getUUIDs() const
65 { 76 {
66 Vector<String> uuids; 77 Vector<String> uuids;
67 uuids.reserveCapacity(m_blobInfo->size()); 78 uuids.reserveCapacity(m_blobInfo->size());
68 for (const auto& info : *m_blobInfo) 79 for (const auto& info : *m_blobInfo)
69 uuids.append(info.uuid()); 80 uuids.append(info.uuid());
70 return uuids; 81 return uuids;
71 } 82 }
72 83
73 const SharedBuffer* IDBValue::data() const 84 const SharedBuffer* IDBValue::data() const
74 { 85 {
75 return m_data.get(); 86 return m_data.get();
76 } 87 }
77 88
78 bool IDBValue::isNull() const 89 bool IDBValue::isNull() const
79 { 90 {
80 return !m_data.get(); 91 return !m_data.get();
81 } 92 }
82 93
83 } // namespace blink 94 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698