OLD | NEW |
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 "chrome/utility/media_galleries/iapps_xml_utils.h" | 5 #include "chrome/utility/media_galleries/iapps_xml_utils.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "third_party/libxml/chromium/libxml_utils.h" | 10 #include "third_party/libxml/chromium/libxml_utils.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 return false; | 63 return false; |
64 if (reader->NodeName() != node_name) | 64 if (reader->NodeName() != node_name) |
65 return false; | 65 return false; |
66 return reader->ReadElementContent(result); | 66 return reader->ReadElementContent(result); |
67 } | 67 } |
68 | 68 |
69 bool ReadString(XmlReader* reader, std::string* result) { | 69 bool ReadString(XmlReader* reader, std::string* result) { |
70 return ReadSimpleValue(reader, "string", result); | 70 return ReadSimpleValue(reader, "string", result); |
71 } | 71 } |
72 | 72 |
73 bool ReadInteger(XmlReader* reader, uint64* result) { | 73 bool ReadInteger(XmlReader* reader, uint64_t* result) { |
74 std::string value; | 74 std::string value; |
75 if (!ReadSimpleValue(reader, "integer", &value)) | 75 if (!ReadSimpleValue(reader, "integer", &value)) |
76 return false; | 76 return false; |
77 return base::StringToUint64(value, result); | 77 return base::StringToUint64(value, result); |
78 } | 78 } |
79 | 79 |
80 std::string ReadFileAsString(base::File file) { | 80 std::string ReadFileAsString(base::File file) { |
81 std::string result; | 81 std::string result; |
82 if (!file.IsValid()) | 82 if (!file.IsValid()) |
83 return result; | 83 return result; |
84 | 84 |
85 // A "reasonable" artificial limit. | 85 // A "reasonable" artificial limit. |
86 // TODO(vandebo): Add a UMA to figure out what common values are. | 86 // TODO(vandebo): Add a UMA to figure out what common values are. |
87 const int64 kMaxLibraryFileSize = 150 * 1024 * 1024; | 87 const int64_t kMaxLibraryFileSize = 150 * 1024 * 1024; |
88 base::File::Info file_info; | 88 base::File::Info file_info; |
89 if (!file.GetInfo(&file_info) || file_info.size > kMaxLibraryFileSize) | 89 if (!file.GetInfo(&file_info) || file_info.size > kMaxLibraryFileSize) |
90 return result; | 90 return result; |
91 | 91 |
92 result.resize(file_info.size); | 92 result.resize(file_info.size); |
93 int bytes_read = file.Read(0, string_as_array(&result), file_info.size); | 93 int bytes_read = file.Read(0, string_as_array(&result), file_info.size); |
94 if (bytes_read != file_info.size) | 94 if (bytes_read != file_info.size) |
95 result.clear(); | 95 result.clear(); |
96 | 96 |
97 return result; | 97 return result; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 151 |
152 bool XmlDictReader::SkipToNext() { | 152 bool XmlDictReader::SkipToNext() { |
153 return SkipToNextElement(reader_) && reader_->Next(); | 153 return SkipToNextElement(reader_) && reader_->Next(); |
154 } | 154 } |
155 | 155 |
156 bool XmlDictReader::Found(const std::string& key) const { | 156 bool XmlDictReader::Found(const std::string& key) const { |
157 return ContainsKey(found_, key); | 157 return ContainsKey(found_, key); |
158 } | 158 } |
159 | 159 |
160 } // namespace iapps | 160 } // namespace iapps |
OLD | NEW |