| Index: third_party/WebKit/Source/modules/indexeddb/IDBValueUnwrapper.h
|
| diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBValueUnwrapper.h b/third_party/WebKit/Source/modules/indexeddb/IDBValueUnwrapper.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6af657f01dc6f0500b06b982b10332c0e01a9c9d
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/modules/indexeddb/IDBValueUnwrapper.h
|
| @@ -0,0 +1,84 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef IDBValueUnwrapper_h
|
| +#define IDBValueUnwrapper_h
|
| +
|
| +#include "platform/SharedBuffer.h"
|
| +#include "platform/wtf/PassRefPtr.h"
|
| +#include "platform/wtf/RefPtr.h"
|
| +#include "platform/wtf/Vector.h"
|
| +#include "public/platform/WebBlobInfo.h"
|
| +
|
| +namespace WTF {
|
| +class String;
|
| +}
|
| +
|
| +namespace blink {
|
| +
|
| +class BlobDataHandle;
|
| +class IDBValue;
|
| +class SharedBuffer;
|
| +
|
| +// Logic for unwrapping large IndexedDB values from Blobs.
|
| +class IDBValueUnwrapper {
|
| + public:
|
| + // Wrapper for an IndexedDB value.
|
| + //
|
| + // The serialization process can throw an exception. The caller is responsible
|
| + // for checking exception_state.
|
| + IDBValueUnwrapper();
|
| +
|
| + // Checks whether a IDBValue's data was wrapped in a Blob.
|
| + static bool IsWrapped(IDBValue*);
|
| +
|
| + // Pieces together an unwrapped IDBValue from a wrapped value and Blob data.
|
| + static PassRefPtr<IDBValue> CreateUnwrapped(
|
| + IDBValue* wrapped_value,
|
| + PassRefPtr<SharedBuffer> unwrapped_data);
|
| +
|
| + // Parses the wrapper Blob information from a wrapped IDBValue.
|
| + //
|
| + // Returns true for success, and false for failure. Failure can mean that the
|
| + // given value was not a wrapped IDBValue, or that the value bytes were
|
| + // corrupted.
|
| + bool Parse(IDBValue*);
|
| +
|
| + // Returns the size of the Blob obtained by the last Unwrap() call.
|
| + //
|
| + // Should only be called after a successful result from Unwrap().
|
| + inline unsigned WrapperBlobSize() const {
|
| + DCHECK(data_);
|
| + return blob_size_;
|
| + }
|
| +
|
| + // Returns a handle to the Blob obtained by the last Unwrap() call.
|
| + //
|
| + // Should only be called exactly once after a successful result from Unwrap().
|
| + PassRefPtr<BlobDataHandle> WrapperBlobHandle();
|
| +
|
| + private:
|
| + // Used to deserialize the wrapped value.
|
| + bool ReadVarint(unsigned& value);
|
| + bool ReadAsciiString(String& value);
|
| +
|
| + // The data of the SharedBuffer in the IDBValue being unwrapped.
|
| + const uint8_t* data_;
|
| +
|
| + // Current deserialization position in data_.
|
| + unsigned position_;
|
| +
|
| + // Smallest invalid position_ value.
|
| + unsigned end_;
|
| +
|
| + // The size of the Blob holding the data for the last unwrapped IDBValue.
|
| + unsigned blob_size_;
|
| +
|
| + // Handle to the Blob holding the data for the last unwrapped IDBValue.
|
| + RefPtr<BlobDataHandle> blob_handle_;
|
| +};
|
| +
|
| +} // namespace blink
|
| +
|
| +#endif // IDBValueWrapper_h
|
|
|