Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: webkit/blob/blob_data.h

Issue 3582002: Add deletable file refs to Blobs (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | webkit/blob/blob_storage_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 WEBKIT_BLOB_BLOB_DATA_H_ 5 #ifndef WEBKIT_BLOB_BLOB_DATA_H_
6 #define WEBKIT_BLOB_BLOB_DATA_H_ 6 #define WEBKIT_BLOB_BLOB_DATA_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/ref_counted.h" 12 #include "base/ref_counted.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
15 #include "webkit/blob/deletable_file_reference.h"
15 16
16 namespace WebKit { 17 namespace WebKit {
17 class WebBlobData; 18 class WebBlobData;
18 } 19 }
19 20
20 namespace webkit_blob { 21 namespace webkit_blob {
21 22
22 class BlobData : public base::RefCounted<BlobData> { 23 class BlobData : public base::RefCounted<BlobData> {
23 public: 24 public:
24 enum Type { 25 enum Type {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 items_.push_back(Item()); 111 items_.push_back(Item());
111 items_.back().SetToFile(file_path, offset, length, 112 items_.back().SetToFile(file_path, offset, length,
112 expected_modification_time); 113 expected_modification_time);
113 } 114 }
114 115
115 void AppendBlob(const GURL& blob_url, uint64 offset, uint64 length) { 116 void AppendBlob(const GURL& blob_url, uint64 offset, uint64 length) {
116 items_.push_back(Item()); 117 items_.push_back(Item());
117 items_.back().SetToBlob(blob_url, offset, length); 118 items_.back().SetToBlob(blob_url, offset, length);
118 } 119 }
119 120
121 void AttachDeletableFileReference(DeletableFileReference* reference) {
122 deletable_files_.push_back(reference);
123 }
124
120 const std::vector<Item>& items() const { return items_; } 125 const std::vector<Item>& items() const { return items_; }
121 void set_items(const std::vector<Item>& items) {
122 items_ = items;
123 }
124 void swap_items(std::vector<Item>* items) {
125 items_.swap(*items);
126 }
127 126
128 const std::string& content_type() const { return content_type_; } 127 const std::string& content_type() const { return content_type_; }
129 void set_content_type(const std::string& content_type) { 128 void set_content_type(const std::string& content_type) {
130 content_type_ = content_type; 129 content_type_ = content_type;
131 } 130 }
132 131
133 const std::string& content_disposition() const { 132 const std::string& content_disposition() const {
134 return content_disposition_; 133 return content_disposition_;
135 } 134 }
136 void set_content_disposition(const std::string& content_disposition) { 135 void set_content_disposition(const std::string& content_disposition) {
137 content_disposition_ = content_disposition; 136 content_disposition_ = content_disposition;
138 } 137 }
139 138
139 // Should only be called by the IPC ParamTraits for this class.
140 void swap_items(std::vector<Item>* items) {
141 items_.swap(*items);
142 }
143
140 private: 144 private:
141 friend class base::RefCounted<BlobData>; 145 friend class base::RefCounted<BlobData>;
142 146
143 virtual ~BlobData() { } 147 virtual ~BlobData() { }
144 148
145 std::string content_type_; 149 std::string content_type_;
146 std::string content_disposition_; 150 std::string content_disposition_;
147 std::vector<Item> items_; 151 std::vector<Item> items_;
152 std::vector<scoped_refptr<DeletableFileReference> > deletable_files_;
153
154 DISALLOW_COPY_AND_ASSIGN(BlobData);
148 }; 155 };
149 156
150 #if defined(UNIT_TEST) 157 #if defined(UNIT_TEST)
151 inline bool operator==(const BlobData::Item& a, const BlobData::Item& b) { 158 inline bool operator==(const BlobData::Item& a, const BlobData::Item& b) {
152 if (a.type() != b.type()) 159 if (a.type() != b.type())
153 return false; 160 return false;
154 if (a.type() == BlobData::TYPE_DATA) { 161 if (a.type() == BlobData::TYPE_DATA) {
155 return a.data() == b.data() && 162 return a.data() == b.data() &&
156 a.offset() == b.offset() && 163 a.offset() == b.offset() &&
157 a.length() == b.length(); 164 a.length() == b.length();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 196 }
190 197
191 inline bool operator!=(const BlobData& a, const BlobData& b) { 198 inline bool operator!=(const BlobData& a, const BlobData& b) {
192 return !(a == b); 199 return !(a == b);
193 } 200 }
194 #endif // defined(UNIT_TEST) 201 #endif // defined(UNIT_TEST)
195 202
196 } // namespace webkit_blob 203 } // namespace webkit_blob
197 204
198 #endif // WEBKIT_BLOB_BLOB_DATA_H_ 205 #endif // WEBKIT_BLOB_BLOB_DATA_H_
OLDNEW
« no previous file with comments | « no previous file | webkit/blob/blob_storage_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698