| Index: storage/browser/blob/blob_flattener.h
|
| diff --git a/storage/browser/blob/blob_flattener.h b/storage/browser/blob/blob_flattener.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..badd812e8bd21703d8e5ddce9979b0171f314446
|
| --- /dev/null
|
| +++ b/storage/browser/blob/blob_flattener.h
|
| @@ -0,0 +1,58 @@
|
| +// Copyright 2016 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 STORAGE_BROWSER_BLOB_BLOB_FLATTENER_H_
|
| +#define STORAGE_BROWSER_BLOB_BLOB_FLATTENER_H_
|
| +
|
| +#include <map>
|
| +#include <string>
|
| +#include <utility>
|
| +
|
| +#include "base/macros.h"
|
| +#include "base/numerics/safe_math.h"
|
| +#include "storage/browser/blob/blob_storage_registry.h"
|
| +#include "storage/browser/blob/internal_blob_data.h"
|
| +#include "storage/browser/storage_browser_export.h"
|
| +
|
| +namespace storage {
|
| +class BlobDataBuilder;
|
| +
|
| +// The class takes an input BlobDataBuilder and turns it into our
|
| +// InternalBlobData representation. This includes 'flattening' out blob
|
| +// references by extracting the ShareableBlobDataItem slice from the reference
|
| +// and including those items instead. The resulting flattened blob (both regular
|
| +// items and items from other blobs) is put into the |output_blob|. We keep
|
| +// track of edge cases like partial slicing on data or pending file entries,
|
| +// and calculate the total & required memory for this blob.
|
| +struct STORAGE_EXPORT BlobFlattener {
|
| + BlobFlattener(const BlobDataBuilder& input_builder,
|
| + InternalBlobData* output_blob,
|
| + BlobStorageRegistry* registry);
|
| + ~BlobFlattener();
|
| +
|
| + // This can be:
|
| + // * DONE if we're successful,
|
| + // * PENDING_DATA_POPULATION if there's pending data that the user needs to
|
| + // populate,
|
| + // * INVALID_CONSTRUCTION_ARGUMENTS if we have invalid input, or
|
| + // * REFERENCED_BLOB_BROKEN if one of the referenced blobs is broken or we
|
| + // reference ourself.
|
| + BlobStatus status = BlobStatus::ERR_INVALID_CONSTRUCTION_ARGUMENTS;
|
| +
|
| + // This is the total size of the blob, including all memory, files, etc.
|
| + base::CheckedNumeric<uint64_t> total_size;
|
| + // This is the new memory needed to construct the blob, including both memory
|
| + // items as well as copies from other blobs.
|
| + base::CheckedNumeric<uint64_t> memory_needed;
|
| +
|
| + // This contains all blobs referenced.
|
| + std::vector<std::pair<std::string, InternalBlobData*>> dependent_blobs;
|
| +
|
| + // These record all future copies we'll need to do from referenced blobs. This
|
| + // happens when we do a partial slice from a pending data or file item.
|
| + std::vector<InternalBlobData::ItemCopyEntry> copies;
|
| +};
|
| +
|
| +} // namespace storage
|
| +#endif // STORAGE_BROWSER_BLOB_BLOB_FLATTENER_H_
|
|
|