| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_t 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, base::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; |
| 98 } | 98 } |
| 99 | 99 |
| 100 XmlDictReader::XmlDictReader(XmlReader* reader) : reader_(reader) {} | 100 XmlDictReader::XmlDictReader(XmlReader* reader) : reader_(reader) {} |
| 101 | 101 |
| 102 XmlDictReader::~XmlDictReader() {} | 102 XmlDictReader::~XmlDictReader() {} |
| 103 | 103 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 147 |
| 148 bool XmlDictReader::FinishedOk() { | 148 bool XmlDictReader::FinishedOk() { |
| 149 return true; | 149 return true; |
| 150 } | 150 } |
| 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 base::ContainsKey(found_, key); |
| 158 } | 158 } |
| 159 | 159 |
| 160 } // namespace iapps | 160 } // namespace iapps |
| OLD | NEW |