| 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 STORAGE_BROWSER_BLOB_SHAREABLE_BLOB_DATA_ITEM_H_ | 5 #ifndef STORAGE_BROWSER_BLOB_SHAREABLE_BLOB_DATA_ITEM_H_ |
| 6 #define STORAGE_BROWSER_BLOB_SHAREABLE_BLOB_DATA_ITEM_H_ | 6 #define STORAGE_BROWSER_BLOB_SHAREABLE_BLOB_DATA_ITEM_H_ |
| 7 | 7 |
| 8 #include <string> |
| 9 |
| 8 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| 9 #include "base/hash.h" | 11 #include "base/hash.h" |
| 10 #include "base/macros.h" | 12 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 12 #include "storage/common/data_element.h" | 14 #include "storage/common/data_element.h" |
| 13 | 15 |
| 14 namespace storage { | 16 namespace storage { |
| 15 | |
| 16 class BlobDataItem; | 17 class BlobDataItem; |
| 18 class InternalBlobData; |
| 17 | 19 |
| 18 // This class allows blob items to be shared between blobs, and is only used by | 20 // This class allows blob items to be shared between blobs, and is only used by |
| 19 // BlobStorageContext. This class contains both the blob data item and the uuids | 21 // BlobStorageContext. This class contains both the blob data item and the uuids |
| 20 // of all the blobs using this item. | 22 // of all the blobs using this item. |
| 21 // The data in this class (the item) is immutable, but the item itself can be | 23 // The data in this class (the item) is immutable, but the item itself can be |
| 22 // swapped out with an item with the same data but a different backing (think | 24 // swapped out with an item with the same data but a different backing (think |
| 23 // RAM vs file backed). | 25 // RAM vs file backed). |
| 24 class ShareableBlobDataItem : public base::RefCounted<ShareableBlobDataItem> { | 26 class ShareableBlobDataItem : public base::RefCounted<ShareableBlobDataItem> { |
| 25 public: | 27 public: |
| 26 ShareableBlobDataItem(const std::string& blob_uuid, | 28 ShareableBlobDataItem(const std::string& blob_uuid, |
| 27 const scoped_refptr<BlobDataItem>& item); | 29 const scoped_refptr<BlobDataItem>& item); |
| 28 | 30 |
| 29 const scoped_refptr<BlobDataItem>& item(); | 31 const scoped_refptr<BlobDataItem>& item(); |
| 30 | 32 |
| 31 base::hash_set<std::string>& referencing_blobs() { | 33 base::hash_set<std::string>& referencing_blobs() { |
| 32 return referencing_blobs_; | 34 return referencing_blobs_; |
| 33 } | 35 } |
| 34 | 36 |
| 35 private: | 37 private: |
| 36 friend class base::RefCounted<ShareableBlobDataItem>; | 38 friend class base::RefCounted<ShareableBlobDataItem>; |
| 39 friend class InternalBlobData; |
| 37 ~ShareableBlobDataItem(); | 40 ~ShareableBlobDataItem(); |
| 38 | 41 |
| 39 scoped_refptr<BlobDataItem> item_; | 42 scoped_refptr<BlobDataItem> item_; |
| 40 | 43 |
| 41 base::hash_set<std::string> referencing_blobs_; | 44 base::hash_set<std::string> referencing_blobs_; |
| 42 | 45 |
| 43 DISALLOW_COPY_AND_ASSIGN(ShareableBlobDataItem); | 46 DISALLOW_COPY_AND_ASSIGN(ShareableBlobDataItem); |
| 44 }; | 47 }; |
| 45 | 48 |
| 46 } // namespace storage | 49 } // namespace storage |
| 47 #endif // STORAGE_BROWSER_BLOB_SHAREABLE_BLOB_DATA_ITEM_H_ | 50 #endif // STORAGE_BROWSER_BLOB_SHAREABLE_BLOB_DATA_ITEM_H_ |
| OLD | NEW |