Index: content/child/blob_storage/blob_consolidation.h |
diff --git a/content/child/blob_storage/blob_consolidation.h b/content/child/blob_storage/blob_consolidation.h |
index 7c581d4cf95ba2e3dace669abd2f4fc58a52d6de..8caf4e6b120aed48977fe2c1d609650f5eb4dbfe 100644 |
--- a/content/child/blob_storage/blob_consolidation.h |
+++ b/content/child/blob_storage/blob_consolidation.h |
@@ -13,8 +13,10 @@ |
#include <string> |
#include <vector> |
+#include "base/callback_forward.h" |
#include "base/logging.h" |
#include "base/macros.h" |
+#include "base/memory/ref_counted.h" |
#include "content/common/content_export.h" |
#include "storage/common/data_element.h" |
#include "third_party/WebKit/public/platform/WebThreadSafeData.h" |
@@ -33,12 +35,14 @@ namespace content { |
// |
// NOTE: this class does not do memory accounting or garbage collecting. The |
// memory for the blob sticks around until this class is destructed. |
-class CONTENT_EXPORT BlobConsolidation { |
+class CONTENT_EXPORT BlobConsolidation |
+ : public base::RefCountedThreadSafe<BlobConsolidation> { |
public: |
enum class ReadStatus { |
ERROR_UNKNOWN, |
ERROR_WRONG_TYPE, |
ERROR_OUT_OF_BOUNDS, |
+ EARLY_ABORT, |
OK |
}; |
struct ConsolidatedItem { |
@@ -64,7 +68,6 @@ class CONTENT_EXPORT BlobConsolidation { |
}; |
BlobConsolidation(); |
- ~BlobConsolidation(); |
void AddDataItem(const blink::WebThreadSafeData& data); |
void AddFileItem(const base::FilePath& path, |
@@ -91,7 +94,22 @@ class CONTENT_EXPORT BlobConsolidation { |
size_t total_memory() const { return total_memory_; } |
- // Reads memory from the given item into the given buffer. Returns: |
+ // The visitor is guaranteed to be called before this method returns. |
kinuko
2016/04/15 15:02:32
Now this comment doesn't give enough info about wh
dmurph
2016/04/20 21:15:34
Done.
|
+ // * ReadStatus::ERROR if the state or arguments are invalid (see error log), |
+ // * ReadStatus::ERROR_WRONG_TYPE if the item at the index isn't memory, |
+ // * ReadStatus::ERROR_OUT_OF_BOUNDS if index, offset, or size are invalid, |
+ // * ReadStatus::EARLY_ABORT if the visitor returns false before we're done, |
+ // * ReadStatus::DONE if the memory has been successfully visited. |
+ ReadStatus VisitMemory( |
+ size_t consolidated_item_index, |
+ size_t consolidated_offset, |
+ size_t consolidated_size, |
+ base::Callback<bool(size_t /* total_memory_read */, |
+ const char* /* memory */, |
+ size_t /* memory_size */)> visitor) const; |
+ |
+ // Reads memory from the given item into the given buffer. This is a simple |
+ // wrapper of VisitMemory. Returns: |
// * ReadStatus::ERROR if the state or arguments are invalid (see error log), |
// * ReadStatus::ERROR_WRONG_TYPE if the item at the index isn't memory, |
// * ReadStatus::ERROR_OUT_OF_BOUNDS if index, offset, or size are invalid, |
@@ -101,9 +119,12 @@ class CONTENT_EXPORT BlobConsolidation { |
ReadStatus ReadMemory(size_t consolidated_item_index, |
size_t consolidated_offset, |
size_t consolidated_size, |
- void* memory_out); |
+ void* memory_out) const; |
private: |
+ friend class base::RefCountedThreadSafe<BlobConsolidation>; |
+ ~BlobConsolidation(); |
+ |
size_t total_memory_; |
std::set<std::string> referenced_blobs_; |
std::vector<ConsolidatedItem> consolidated_items_; |