Chromium Code Reviews| 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" | |
|
Lei Zhang
2013/06/06 03:48:47
base/callback_forward.h instead?
vandebo (ex-Chrome)
2013/06/06 19:49:18
Done.
| |
| 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 { | |
|
Lei Zhang
2013/06/06 03:48:47
Needs some comment to explain what this does.
Lei Zhang
2013/06/06 09:58:54
Like, for instance, what thread does this run on?
vandebo (ex-Chrome)
2013/06/06 19:49:18
Done.
vandebo (ex-Chrome)
2013/06/06 19:49:18
It doesn't really care which thread it's on. Ther
| |
| 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(); | |
|
Lei Zhang
2013/06/06 03:48:47
no virtual
vandebo (ex-Chrome)
2013/06/06 19:49:18
Done.
| |
| 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; | |
|
Lei Zhang
2013/06/06 03:48:47
return const ref.
vandebo (ex-Chrome)
2013/06/06 19:49:18
Done.
| |
| 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, | |
|
Lei Zhang
2013/06/06 03:48:47
Just return an empty FilePath on failure?
vandebo (ex-Chrome)
2013/06/06 19:49:18
Done.
| |
| 43 const TrackName& track, base::FilePath* result) const; | |
| 44 | |
| 45 // Get the set of artists. | |
| 46 std::set<ArtistName> GetArtists() const; | |
|
Lei Zhang
2013/06/06 09:58:54
How about GetArtistNames, GetAlbumNames, and GetAl
vandebo (ex-Chrome)
2013/06/06 19:49:18
Done.
| |
| 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); | |
|
Lei Zhang
2013/06/06 03:48:47
Put this in the anonymous namespace instead?
vandebo (ex-Chrome)
2013/06/06 19:49:18
I started there, but Album was not public and it m
| |
| 61 | |
| 62 void ParseLibrary(); | |
| 63 | |
| 64 base::FilePath library_path_; | |
|
Lei Zhang
2013/06/06 03:48:47
const
vandebo (ex-Chrome)
2013/06/06 19:49:18
Done.
| |
| 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 |