| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_ITUNES_DATA_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_ITUNES_DATA_PROVIDER_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <set> |
| 10 #include <string> |
| 11 |
| 12 #include "base/basictypes.h" |
| 13 #include "base/callback.h" |
| 14 #include "base/files/file_path.h" |
| 15 #include "chrome/browser/media_galleries/fileapi/itunes_library_parser.h" |
| 16 |
| 17 namespace itunes { |
| 18 |
| 19 class ITunesDataProvider { |
| 20 public: |
| 21 typedef std::string TrackName; |
| 22 typedef std::string AlbumName; |
| 23 typedef std::string ArtistName; |
| 24 |
| 25 explicit ITunesDataProvider(const base::FilePath& library_path); |
| 26 virtual ~ITunesDataProvider(); |
| 27 |
| 28 // Ask the data provider to refresh the data if necessary. |ready_callback| |
| 29 // will be called when the data is up to date. |
| 30 void RefreshData(const base::Closure& ready_callback); |
| 31 |
| 32 // Get the platform path for the library xml file. |
| 33 base::FilePath library_path() const; |
| 34 |
| 35 // Returns true if |artist| exists in the library. |
| 36 bool KnownArtist(const ArtistName& artist) const; |
| 37 |
| 38 // Returns true if |artist| has an album by the name |album| in the library. |
| 39 bool KnownAlbum(const ArtistName& artist, const AlbumName& album) const; |
| 40 |
| 41 // Get the track named (filename basename) |track| in |album| by |artist|. |
| 42 bool GetTrackLocation(const ArtistName& artist, const AlbumName& album, |
| 43 const TrackName& track, base::FilePath* result) const; |
| 44 |
| 45 // Get the set of artists. |
| 46 std::set<ArtistName> GetArtists() const; |
| 47 |
| 48 // Get the set of albums for |artist|. |
| 49 std::set<AlbumName> GetAlbums(const ArtistName& artist) const; |
| 50 |
| 51 // Get the tracks for the |album| by |artist|. |
| 52 std::map<TrackName, base::FilePath> GetTracks(const ArtistName& artist, |
| 53 const AlbumName& album) const; |
| 54 |
| 55 private: |
| 56 typedef std::map<TrackName, base::FilePath> Album; |
| 57 typedef std::map<AlbumName, Album> Artist; |
| 58 typedef std::map<ArtistName, Artist> Library; |
| 59 |
| 60 static Album MakeUniqueTrackNames(const ITunesLibraryParser::Album& album); |
| 61 |
| 62 void ParseLibrary(); |
| 63 |
| 64 base::FilePath library_path_; |
| 65 |
| 66 Library library_; |
| 67 |
| 68 bool needs_refresh_; |
| 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(ITunesDataProvider); |
| 71 }; |
| 72 |
| 73 } // namespace itunes |
| 74 |
| 75 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_ITUNES_DATA_PROVIDER_H_ |
| OLD | NEW |