| 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_UTILITY_MEDIA_GALLERIES_PICASA_ALBUMS_INDEXER_H_ | 5 #ifndef CHROME_UTILITY_MEDIA_GALLERIES_PICASA_ALBUMS_INDEXER_H_ |
| 6 #define CHROME_UTILITY_MEDIA_GALLERIES_PICASA_ALBUMS_INDEXER_H_ | 6 #define CHROME_UTILITY_MEDIA_GALLERIES_PICASA_ALBUMS_INDEXER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "chrome/common/media_galleries/picasa_types.h" |
| 13 | 14 |
| 14 namespace picasa { | 15 namespace picasa { |
| 15 | 16 |
| 16 // Defined outside of class because used by IPC messages. | |
| 17 typedef std::set<base::FilePath> AlbumImages; | |
| 18 typedef std::set<std::string> AlbumUUIDSet; | |
| 19 typedef std::map<std::string, AlbumImages> AlbumImagesMap; | |
| 20 | |
| 21 // Parses a series of INI files and builds up the set of files contained within | 17 // Parses a series of INI files and builds up the set of files contained within |
| 22 // the albums passed in through |album_uuids|. | 18 // the albums passed in through |album_uids|. |
| 23 // | 19 // |
| 24 // Each INI file only describes the images contained within a single directory. | 20 // Each INI file only describes the images contained within a single directory. |
| 25 // To build the contents of all the albums, we read in all the INI files | 21 // To build the contents of all the albums, we read in all the INI files |
| 26 // in all the Picasa folders. | 22 // in all the Picasa folders. |
| 27 // | 23 // |
| 28 // The INI albums also contain ".album*" sections describing the albums that | 24 // The INI albums also contain ".album*" sections describing the albums that |
| 29 // have pictures in the same directory as the INI. However, we use the PMP | 25 // have pictures in the same directory as the INI. However, we use the PMP |
| 30 // database as the authoritative source on Album metadata, so we ignore those | 26 // database as the authoritative source on Album metadata, so we ignore those |
| 31 // sections. The PMP derived |album_uuids| are passed in by the constructor. | 27 // sections. The PMP derived |album_uids| are passed in by the constructor. |
| 32 // | 28 // |
| 33 // Example INI File: | 29 // Example INI File: |
| 34 // | 30 // |
| 35 // [.album:e66fb059001aabcc69b262b7009fad90] | 31 // [.album:e66fb059001aabcc69b262b7009fad90] |
| 36 // name=CustomAlbum1 | 32 // name=CustomAlbum1 |
| 37 // token=e66fb059001aabcc69b262b7009fad90 | 33 // token=e66fb059001aabcc69b262b7009fad90 |
| 38 // date=2013-03-15T14:53:21-07:00 | 34 // date=2013-03-15T14:53:21-07:00 |
| 39 // [InBoth.jpg] | 35 // [InBoth.jpg] |
| 40 // albums=e66fb059001aabcc69b262b7009fad90,18cb2df48aaa98e1c276b45cfcd81c95 | 36 // albums=e66fb059001aabcc69b262b7009fad90,18cb2df48aaa98e1c276b45cfcd81c95 |
| 41 // [.album:18cb2df48aaa98e1c276b45cfcd81c95] | 37 // [.album:18cb2df48aaa98e1c276b45cfcd81c95] |
| 42 // name=CustomAlbum1 | 38 // name=CustomAlbum1 |
| 43 // token=18cb2df48aaa98e1c276b45cfcd81c95 | 39 // token=18cb2df48aaa98e1c276b45cfcd81c95 |
| 44 // date=2013-04-01T16:37:34-07:00 | 40 // date=2013-04-01T16:37:34-07:00 |
| 45 // [InFirst.jpg] | 41 // [InFirst.jpg] |
| 46 // albums=e66fb059001aabcc69b262b7009fad90 | 42 // albums=e66fb059001aabcc69b262b7009fad90 |
| 47 // [InSecond.jpg] | 43 // [InSecond.jpg] |
| 48 // albums=18cb2df48aaa98e1c276b45cfcd81c95 | 44 // albums=18cb2df48aaa98e1c276b45cfcd81c95 |
| 49 class PicasaAlbumsIndexer { | 45 class PicasaAlbumsIndexer { |
| 50 public: | 46 public: |
| 51 explicit PicasaAlbumsIndexer(const AlbumUUIDSet& album_uuids); | 47 explicit PicasaAlbumsIndexer(const AlbumUIDSet& album_uids); |
| 52 ~PicasaAlbumsIndexer(); | 48 ~PicasaAlbumsIndexer(); |
| 53 | 49 |
| 54 // This method should be called once for each Folder in the PMP database. | 50 // This method should be called once for each Folder in the PMP database. |
| 55 void ParseFolderINI(const base::FilePath& folder_path, | 51 void ParseFolderINI(const base::FilePath& folder_path, |
| 56 const std::string& ini_contents); | 52 const std::string& ini_contents); |
| 57 | 53 |
| 58 const AlbumImagesMap& albums_images() const { return albums_images_; } | 54 const AlbumImagesMap& albums_images() const { return albums_images_; } |
| 59 | 55 |
| 60 private: | 56 private: |
| 61 AlbumImagesMap albums_images_; | 57 AlbumImagesMap albums_images_; |
| 62 | 58 |
| 63 DISALLOW_COPY_AND_ASSIGN(PicasaAlbumsIndexer); | 59 DISALLOW_COPY_AND_ASSIGN(PicasaAlbumsIndexer); |
| 64 }; | 60 }; |
| 65 | 61 |
| 66 } // namespace picasa | 62 } // namespace picasa |
| 67 | 63 |
| 68 #endif // CHROME_UTILITY_MEDIA_GALLERIES_PICASA_ALBUMS_INDEXER_H_ | 64 #endif // CHROME_UTILITY_MEDIA_GALLERIES_PICASA_ALBUMS_INDEXER_H_ |
| OLD | NEW |