| 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 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_ITUNES_DATA_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_ITUNES_DATA_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_ITUNES_DATA_PROVIDER_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_ITUNES_DATA_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // methods to access it. When the file changes, it will update the data. | 25 // methods to access it. When the file changes, it will update the data. |
| 26 // It is not thread safe, but can be run on any thread with IO access. | 26 // It is not thread safe, but can be run on any thread with IO access. |
| 27 class ITunesDataProvider : public iapps::IAppsDataProvider { | 27 class ITunesDataProvider : public iapps::IAppsDataProvider { |
| 28 public: | 28 public: |
| 29 typedef std::string ArtistName; | 29 typedef std::string ArtistName; |
| 30 typedef std::string AlbumName; | 30 typedef std::string AlbumName; |
| 31 typedef std::string TrackName; | 31 typedef std::string TrackName; |
| 32 typedef std::map<TrackName, base::FilePath> Album; | 32 typedef std::map<TrackName, base::FilePath> Album; |
| 33 | 33 |
| 34 explicit ITunesDataProvider(const base::FilePath& library_path); | 34 explicit ITunesDataProvider(const base::FilePath& library_path); |
| 35 virtual ~ITunesDataProvider(); | 35 ~ITunesDataProvider() override; |
| 36 | 36 |
| 37 // Get the platform path for the auto-add directory. | 37 // Get the platform path for the auto-add directory. |
| 38 virtual const base::FilePath& auto_add_path() const; | 38 virtual const base::FilePath& auto_add_path() const; |
| 39 | 39 |
| 40 // Returns true if |artist| exists in the library. | 40 // Returns true if |artist| exists in the library. |
| 41 bool KnownArtist(const ArtistName& artist) const; | 41 bool KnownArtist(const ArtistName& artist) const; |
| 42 | 42 |
| 43 // Returns true if |artist| has an album by the name |album| in the library. | 43 // Returns true if |artist| has an album by the name |album| in the library. |
| 44 bool KnownAlbum(const ArtistName& artist, const AlbumName& album) const; | 44 bool KnownAlbum(const ArtistName& artist, const AlbumName& album) const; |
| 45 | 45 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 58 // Get the tracks for the |album| by |artist|. | 58 // Get the tracks for the |album| by |artist|. |
| 59 Album GetAlbum(const ArtistName& artist, const AlbumName& album) const; | 59 Album GetAlbum(const ArtistName& artist, const AlbumName& album) const; |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 friend class TestITunesDataProvider; | 62 friend class TestITunesDataProvider; |
| 63 | 63 |
| 64 typedef std::map<AlbumName, Album> Artist; | 64 typedef std::map<AlbumName, Album> Artist; |
| 65 typedef std::map<ArtistName, Artist> Library; | 65 typedef std::map<ArtistName, Artist> Library; |
| 66 | 66 |
| 67 // Parse the library xml file. | 67 // Parse the library xml file. |
| 68 virtual void DoParseLibrary(const base::FilePath& library_path, | 68 void DoParseLibrary(const base::FilePath& library_path, |
| 69 const ReadyCallback& ready_callback) override; | 69 const ReadyCallback& ready_callback) override; |
| 70 | 70 |
| 71 // Called when the utility process finishes parsing the library XML file. | 71 // Called when the utility process finishes parsing the library XML file. |
| 72 void OnLibraryParsed(const ReadyCallback& ready_callback, | 72 void OnLibraryParsed(const ReadyCallback& ready_callback, |
| 73 bool result, | 73 bool result, |
| 74 const parser::Library& library); | 74 const parser::Library& library); |
| 75 | 75 |
| 76 // Path to the auto-add directory. | 76 // Path to the auto-add directory. |
| 77 const base::FilePath auto_add_path_; | 77 const base::FilePath auto_add_path_; |
| 78 | 78 |
| 79 // The parsed and uniquified data. | 79 // The parsed and uniquified data. |
| 80 Library library_; | 80 Library library_; |
| 81 | 81 |
| 82 scoped_refptr<iapps::SafeIAppsLibraryParser> xml_parser_; | 82 scoped_refptr<iapps::SafeIAppsLibraryParser> xml_parser_; |
| 83 | 83 |
| 84 // Hides parent class member, but it is private, and there's no way to get a | 84 // Hides parent class member, but it is private, and there's no way to get a |
| 85 // WeakPtr<Derived> from a WeakPtr<Base> without using SupportsWeakPtr. | 85 // WeakPtr<Derived> from a WeakPtr<Base> without using SupportsWeakPtr. |
| 86 base::WeakPtrFactory<ITunesDataProvider> weak_factory_; | 86 base::WeakPtrFactory<ITunesDataProvider> weak_factory_; |
| 87 | 87 |
| 88 DISALLOW_COPY_AND_ASSIGN(ITunesDataProvider); | 88 DISALLOW_COPY_AND_ASSIGN(ITunesDataProvider); |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 } // namespace itunes | 91 } // namespace itunes |
| 92 | 92 |
| 93 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_ITUNES_DATA_PROVIDER_H_ | 93 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_ITUNES_DATA_PROVIDER_H_ |
| OLD | NEW |