| 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&); |
| 30 ~IDBValue(); | 31 ~IDBValue(); |
| 31 | 32 |
| 32 bool IsNull() const; | 33 bool IsNull() const; |
| 33 Vector<String> GetUUIDs() const; | 34 Vector<String> GetUUIDs() const; |
| 34 RefPtr<SerializedScriptValue> CreateSerializedValue() const; | 35 RefPtr<SerializedScriptValue> CreateSerializedValue() const; |
| 35 Vector<WebBlobInfo>* BlobInfo() const { return blob_info_.get(); } | 36 Vector<WebBlobInfo>* BlobInfo() const { return blob_info_.get(); } |
| 36 const IDBKey* PrimaryKey() const { return primary_key_; } | 37 const IDBKey* PrimaryKey() const { return primary_key_; } |
| 37 const IDBKeyPath& KeyPath() const { return key_path_; } | 38 const IDBKeyPath& KeyPath() const { return key_path_; } |
| 38 | 39 |
| 39 private: | 40 private: |
| 41 friend class IDBValueUnwrapper; |
| 42 |
| 40 IDBValue(); | 43 IDBValue(); |
| 41 IDBValue(const WebIDBValue&, v8::Isolate*); | 44 IDBValue(const WebIDBValue&, v8::Isolate*); |
| 42 IDBValue(PassRefPtr<SharedBuffer>, | 45 IDBValue(PassRefPtr<SharedBuffer>, |
| 43 const WebVector<WebBlobInfo>&, | 46 const WebVector<WebBlobInfo>&, |
| 44 IDBKey*, | 47 IDBKey*, |
| 45 const IDBKeyPath&); | 48 const IDBKeyPath&); |
| 46 IDBValue(const IDBValue*, IDBKey*, const IDBKeyPath&); | 49 IDBValue(const IDBValue*, IDBKey*, const IDBKeyPath&); |
| 47 | 50 |
| 51 // Used by IDBValueUnwrapper. |
| 52 IDBValue(PassRefPtr<SharedBuffer> unwrapped_data, |
| 53 std::unique_ptr<Vector<RefPtr<BlobDataHandle>>>, |
| 54 std::unique_ptr<Vector<WebBlobInfo>>); |
| 55 |
| 48 // Keep this private to prevent new refs because we manually bookkeep the | 56 // Keep this private to prevent new refs because we manually bookkeep the |
| 49 // memory to V8. | 57 // memory to V8. |
| 50 const RefPtr<SharedBuffer> data_; | 58 const RefPtr<SharedBuffer> data_; |
| 51 const std::unique_ptr<Vector<RefPtr<BlobDataHandle>>> blob_data_; | 59 const std::unique_ptr<Vector<RefPtr<BlobDataHandle>>> blob_data_; |
| 52 const std::unique_ptr<Vector<WebBlobInfo>> blob_info_; | 60 const std::unique_ptr<Vector<WebBlobInfo>> blob_info_; |
| 53 const Persistent<IDBKey> primary_key_; | 61 const Persistent<IDBKey> primary_key_; |
| 54 const IDBKeyPath key_path_; | 62 const IDBKeyPath key_path_; |
| 55 int64_t external_allocated_size_ = 0; | 63 int64_t external_allocated_size_ = 0; |
| 56 // Used to register memory externally allocated by the WebIDBValue, and to | 64 // Used to register memory externally allocated by the WebIDBValue, and to |
| 57 // unregister that memory in the destructor. Unused in other construction | 65 // unregister that memory in the destructor. Unused in other construction |
| 58 // paths. | 66 // paths. |
| 59 v8::Isolate* isolate_ = nullptr; | 67 v8::Isolate* isolate_ = nullptr; |
| 60 }; | 68 }; |
| 61 | 69 |
| 62 } // namespace blink | 70 } // namespace blink |
| 63 | 71 |
| 64 #endif | 72 #endif |
| OLD | NEW |