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

Side by Side Diff: storage/common/data_element.cc

Issue 1502503004: Remove kuint64max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kint8
Patch Set: rebase Created 5 years 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
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> 7 #include <algorithm>
8 8
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 10
11 namespace storage { 11 namespace storage {
12 12
13 DataElement::DataElement() 13 DataElement::DataElement()
14 : type_(TYPE_UNKNOWN), 14 : type_(TYPE_UNKNOWN),
15 bytes_(NULL), 15 bytes_(NULL),
16 offset_(0), 16 offset_(0),
17 length_(kuint64max) { 17 length_(std::numeric_limits<uint64_t>::max()) {}
18 }
19 18
20 DataElement::~DataElement() {} 19 DataElement::~DataElement() {}
21 20
22 void DataElement::SetToFilePathRange( 21 void DataElement::SetToFilePathRange(
23 const base::FilePath& path, 22 const base::FilePath& path,
24 uint64 offset, uint64 length, 23 uint64_t offset,
24 uint64_t length,
25 const base::Time& expected_modification_time) { 25 const base::Time& expected_modification_time) {
26 type_ = TYPE_FILE; 26 type_ = TYPE_FILE;
27 path_ = path; 27 path_ = path;
28 offset_ = offset; 28 offset_ = offset;
29 length_ = length; 29 length_ = length;
30 expected_modification_time_ = expected_modification_time; 30 expected_modification_time_ = expected_modification_time;
31 } 31 }
32 32
33 void DataElement::SetToBlobRange( 33 void DataElement::SetToBlobRange(const std::string& blob_uuid,
34 const std::string& blob_uuid, 34 uint64_t offset,
35 uint64 offset, uint64 length) { 35 uint64_t length) {
36 type_ = TYPE_BLOB; 36 type_ = TYPE_BLOB;
37 blob_uuid_ = blob_uuid; 37 blob_uuid_ = blob_uuid;
38 offset_ = offset; 38 offset_ = offset;
39 length_ = length; 39 length_ = length;
40 } 40 }
41 41
42 void DataElement::SetToFileSystemUrlRange( 42 void DataElement::SetToFileSystemUrlRange(
43 const GURL& filesystem_url, 43 const GURL& filesystem_url,
44 uint64 offset, uint64 length, 44 uint64_t offset,
45 uint64_t length,
45 const base::Time& expected_modification_time) { 46 const base::Time& expected_modification_time) {
46 type_ = TYPE_FILE_FILESYSTEM; 47 type_ = TYPE_FILE_FILESYSTEM;
47 filesystem_url_ = filesystem_url; 48 filesystem_url_ = filesystem_url;
48 offset_ = offset; 49 offset_ = offset;
49 length_ = length; 50 length_ = length;
50 expected_modification_time_ = expected_modification_time; 51 expected_modification_time_ = expected_modification_time;
51 } 52 }
52 53
53 void DataElement::SetToDiskCacheEntryRange(uint64 offset, uint64 length) { 54 void DataElement::SetToDiskCacheEntryRange(uint64_t offset, uint64_t length) {
54 type_ = TYPE_DISK_CACHE_ENTRY; 55 type_ = TYPE_DISK_CACHE_ENTRY;
55 offset_ = offset; 56 offset_ = offset;
56 length_ = length; 57 length_ = length;
57 } 58 }
58 59
59 void PrintTo(const DataElement& x, std::ostream* os) { 60 void PrintTo(const DataElement& x, std::ostream* os) {
60 const uint64 kMaxDataPrintLength = 40; 61 const uint64_t kMaxDataPrintLength = 40;
61 *os << "<DataElement>{type: "; 62 *os << "<DataElement>{type: ";
62 switch (x.type()) { 63 switch (x.type()) {
63 case DataElement::TYPE_BYTES: { 64 case DataElement::TYPE_BYTES: {
64 uint64 length = std::min(x.length(), kMaxDataPrintLength); 65 uint64_t length = std::min(x.length(), kMaxDataPrintLength);
65 *os << "TYPE_BYTES, data: [" 66 *os << "TYPE_BYTES, data: ["
66 << base::HexEncode(x.bytes(), static_cast<size_t>(length)); 67 << base::HexEncode(x.bytes(), static_cast<size_t>(length));
67 if (length < x.length()) { 68 if (length < x.length()) {
68 *os << "<...truncated due to length...>"; 69 *os << "<...truncated due to length...>";
69 } 70 }
70 *os << "]"; 71 *os << "]";
71 break; 72 break;
72 } 73 }
73 case DataElement::TYPE_FILE: 74 case DataElement::TYPE_FILE:
74 *os << "TYPE_FILE, path: " << x.path().AsUTF8Unsafe() 75 *os << "TYPE_FILE, path: " << x.path().AsUTF8Unsafe()
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 return false; 119 return false;
119 } 120 }
120 return false; 121 return false;
121 } 122 }
122 123
123 bool operator!=(const DataElement& a, const DataElement& b) { 124 bool operator!=(const DataElement& a, const DataElement& b) {
124 return !(a == b); 125 return !(a == b);
125 } 126 }
126 127
127 } // namespace storage 128 } // namespace storage
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698