Index: storage/browser/blob/blob_data_builder.h |
diff --git a/storage/browser/blob/blob_data_builder.h b/storage/browser/blob/blob_data_builder.h |
index f304f446555cff8fa0f9291fea32bb2a95b72051..164b7f39b825aa502529da252a68cac41810f9e4 100644 |
--- a/storage/browser/blob/blob_data_builder.h |
+++ b/storage/browser/blob/blob_data_builder.h |
@@ -16,6 +16,7 @@ |
#include "base/memory/ref_counted.h" |
#include "storage/browser/blob/blob_data_item.h" |
#include "storage/browser/blob/blob_data_snapshot.h" |
+#include "storage/browser/blob/shareable_file_reference.h" |
#include "storage/browser/storage_browser_export.h" |
namespace disk_cache { |
@@ -26,13 +27,21 @@ namespace storage { |
class BlobStorageContext; |
class ShareableFileReference; |
+// This class is used to build blobs. It also facilitates the operation of |
+// 'pending' data, where the user knows the size and existence of a file or |
+// bytes item, but we don't have the memory or file yet. See AppendFuture* and |
+// PopulateFuture* methods for more description. Use |
+// BlobDataHandle::GetBlobStatus to check for an error after creating the blob. |
class STORAGE_EXPORT BlobDataBuilder { |
public: |
using DataHandle = BlobDataItem::DataHandle; |
+ // Visible for tesing. |
+ static const char kAppendFutureFileTemporaryFileName[]; |
michaeln
2016/08/15 22:44:44
please use shorter symbols, kFutureFileName[]
dmurph
2016/08/19 00:18:32
Done.
|
- // This is the filename used for the temporary file items added by |
- // AppendFutureFile. |
- const static char kAppendFutureFileTemporaryFileName[]; |
+ // Use this function to tell if an item was added using AppendFutureFile. |
+ static bool IsTemporaryFileItem(const DataElement& element); |
michaeln
2016/08/15 22:44:44
please use consistent terminology, "future" or "te
dmurph
2016/08/19 00:18:32
Done.
|
+ // Generated from |file_id| given in AppendFutureFile. |
michaeln
2016/08/15 22:44:44
what does this function do? oh?
dmurph
2016/08/19 00:18:32
Done.
|
+ static std::string GetTemporaryFileID(const DataElement& element); |
michaeln
2016/08/15 22:44:44
there's mysteriousness around file_ids and future
dmurph
2016/08/19 00:18:32
Done.
|
explicit BlobDataBuilder(const std::string& uuid); |
~BlobDataBuilder(); |
@@ -73,9 +82,14 @@ class STORAGE_EXPORT BlobDataBuilder { |
// Adds an item that is flagged for future data population. Use |
// 'PopulateFutureFile' to set the file path and expected modification time |
// of this file. Returns the index of the item (to be used in |
- // PopulateFutureFile). The temporary filename used by this method is |
- // kAppendFutureFileTemporaryFileName. |length| cannot be 0. |
- size_t AppendFutureFile(uint64_t offset, uint64_t length); |
+ // PopulateFutureFile). |length| cannot be 0. |
+ // |file_id| should correspond to the file handle used to store this item, |
+ // which needs to be unique on a per-builder bases. This is used by the |
+ // BlobMemoryController class to determine the number and size of files it |
+ // needs to create for a blob. |
+ size_t AppendFutureFile(uint64_t offset, |
+ uint64_t length, |
+ const std::string& file_id); |
// Populates a part of an item previously allocated with AppendFutureFile. |
// Returns true if: |
@@ -106,6 +120,7 @@ class STORAGE_EXPORT BlobDataBuilder { |
void AppendDiskCacheEntry(const scoped_refptr<DataHandle>& data_handle, |
disk_cache::Entry* disk_cache_entry, |
int disk_cache_stream_index); |
+ |
// The content of the side data is accessible with BlobReader::ReadSideData(). |
void AppendDiskCacheEntryWithSideData( |
const scoped_refptr<DataHandle>& data_handle, |
@@ -124,8 +139,10 @@ class STORAGE_EXPORT BlobDataBuilder { |
void Clear(); |
private: |
- friend class BlobStorageContext; |
friend class BlobAsyncBuilderHostTest; |
+ friend struct BlobFlattener; |
+ friend class BlobStorageContext; |
+ FRIEND_TEST_ALL_PREFIXES(BlobStorageContextTest, BuildBlobFuzzy); |
friend bool operator==(const BlobDataBuilder& a, const BlobDataBuilder& b); |
friend bool operator==(const BlobDataSnapshot& a, const BlobDataBuilder& b); |
friend STORAGE_EXPORT void PrintTo(const BlobDataBuilder& x, |