OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef STORAGE_BROWSER_BLOB_INTERNAL_BLOB_DATA_H_ | |
6 #define STORAGE_BROWSER_BLOB_INTERNAL_BLOB_DATA_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/macros.h" | |
12 #include "base/memory/ref_counted.h" | |
13 #include "storage/browser/blob/shareable_blob_data_item.h" | |
14 | |
15 namespace storage { | |
16 class ViewBlobInternalsJob; | |
17 | |
18 // This class represents a blob in the BlobStorageContext. It is constructed | |
19 // using the internal Builder class. | |
20 class InternalBlobData { | |
21 public: | |
22 ~InternalBlobData(); | |
23 | |
24 protected: | |
25 friend class BlobStorageContext; | |
26 friend class ViewBlobInternalsJob; | |
27 | |
28 // Removes the given blob uuid from the internal ShareableBlobDataItems. | |
29 // This is called when this blob is being destroyed. | |
30 void RemoveBlobFromShareableItems(const std::string& blob_uuid); | |
31 | |
32 const std::vector<scoped_refptr<ShareableBlobDataItem>>& items() const; | |
33 const std::string& content_type() const; | |
34 const std::string& content_disposition() const; | |
35 | |
36 // Gets the memory used by this blob that is not shared by other blobs. | |
37 size_t GetNonsharedMemoryUsage() const; | |
38 | |
39 // Includes memory of items possibly shared with other blobs, or items that | |
40 // appear multiple times in this blob. | |
41 size_t GetTotalMemoryUsage() const; | |
42 | |
43 private: | |
44 friend class Builder; | |
45 InternalBlobData(); | |
46 | |
47 std::string content_type_; | |
48 std::string content_disposition_; | |
49 std::vector<scoped_refptr<ShareableBlobDataItem>> items_; | |
50 | |
51 class Builder { | |
52 public: | |
53 Builder(); | |
54 ~Builder(); | |
55 | |
56 void AppendSharedBlobItem(scoped_refptr<ShareableBlobDataItem> item); | |
57 void set_content_type(const std::string& content_type); | |
58 void set_content_disposition(const std::string& content_disposition); | |
59 | |
60 // Gets the memory used by this builder that is not shared with other blobs. | |
61 size_t GetNonsharedMemoryUsage() const; | |
62 | |
63 // Removes the given blob uuid from the internal ShareableBlobDataItems. | |
64 // This is called on destruction of the blob if we're still building it. | |
65 void RemoveBlobFromShareableItems(const std::string& blob_uuid); | |
66 | |
67 // The builder is invalid after calling this method. | |
68 scoped_ptr<::storage::InternalBlobData> Build(); | |
69 | |
70 private: | |
71 scoped_ptr<::storage::InternalBlobData> data_; | |
72 }; | |
Alexei Svitkine (slow)
2015/02/10 16:05:05
DISALLOW_COPY_AND_ASSIGN?
dmurph
2015/02/10 22:17:47
Done.
| |
73 | |
74 DISALLOW_COPY_AND_ASSIGN(InternalBlobData); | |
75 }; | |
76 | |
77 } // namespace storage | |
78 #endif // STORAGE_BROWSER_BLOB_INTERNAL_BLOB_DATA_H_ | |
OLD | NEW |