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

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

Issue 10827414: Factor out common Element struct from BlobData and ResourceRequestBody (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: webkit/common -> webkit/base Created 8 years, 3 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) 2012 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 11
12 namespace webkit_blob { 12 namespace webkit_blob {
13 13
14 BlobData::Item::Item()
15 : type(TYPE_DATA),
16 data_external(NULL),
17 offset(0),
18 length(0) {
19 }
20
21 BlobData::Item::~Item() {}
22
23 BlobData::BlobData() {} 14 BlobData::BlobData() {}
24 15
25 BlobData::~BlobData() {} 16 BlobData::~BlobData() {}
26 17
27 void BlobData::AppendData(const char* data, size_t length) { 18 void BlobData::AppendData(const char* data, size_t length) {
28 DCHECK(length > 0); 19 DCHECK(length > 0);
29 items_.push_back(Item()); 20 items_.push_back(Item());
30 items_.back().SetToData(data, length); 21 items_.back().SetToBytes(data, length);
31 } 22 }
32 23
33 void BlobData::AppendFile(const FilePath& file_path, uint64 offset, 24 void BlobData::AppendFile(const FilePath& file_path,
34 uint64 length, 25 uint64 offset, uint64 length,
35 const base::Time& expected_modification_time) { 26 const base::Time& expected_modification_time) {
36 DCHECK(length > 0); 27 DCHECK(length > 0);
37 items_.push_back(Item()); 28 items_.push_back(Item());
38 items_.back().SetToFile(file_path, offset, length, 29 items_.back().SetToFilePathRange(file_path, offset, length,
39 expected_modification_time); 30 expected_modification_time);
40 } 31 }
41 32
42 void BlobData::AppendBlob(const GURL& blob_url, uint64 offset, uint64 length) { 33 void BlobData::AppendBlob(const GURL& blob_url, uint64 offset, uint64 length) {
43 DCHECK(length > 0); 34 DCHECK(length > 0);
44 items_.push_back(Item()); 35 items_.push_back(Item());
45 items_.back().SetToBlob(blob_url, offset, length); 36 items_.back().SetToBlobUrlRange(blob_url, offset, length);
46 } 37 }
47 38
48 int64 BlobData::GetMemoryUsage() const { 39 int64 BlobData::GetMemoryUsage() const {
49 int64 memory = 0; 40 int64 memory = 0;
50 for (std::vector<Item>::const_iterator iter = items_.begin(); 41 for (std::vector<Item>::const_iterator iter = items_.begin();
51 iter != items_.end(); ++iter) { 42 iter != items_.end(); ++iter) {
52 if (iter->type == TYPE_DATA) 43 if (iter->type() == Item::TYPE_BYTES)
53 memory += iter->data.size(); 44 memory += iter->length();
54 } 45 }
55 return memory; 46 return memory;
56 } 47 }
57 48
58 } // namespace webkit_blob 49 } // 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