Chromium Code Reviews| Index: chrome/browser/media_galleries/fileapi/safe_picasa_albums_indexer.h |
| diff --git a/chrome/browser/media_galleries/fileapi/safe_picasa_album_table_reader.h b/chrome/browser/media_galleries/fileapi/safe_picasa_albums_indexer.h |
| similarity index 52% |
| copy from chrome/browser/media_galleries/fileapi/safe_picasa_album_table_reader.h |
| copy to chrome/browser/media_galleries/fileapi/safe_picasa_albums_indexer.h |
| index 7ba576488449cf510a6d72b6220f139ee9ebf27d..9c299ddac768a6da10b1f96a106842ec623dff46 100644 |
| --- a/chrome/browser/media_galleries/fileapi/safe_picasa_album_table_reader.h |
| +++ b/chrome/browser/media_galleries/fileapi/safe_picasa_albums_indexer.h |
| @@ -2,16 +2,16 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUM_TABLE_READER_H_ |
| -#define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUM_TABLE_READER_H_ |
| +#ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUMS_INDEXER_H_ |
| +#define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUMS_INDEXER_H_ |
| -#include <string> |
| +#include <queue> |
| +#include <vector> |
| #include "base/callback.h" |
| -#include "base/compiler_specific.h" |
| +#include "base/compiler_specific.h" |
| #include "base/memory/weak_ptr.h" |
| -#include "chrome/common/media_galleries/picasa_types.h" |
| -#include "content/public/browser/utility_process_host.h" |
| +#include "chrome/common/media_galleries/picasa_types.h" |
| #include "content/public/browser/utility_process_host_client.h" |
| namespace base { |
| @@ -24,68 +24,69 @@ class Message; |
| namespace picasa { |
| -// SafePicasaAlbumTableReader parses the given Picasa PMP Album Table safely |
| -// via a utility process. The SafePicasaAlbumTableReader object is ref-counted |
| +// SafePicasaAlbumsIndexer indexes the contents of Picasa Albums by parsing the |
| +// INI files found in Folders. The SafePicasaAlbumsIndexer object is ref-counted |
| // and kept alive after Start() is called until the ParserCallback is called. |
| // The ParserCallback is guaranteed to be called eventually either when the |
| // utility process replies or when it dies. |
| -class SafePicasaAlbumTableReader : public content::UtilityProcessHostClient { |
| +class SafePicasaAlbumsIndexer : public content::UtilityProcessHostClient { |
| public: |
| - typedef base::Callback<void(bool, |
| - const std::vector<AlbumInfo>&, |
| - const std::vector<AlbumInfo>&)> ParserCallback; |
| + typedef base::Callback<void(bool success, |
|
Lei Zhang
2013/07/22 21:02:44
You should either name both callback parameters or
tommycli
2013/07/25 17:02:51
Done.
|
| + const picasa::AlbumImagesMap&)> DoneCallback; |
| - SafePicasaAlbumTableReader(const AlbumTableFiles& album_table_files, |
| - const ParserCallback& callback); |
| + SafePicasaAlbumsIndexer(const AlbumMap& albums, |
| + const AlbumMap& folders, |
| + const DoneCallback& callback); |
| void Start(); |
| private: |
| enum ParserState { |
| INITIAL_STATE, |
| - PINGED_UTILITY_PROCESS_STATE, |
| + STARTED_READING_INI_FILES_STATE, |
| + FINISHED_READING_INI_FILES_STATE, |
| STARTED_PARSING_STATE, |
| FINISHED_PARSING_STATE, |
| }; |
| // Private because content::UtilityProcessHostClient is ref-counted. |
| - virtual ~SafePicasaAlbumTableReader(); |
| + virtual ~SafePicasaAlbumsIndexer(); |
| + |
| + // Processes a batch of folders. Reposts itself until done, then starts IPC. |
| + void ProcessFoldersBatch(); |
| // Launches the utility process. Must run on the IO thread. |
| void StartWorkOnIOThread(); |
| - // Notification that the utility process is running, and we can now get its |
| - // process handle. |
| - // Runs on the IO thread. |
| - void OnProcessStarted(); |
| - |
| - // Notification from the utility process when it finshes parsing the PMP |
| - // database. This is received even if PMP parsing fails. |
| + // Notification from the utility process when it finshes indexing all the |
| + // album contents. On error will return an empty map. |
| // Runs on the IO thread. |
| - void OnParsePicasaPMPDatabaseFinished(bool parse_success, |
| - const std::vector<AlbumInfo>& albums, |
| - const std::vector<AlbumInfo>& folders); |
| + void OnIndexPicasaAlbumsContentsFinished(const AlbumImagesMap& albums_images); |
| // UtilityProcessHostClient implementation. |
| // Runs on the IO thread. |
| virtual void OnProcessCrashed(int exit_code) OVERRIDE; |
| virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| - const AlbumTableFiles album_table_files_; |
| + AlbumUIDSet album_uids_; |
| - // Only accessed on the IO thread. |
| - base::WeakPtr<content::UtilityProcessHost> utility_process_host_; |
| + // List of folders that still need their INI files read. |
| + std::queue<base::FilePath> folders_queue_; |
| + |
| + std::vector<picasa::FolderINIContents> folders_inis_; |
| // Only accessed on the Media Task Runner. |
| - const ParserCallback callback_; |
| + const DoneCallback callback_; |
| // Verifies the messages from the utility process came at the right time. |
| // Initialized on the Media Task Runner, but only accessed on the IO thread. |
|
Lei Zhang
2013/07/22 21:02:44
This comment is no longer true. |parser_state_| is
tommycli
2013/07/25 17:02:51
Done.
|
| ParserState parser_state_; |
| - DISALLOW_COPY_AND_ASSIGN(SafePicasaAlbumTableReader); |
| + base::WeakPtrFactory<SafePicasaAlbumsIndexer> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SafePicasaAlbumsIndexer); |
| }; |
| } // namespace picasa |
| -#endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUM_TABLE_READER_H_ |
| +#endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUMS_INDEXER_H_ |