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_PICASA_PICASA_DATA_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_PICASA_PICASA_DATA_PROVIDER_H_ |
6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_PICASA_PICASA_DATA_PROVIDER_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_PICASA_PICASA_DATA_PROVIDER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "chrome/common/media_galleries/picasa_types.h" | 18 #include "chrome/common/media_galleries/picasa_types.h" |
19 | 19 |
20 namespace picasa { | 20 namespace picasa { |
21 | 21 |
22 struct AlbumInfo; | |
23 class SafePicasaAlbumTableReader; | 22 class SafePicasaAlbumTableReader; |
24 | 23 |
25 typedef std::map<std::string, AlbumInfo> AlbumMap; | |
26 | |
27 // Created and owned by ImportedMediaGalleryRegistryTaskRunnerValues | 24 // Created and owned by ImportedMediaGalleryRegistryTaskRunnerValues |
28 class PicasaDataProvider { | 25 class PicasaDataProvider { |
29 public: | 26 public: |
30 explicit PicasaDataProvider(const base::FilePath& database_path); | 27 explicit PicasaDataProvider(const base::FilePath& database_path); |
31 virtual ~PicasaDataProvider(); | 28 virtual ~PicasaDataProvider(); |
32 | 29 |
33 // Ask the data provider to refresh the data if necessary. |ready_callback| | 30 // Ask the data provider to refresh the data if necessary. |ready_callback| |
34 // will be called when the data is up to date | 31 // will be called when the data is up to date |
35 // TODO(tommycli): Investigate having the callback return a bool indicating | 32 // TODO(tommycli): Investigate having the callback return a bool indicating |
36 // success or failure - and handling it intelligently in PicasaFileUtil. | 33 // success or failure - and handling it intelligently in PicasaFileUtil. |
37 void RefreshData(const base::Closure& ready_callback); | 34 void RefreshData(const base::Closure& ready_callback); |
38 | 35 |
39 scoped_ptr<AlbumMap> GetAlbums(); | 36 scoped_ptr<AlbumMap> GetAlbums(); |
40 scoped_ptr<AlbumMap> GetFolders(); | 37 scoped_ptr<AlbumMap> GetFolders(); |
41 // TODO(tommycli): Implement album contents. GetAlbumContents(...) | 38 // TODO(tommycli): Implement album contents. GetAlbumContents(...) |
42 | 39 |
43 protected: | 40 protected: |
44 // Protected for test class usage. | 41 // Protected for test class usage. |
45 void OnDataRefreshed(const base::Closure& ready_callback, | 42 void OnDataRefreshed(const base::Closure& ready_callback, |
46 bool parse_success, const std::vector<AlbumInfo>& albums, | 43 bool parse_success, const std::vector<AlbumInfo>& albums, |
vandebo (ex-Chrome)
2013/07/10 19:54:03
IWYU: picasa_types.h (several places in this CL)
tommycli
2013/07/10 22:22:27
Done.
| |
47 const std::vector<AlbumInfo>& folder); | 44 const std::vector<AlbumInfo>& folder); |
48 | 45 |
49 private: | 46 private: |
50 friend class PicasaFileUtilTest; | 47 friend class PicasaFileUtilTest; |
51 | 48 |
52 static std::string DateToPathString(const base::Time& time); | 49 static std::string DateToPathString(const base::Time& time); |
53 static void UniquifyNames(const std::vector<AlbumInfo>& info_list, | 50 static void UniquifyNames(const std::vector<AlbumInfo>& info_list, |
54 AlbumMap* result_map); | 51 AlbumMap* result_map); |
55 | 52 |
56 AlbumMap album_map_; | 53 AlbumMap album_map_; |
57 AlbumMap folder_map_; | 54 AlbumMap folder_map_; |
58 | 55 |
59 base::FilePath database_path_; | 56 base::FilePath database_path_; |
60 bool needs_refresh_; | 57 bool needs_refresh_; |
61 | 58 |
62 scoped_refptr<SafePicasaAlbumTableReader> album_table_reader_; | 59 scoped_refptr<SafePicasaAlbumTableReader> album_table_reader_; |
63 | 60 |
64 base::WeakPtrFactory<PicasaDataProvider> weak_factory_; | 61 base::WeakPtrFactory<PicasaDataProvider> weak_factory_; |
65 | 62 |
66 DISALLOW_COPY_AND_ASSIGN(PicasaDataProvider); | 63 DISALLOW_COPY_AND_ASSIGN(PicasaDataProvider); |
67 }; | 64 }; |
68 | 65 |
69 } // namespace picasa | 66 } // namespace picasa |
70 | 67 |
71 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_PICASA_PICASA_DATA_PROVIDER_H_ | 68 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_PICASA_PICASA_DATA_PROVIDER_H_ |
OLD | NEW |