| 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 #ifndef IDBValue_h | 5 #ifndef IDBValue_h |
| 6 #define IDBValue_h | 6 #define IDBValue_h |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include "modules/ModulesExport.h" | 9 #include "modules/ModulesExport.h" |
| 10 #include "modules/indexeddb/IDBKey.h" | 10 #include "modules/indexeddb/IDBKey.h" |
| 11 #include "modules/indexeddb/IDBKeyPath.h" | 11 #include "modules/indexeddb/IDBKeyPath.h" |
| 12 #include "platform/SharedBuffer.h" | 12 #include "platform/SharedBuffer.h" |
| 13 #include "platform/wtf/PassRefPtr.h" |
| 13 #include "platform/wtf/RefPtr.h" | 14 #include "platform/wtf/RefPtr.h" |
| 14 #include "public/platform/WebVector.h" | 15 #include "public/platform/WebVector.h" |
| 15 | 16 |
| 16 namespace blink { | 17 namespace blink { |
| 17 | 18 |
| 18 class BlobDataHandle; | 19 class BlobDataHandle; |
| 19 class SerializedScriptValue; | 20 class SerializedScriptValue; |
| 20 class WebBlobInfo; | 21 class WebBlobInfo; |
| 21 struct WebIDBValue; | 22 struct WebIDBValue; |
| 22 | 23 |
| 23 class MODULES_EXPORT IDBValue final : public RefCounted<IDBValue> { | 24 class MODULES_EXPORT IDBValue final : public RefCounted<IDBValue> { |
| 24 public: | 25 public: |
| 25 static PassRefPtr<IDBValue> Create(); | 26 static PassRefPtr<IDBValue> Create(); |
| 26 static PassRefPtr<IDBValue> Create(const WebIDBValue&, v8::Isolate*); | 27 static PassRefPtr<IDBValue> Create(const WebIDBValue&, v8::Isolate*); |
| 27 static PassRefPtr<IDBValue> Create(const IDBValue*, | 28 static PassRefPtr<IDBValue> Create(const IDBValue*, |
| 28 IDBKey*, | 29 IDBKey*, |
| 29 const IDBKeyPath&); | 30 const IDBKeyPath&); |
| 31 // Used by IDBValueUnwrapper and its tests. |
| 32 static PassRefPtr<IDBValue> Create( |
| 33 PassRefPtr<SharedBuffer> unwrapped_data, |
| 34 std::unique_ptr<Vector<RefPtr<BlobDataHandle>>>, |
| 35 std::unique_ptr<Vector<WebBlobInfo>>); |
| 36 |
| 30 ~IDBValue(); | 37 ~IDBValue(); |
| 31 | 38 |
| 32 bool IsNull() const; | 39 bool IsNull() const; |
| 33 Vector<String> GetUUIDs() const; | 40 Vector<String> GetUUIDs() const; |
| 34 RefPtr<SerializedScriptValue> CreateSerializedValue() const; | 41 RefPtr<SerializedScriptValue> CreateSerializedValue() const; |
| 35 Vector<WebBlobInfo>* BlobInfo() const { return blob_info_.get(); } | 42 Vector<WebBlobInfo>* BlobInfo() const { return blob_info_.get(); } |
| 36 const IDBKey* PrimaryKey() const { return primary_key_; } | 43 const IDBKey* PrimaryKey() const { return primary_key_; } |
| 37 const IDBKeyPath& KeyPath() const { return key_path_; } | 44 const IDBKeyPath& KeyPath() const { return key_path_; } |
| 38 | 45 |
| 39 private: | 46 private: |
| 47 friend class IDBValueUnwrapper; |
| 48 |
| 40 IDBValue(); | 49 IDBValue(); |
| 41 IDBValue(const WebIDBValue&, v8::Isolate*); | 50 IDBValue(const WebIDBValue&, v8::Isolate*); |
| 42 IDBValue(PassRefPtr<SharedBuffer>, | 51 IDBValue(PassRefPtr<SharedBuffer>, |
| 43 const WebVector<WebBlobInfo>&, | 52 const WebVector<WebBlobInfo>&, |
| 44 IDBKey*, | 53 IDBKey*, |
| 45 const IDBKeyPath&); | 54 const IDBKeyPath&); |
| 46 IDBValue(const IDBValue*, IDBKey*, const IDBKeyPath&); | 55 IDBValue(const IDBValue*, IDBKey*, const IDBKeyPath&); |
| 56 IDBValue(PassRefPtr<SharedBuffer> unwrapped_data, |
| 57 std::unique_ptr<Vector<RefPtr<BlobDataHandle>>>, |
| 58 std::unique_ptr<Vector<WebBlobInfo>>); |
| 47 | 59 |
| 48 // Keep this private to prevent new refs because we manually bookkeep the | 60 // Keep this private to prevent new refs because we manually bookkeep the |
| 49 // memory to V8. | 61 // memory to V8. |
| 50 const RefPtr<SharedBuffer> data_; | 62 const RefPtr<SharedBuffer> data_; |
| 51 const std::unique_ptr<Vector<RefPtr<BlobDataHandle>>> blob_data_; | 63 const std::unique_ptr<Vector<RefPtr<BlobDataHandle>>> blob_data_; |
| 52 const std::unique_ptr<Vector<WebBlobInfo>> blob_info_; | 64 const std::unique_ptr<Vector<WebBlobInfo>> blob_info_; |
| 53 const Persistent<IDBKey> primary_key_; | 65 const Persistent<IDBKey> primary_key_; |
| 54 const IDBKeyPath key_path_; | 66 const IDBKeyPath key_path_; |
| 55 int64_t external_allocated_size_ = 0; | 67 int64_t external_allocated_size_ = 0; |
| 56 // Used to register memory externally allocated by the WebIDBValue, and to | 68 // Used to register memory externally allocated by the WebIDBValue, and to |
| 57 // unregister that memory in the destructor. Unused in other construction | 69 // unregister that memory in the destructor. Unused in other construction |
| 58 // paths. | 70 // paths. |
| 59 v8::Isolate* isolate_ = nullptr; | 71 v8::Isolate* isolate_ = nullptr; |
| 60 }; | 72 }; |
| 61 | 73 |
| 62 } // namespace blink | 74 } // namespace blink |
| 63 | 75 |
| 64 #endif | 76 #endif |
| OLD | NEW |