Chromium Code Reviews| Index: chrome/browser/media_galleries/fileapi/picasa/picasa_data_provider.h |
| diff --git a/chrome/browser/media_galleries/fileapi/picasa/picasa_data_provider.h b/chrome/browser/media_galleries/fileapi/picasa/picasa_data_provider.h |
| index 5109b5b70ab288a00b92e2746b087427f56b33e9..ecc972b32de3e39d4bb1316611903e6d93240da1 100644 |
| --- a/chrome/browser/media_galleries/fileapi/picasa/picasa_data_provider.h |
| +++ b/chrome/browser/media_galleries/fileapi/picasa/picasa_data_provider.h |
| @@ -6,10 +6,11 @@ |
| #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_PICASA_PICASA_DATA_PROVIDER_H_ |
| #include <map> |
| +#include <queue> |
| #include <string> |
| #include <vector> |
| -#include "base/callback_forward.h" |
| +#include "base/callback.h" |
| #include "base/files/file_path.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/memory/scoped_ptr.h" |
| @@ -20,6 +21,7 @@ |
| namespace picasa { |
| class SafePicasaAlbumTableReader; |
| +class SafePicasaAlbumsIndexer; |
| // Created and owned by ImportedMediaGalleryRegistryTaskRunnerValues |
| class PicasaDataProvider { |
| @@ -28,35 +30,64 @@ class PicasaDataProvider { |
| virtual ~PicasaDataProvider(); |
| // Ask the data provider to refresh the data if necessary. |ready_callback| |
| - // will be called when the data is up to date |
| + // will be called when the data is up to date. |refresh_album_contents| |
| + // is true if the caller wants the album contents also. |
| // TODO(tommycli): Investigate having the callback return a bool indicating |
| // success or failure - and handling it intelligently in PicasaFileUtil. |
| - void RefreshData(const base::Closure& ready_callback); |
| + void RefreshData( |
| + bool need_albums_images, |
| + const base::Closure& ready_callback); |
| + // Notifies data provider that any currently cached data is stale. |
| + void InvalidateData(); |
|
vandebo (ex-Chrome)
2013/07/11 16:56:27
This should be handled internally.
tommycli
2013/07/11 21:19:17
Done.
|
| + |
| + // These methods return scoped_ptrs because we want to return a copy that |
| + // will not change to the caller. |
| scoped_ptr<AlbumMap> GetAlbums(); |
| scoped_ptr<AlbumMap> GetFolders(); |
| - // TODO(tommycli): Implement album contents. GetAlbumContents(...) |
| - |
| - protected: |
| - // Protected for test class usage. |
| - void OnDataRefreshed(const base::Closure& ready_callback, |
| - bool parse_success, const std::vector<AlbumInfo>& albums, |
| - const std::vector<AlbumInfo>& folder); |
| + scoped_ptr<AlbumImagesMap> GetAlbumsImages(); |
| private: |
| + enum DataState { |
|
vandebo (ex-Chrome)
2013/07/11 16:56:27
nit: this can probably just be state instead of da
tommycli
2013/07/11 21:19:17
Done.
|
| + NO_FRESH_DATA_STATE = 0, |
|
vandebo (ex-Chrome)
2013/07/11 16:56:27
nit: omit = 0
vandebo (ex-Chrome)
2013/07/11 16:56:27
nit: STALE_DATA_STATE ?
tommycli
2013/07/11 21:19:17
Done.
tommycli
2013/07/11 21:19:17
Done.
|
| + ALBUM_LIST_FRESH_STATE, |
| + ALBUMS_IMAGES_FRESH_STATE |
| + }; |
| + |
| friend class PicasaFileUtilTest; |
| + void EnsureAlbumListRefreshed(const base::Closure& ready_callback); |
| + void EnsureAlbumsImagesRefreshed(const base::Closure& ready_callback); |
| + |
| + void OnAlbumListRefreshed(scoped_refptr<SafePicasaAlbumTableReader> reader, |
| + bool parse_success, |
| + const std::vector<AlbumInfo>& albums, |
| + const std::vector<AlbumInfo>& folder); |
| + |
| + void OnAlbumsIndexerDone(scoped_refptr<SafePicasaAlbumsIndexer> indexer, |
| + const picasa::AlbumImagesMap& albums_images); |
| + |
| static std::string DateToPathString(const base::Time& time); |
| static void UniquifyNames(const std::vector<AlbumInfo>& info_list, |
| AlbumMap* result_map); |
| AlbumMap album_map_; |
| AlbumMap folder_map_; |
| + AlbumImagesMap albums_images_; |
| base::FilePath database_path_; |
| - bool needs_refresh_; |
| + DataState data_state_; |
| + |
| + // Callbacks that are waiting for their requested data to be ready. |
| + std::queue<base::Closure> album_list_ready_callbacks_; |
| + std::queue<base::Closure> albums_indexer_ready_callbacks_; |
| + |
| + // Stores the "live" in-flight utility processes. Callbacks from other |
| + // (older) utility processes are stale and ignored. Only one of these should |
| + // ever be non-NULL. |
| scoped_refptr<SafePicasaAlbumTableReader> album_table_reader_; |
| + scoped_refptr<SafePicasaAlbumsIndexer> albums_indexer_; |
| base::WeakPtrFactory<PicasaDataProvider> weak_factory_; |