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

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

Issue 10444010: Revert 138554 - Prevent zero-length items from being appended to a blob. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 | « webkit/blob/blob_data.h ('k') | webkit/blob/blob_storage_controller.cc » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "webkit/blob/blob_data.h" 5 #include "webkit/blob/blob_data.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/sys_string_conversions.h" 8 #include "base/sys_string_conversions.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebBlobData. h" 11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebBlobData. h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 default: 79 default:
80 NOTREACHED(); 80 NOTREACHED();
81 } 81 }
82 } 82 }
83 content_type_= data.contentType().utf8().data(); 83 content_type_= data.contentType().utf8().data();
84 content_disposition_ = data.contentDisposition().utf8().data(); 84 content_disposition_ = data.contentDisposition().utf8().data();
85 } 85 }
86 86
87 BlobData::~BlobData() {} 87 BlobData::~BlobData() {}
88 88
89 void BlobData::AppendData(const char* data, size_t length) {
90 DCHECK(length > 0);
91 items_.push_back(Item());
92 items_.back().SetToData(data, length);
93 }
94
95 void BlobData::AppendFile(const FilePath& file_path, uint64 offset,
96 uint64 length,
97 const base::Time& expected_modification_time) {
98 DCHECK(length > 0);
99 items_.push_back(Item());
100 items_.back().SetToFile(file_path, offset, length,
101 expected_modification_time);
102 }
103
104 void BlobData::AppendBlob(const GURL& blob_url, uint64 offset, uint64 length) {
105 DCHECK(length > 0);
106 items_.push_back(Item());
107 items_.back().SetToBlob(blob_url, offset, length);
108 }
109
110 int64 BlobData::GetMemoryUsage() const {
111 int64 memory = 0;
112 for (std::vector<Item>::const_iterator iter = items_.begin();
113 iter != items_.end(); ++iter) {
114 if (iter->type == TYPE_DATA)
115 memory += iter->data.size();
116 }
117 return memory;
118 }
119
120 } // namespace webkit_blob 89 } // namespace webkit_blob
OLDNEW
« no previous file with comments | « webkit/blob/blob_data.h ('k') | webkit/blob/blob_storage_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698