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

Side by Side Diff: chrome/utility/media_galleries/itunes_library_parser.cc

Issue 1548153002: Switch to standard integer types in chrome/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
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 "chrome/utility/media_galleries/itunes_library_parser.h" 5 #include "chrome/utility/media_galleries/itunes_library_parser.h"
6 6
7 #include <stdint.h>
8
7 #include <string> 9 #include <string>
8 10
9 #include "base/logging.h" 11 #include "base/logging.h"
10 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
11 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "build/build_config.h"
13 #include "chrome/utility/media_galleries/iapps_xml_utils.h" 16 #include "chrome/utility/media_galleries/iapps_xml_utils.h"
14 #include "third_party/libxml/chromium/libxml_utils.h" 17 #include "third_party/libxml/chromium/libxml_utils.h"
15 #include "url/gurl.h" 18 #include "url/gurl.h"
16 #include "url/url_canon.h" 19 #include "url/url_canon.h"
17 #include "url/url_util.h" 20 #include "url/url_util.h"
18 21
19 namespace itunes { 22 namespace itunes {
20 23
21 namespace { 24 namespace {
22 25
23 struct TrackInfo { 26 struct TrackInfo {
24 uint64 id; 27 uint64_t id;
25 base::FilePath location; 28 base::FilePath location;
26 std::string artist; 29 std::string artist;
27 std::string album; 30 std::string album;
28 }; 31 };
29 32
30 class TrackInfoXmlDictReader : public iapps::XmlDictReader { 33 class TrackInfoXmlDictReader : public iapps::XmlDictReader {
31 public: 34 public:
32 TrackInfoXmlDictReader(XmlReader* reader, TrackInfo* track_info) : 35 TrackInfoXmlDictReader(XmlReader* reader, TrackInfo* track_info) :
33 iapps::XmlDictReader(reader), track_info_(track_info) {} 36 iapps::XmlDictReader(reader), track_info_(track_info) {}
34 37
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // Once parsing has gotten this far, return whatever is found, even if 131 // Once parsing has gotten this far, return whatever is found, even if
129 // some of the data isn't extracted just right. 132 // some of the data isn't extracted just right.
130 bool no_errors = true; 133 bool no_errors = true;
131 bool track_found = false; 134 bool track_found = false;
132 while (reader.Depth() >= tracks_dict_depth) { 135 while (reader.Depth() >= tracks_dict_depth) {
133 if (!iapps::SeekToNodeAtCurrentDepth(&reader, "key")) 136 if (!iapps::SeekToNodeAtCurrentDepth(&reader, "key"))
134 return track_found; 137 return track_found;
135 std::string key; // Should match track id below. 138 std::string key; // Should match track id below.
136 if (!reader.ReadElementContent(&key)) 139 if (!reader.ReadElementContent(&key))
137 return track_found; 140 return track_found;
138 uint64 id; 141 uint64_t id;
139 bool id_valid = base::StringToUint64(key, &id); 142 bool id_valid = base::StringToUint64(key, &id);
140 if (!reader.SkipToElement()) 143 if (!reader.SkipToElement())
141 return track_found; 144 return track_found;
142 145
143 TrackInfo track_info; 146 TrackInfo track_info;
144 if (GetTrackInfoFromDict(&reader, &track_info) && 147 if (GetTrackInfoFromDict(&reader, &track_info) &&
145 id_valid && 148 id_valid &&
146 id == track_info.id) { 149 id == track_info.id) {
147 if (track_info.artist.empty()) 150 if (track_info.artist.empty())
148 track_info.artist = "Unknown Artist"; 151 track_info.artist = "Unknown Artist";
149 if (track_info.album.empty()) 152 if (track_info.album.empty())
150 track_info.album = "Unknown Album"; 153 track_info.album = "Unknown Album";
151 parser::Track track(track_info.id, track_info.location); 154 parser::Track track(track_info.id, track_info.location);
152 library_[track_info.artist][track_info.album].insert(track); 155 library_[track_info.artist][track_info.album].insert(track);
153 track_found = true; 156 track_found = true;
154 } else { 157 } else {
155 no_errors = false; 158 no_errors = false;
156 } 159 }
157 } 160 }
158 161
159 return track_found || no_errors; 162 return track_found || no_errors;
160 } 163 }
161 164
162 } // namespace itunes 165 } // namespace itunes
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698