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

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

Issue 11410019: ********** Chromium Blob hacking (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 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_context.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) 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::BlobData() {} 14 BlobData::BlobData(const std::string& uuid)
15 : uuid_(uuid) {
16 }
15 17
16 BlobData::~BlobData() {} 18 BlobData::~BlobData() {}
17 19
18 void BlobData::AppendData(const char* data, size_t length) { 20 void BlobData::AppendData(const char* data, size_t length) {
19 DCHECK(length > 0); 21 DCHECK(length > 0);
20 items_.push_back(Item()); 22 items_.push_back(Item());
21 items_.back().SetToBytes(data, length); 23 items_.back().SetToBytes(data, length);
22 } 24 }
23 25
24 void BlobData::AppendFile(const base::FilePath& file_path, 26 void BlobData::AppendFile(const base::FilePath& file_path,
25 uint64 offset, uint64 length, 27 uint64 offset, uint64 length,
26 const base::Time& expected_modification_time) { 28 const base::Time& expected_modification_time) {
27 DCHECK(length > 0); 29 DCHECK(length > 0);
28 items_.push_back(Item()); 30 items_.push_back(Item());
29 items_.back().SetToFilePathRange(file_path, offset, length, 31 items_.back().SetToFilePathRange(file_path, offset, length,
30 expected_modification_time); 32 expected_modification_time);
31 } 33 }
32 34
33 void BlobData::AppendBlob(const GURL& blob_url, uint64 offset, uint64 length) { 35 void BlobData::AppendBlob(
36 const std::string& uuid, uint64 offset, uint64 length) {
34 DCHECK(length > 0); 37 DCHECK(length > 0);
35 items_.push_back(Item()); 38 items_.push_back(Item());
36 items_.back().SetToBlobUrlRange(blob_url, offset, length); 39 items_.back().SetToBlobRange(uuid, offset, length);
37 } 40 }
38 41
39 void BlobData::AppendFileSystemFile( 42 void BlobData::AppendFileSystemFile(
40 const GURL& url, uint64 offset, 43 const GURL& url, uint64 offset,
41 uint64 length, 44 uint64 length,
42 const base::Time& expected_modification_time) { 45 const base::Time& expected_modification_time) {
43 DCHECK(length > 0); 46 DCHECK(length > 0);
44 items_.push_back(Item()); 47 items_.push_back(Item());
45 items_.back().SetToFileSystemUrlRange(url, offset, length, 48 items_.back().SetToFileSystemUrlRange(url, offset, length,
46 expected_modification_time); 49 expected_modification_time);
47 } 50 }
48 51
49 int64 BlobData::GetMemoryUsage() const { 52 int64 BlobData::GetMemoryUsage() const {
50 int64 memory = 0; 53 int64 memory = 0;
51 for (std::vector<Item>::const_iterator iter = items_.begin(); 54 for (std::vector<Item>::const_iterator iter = items_.begin();
52 iter != items_.end(); ++iter) { 55 iter != items_.end(); ++iter) {
53 if (iter->type() == Item::TYPE_BYTES) 56 if (iter->type() == Item::TYPE_BYTES)
54 memory += iter->length(); 57 memory += iter->length();
55 } 58 }
56 return memory; 59 return memory;
57 } 60 }
58 61
59 } // namespace webkit_blob 62 } // namespace webkit_blob
OLDNEW
« no previous file with comments | « webkit/blob/blob_data.h ('k') | webkit/blob/blob_storage_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698