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: storage/common/data_element.cc

Issue 1288373002: [BlobAsync] Patch 2: Common Constants (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@async1
Patch Set: comments Created 5 years, 1 month 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 | « storage/common/data_element.h ('k') | storage/storage_common.gyp » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "storage/common/data_element.h" 5 #include "storage/common/data_element.h"
6 6
7 #include <algorithm>
8
9 #include "base/strings/string_number_conversions.h"
10
7 namespace storage { 11 namespace storage {
8 12
9 DataElement::DataElement() 13 DataElement::DataElement()
10 : type_(TYPE_UNKNOWN), 14 : type_(TYPE_UNKNOWN),
11 bytes_(NULL), 15 bytes_(NULL),
12 offset_(0), 16 offset_(0),
13 length_(kuint64max) { 17 length_(kuint64max) {
14 } 18 }
15 19
16 DataElement::~DataElement() {} 20 DataElement::~DataElement() {}
(...skipping 28 matching lines...) Expand all
45 length_ = length; 49 length_ = length;
46 expected_modification_time_ = expected_modification_time; 50 expected_modification_time_ = expected_modification_time;
47 } 51 }
48 52
49 void DataElement::SetToDiskCacheEntryRange(uint64 offset, uint64 length) { 53 void DataElement::SetToDiskCacheEntryRange(uint64 offset, uint64 length) {
50 type_ = TYPE_DISK_CACHE_ENTRY; 54 type_ = TYPE_DISK_CACHE_ENTRY;
51 offset_ = offset; 55 offset_ = offset;
52 length_ = length; 56 length_ = length;
53 } 57 }
54 58
59 void PrintTo(const DataElement& x, std::ostream* os) {
60 const uint64 kMaxDataPrintLength = 40;
61 *os << "<DataElement>{type: ";
62 switch (x.type()) {
63 case DataElement::TYPE_BYTES: {
64 uint64 length = std::min(x.length(), kMaxDataPrintLength);
65 *os << "TYPE_BYTES, data: ["
66 << base::HexEncode(x.bytes(), static_cast<size_t>(length));
67 if (length < x.length()) {
68 *os << "<...truncated due to length...>";
69 }
70 *os << "]";
71 break;
72 }
73 case DataElement::TYPE_FILE:
74 *os << "TYPE_FILE, path: " << x.path().AsUTF8Unsafe()
75 << ", expected_modification_time: " << x.expected_modification_time();
76 break;
77 case DataElement::TYPE_BLOB:
78 *os << "TYPE_BLOB, uuid: " << x.blob_uuid();
79 break;
80 case DataElement::TYPE_FILE_FILESYSTEM:
81 *os << "TYPE_FILE_FILESYSTEM, filesystem_url: " << x.filesystem_url();
82 break;
83 case DataElement::TYPE_DISK_CACHE_ENTRY:
84 *os << "TYPE_DISK_CACHE_ENTRY";
85 break;
86 case DataElement::TYPE_BYTES_DESCRIPTION:
87 *os << "TYPE_BYTES_DESCRIPTION";
88 break;
89 case DataElement::TYPE_UNKNOWN:
90 *os << "TYPE_UNKNOWN";
91 break;
92 }
93 *os << ", length: " << x.length() << ", offset: " << x.offset() << "}";
94 }
95
55 } // namespace storage 96 } // namespace storage
OLDNEW
« no previous file with comments | « storage/common/data_element.h ('k') | storage/storage_common.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698