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

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

Issue 524983002: Move fileapi-related files from webkit/common/ to storage/common/ and set up redirect headers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix presubmit Created 6 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
« no previous file with comments | « webkit/common/blob/blob_data.h ('k') | webkit/common/blob/scoped_file.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "webkit/common/blob/blob_data.h"
6
7 #include "base/logging.h"
8 #include "base/strings/sys_string_conversions.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "base/time/time.h"
11
12 namespace storage {
13
14 BlobData::BlobData() {}
15 BlobData::BlobData(const std::string& uuid)
16 : uuid_(uuid) {
17 }
18
19 BlobData::~BlobData() {}
20
21 void BlobData::AppendData(const char* data, size_t length) {
22 DCHECK(length > 0);
23 items_.push_back(Item());
24 items_.back().SetToBytes(data, length);
25 }
26
27 void BlobData::AppendFile(const base::FilePath& file_path,
28 uint64 offset, uint64 length,
29 const base::Time& expected_modification_time) {
30 DCHECK(length > 0);
31 items_.push_back(Item());
32 items_.back().SetToFilePathRange(file_path, offset, length,
33 expected_modification_time);
34 }
35
36 void BlobData::AppendBlob(const std::string& uuid,
37 uint64 offset, uint64 length) {
38 DCHECK_GT(length, 0ul);
39 items_.push_back(Item());
40 items_.back().SetToBlobRange(uuid, offset, length);
41 }
42
43 void BlobData::AppendFileSystemFile(
44 const GURL& url, uint64 offset,
45 uint64 length,
46 const base::Time& expected_modification_time) {
47 DCHECK(length > 0);
48 items_.push_back(Item());
49 items_.back().SetToFileSystemUrlRange(url, offset, length,
50 expected_modification_time);
51 }
52
53 int64 BlobData::GetMemoryUsage() const {
54 int64 memory = 0;
55 for (std::vector<Item>::const_iterator iter = items_.begin();
56 iter != items_.end(); ++iter) {
57 if (iter->type() == Item::TYPE_BYTES)
58 memory += iter->length();
59 }
60 return memory;
61 }
62
63 } // namespace storage
OLDNEW
« no previous file with comments | « webkit/common/blob/blob_data.h ('k') | webkit/common/blob/scoped_file.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698