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

Side by Side Diff: chrome/browser/media_galleries/fileapi/itunes_xml_utils.cc

Issue 16231016: Extract track information from iTunes library xml file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win test Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/media_galleries/fileapi/itunes_xml_utils.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/media_galleries/fileapi/itunes_xml_utils.h"
6 #include <string>
7
8 #include "base/logging.h"
9 #include "third_party/libxml/chromium/libxml_utils.h"
10
11 namespace itunes {
12
13 bool SkipToNextElement(XmlReader* reader) {
14 if (!reader->SkipToElement()) {
15 // SkipToElement returns false if the current node is an end element,
16 // try to advance to the next element and then try again.
17 if (!reader->Read() || !reader->SkipToElement())
18 return false;
19 }
20 return true;
21 }
22
23 bool SeekToNodeAtCurrentDepth(XmlReader* reader, const std::string& name) {
24 int depth = reader->Depth();
25 do {
26 if (!SkipToNextElement(reader))
27 return false;
28 DCHECK_EQ(depth, reader->Depth());
29 if (reader->NodeName() == name)
30 return true;
31 } while (reader->Next());
32
33 return false;
34 }
35
36 bool SeekInDict(XmlReader* reader, const std::string& key) {
37 DCHECK_EQ("dict", reader->NodeName());
38
39 int dict_content_depth = reader->Depth() + 1;
40 // Advance past the dict node and into the body of the dictionary.
41 if (!reader->Read())
42 return false;
43
44 while (reader->Depth() >= dict_content_depth) {
45 if (!SeekToNodeAtCurrentDepth(reader, "key"))
46 return false;
47 std::string found_key;
48 if (!reader->ReadElementContent(&found_key))
49 return false;
50 DCHECK_EQ(dict_content_depth, reader->Depth());
51 if (found_key == key)
52 return true;
53 }
54 return false;
55 }
56
57 } // namespace itunes
OLDNEW
« no previous file with comments | « chrome/browser/media_galleries/fileapi/itunes_xml_utils.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698