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_SAFE_PICASA_ALBUMS_INDEXER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUMS_INDEXER_H_ |
6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUMS_INDEXER_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUMS_INDEXER_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "chrome/common/media_galleries/picasa_types.h" | 14 #include "chrome/common/media_galleries/picasa_types.h" |
15 #include "content/public/browser/utility_process_host_client.h" | 15 #include "content/public/browser/utility_process_host_client.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class FilePath; | 18 class FilePath; |
19 } | 19 } |
20 | 20 |
21 namespace IPC { | 21 namespace IPC { |
22 class Message; | 22 class Message; |
23 } | 23 } |
24 | 24 |
25 namespace picasa { | 25 namespace picasa { |
26 | 26 |
| 27 extern const char kPicasaINIFilename[]; |
| 28 |
27 // SafePicasaAlbumsIndexer indexes the contents of Picasa Albums by parsing the | 29 // SafePicasaAlbumsIndexer indexes the contents of Picasa Albums by parsing the |
28 // INI files found in Folders. The SafePicasaAlbumsIndexer object is ref-counted | 30 // INI files found in Folders. The SafePicasaAlbumsIndexer object is ref-counted |
29 // and kept alive after Start() is called until the ParserCallback is called. | 31 // and kept alive after Start() is called until the ParserCallback is called. |
30 // The ParserCallback is guaranteed to be called eventually either when the | 32 // The ParserCallback is guaranteed to be called eventually either when the |
31 // utility process replies or when it dies. | 33 // utility process replies or when it dies. |
32 class SafePicasaAlbumsIndexer : public content::UtilityProcessHostClient { | 34 class SafePicasaAlbumsIndexer : public content::UtilityProcessHostClient { |
33 public: | 35 public: |
34 typedef base::Callback<void(bool /* success */, | 36 typedef base::Callback< |
35 const picasa::AlbumImagesMap&)> DoneCallback; | 37 void(bool parse_success, const picasa::AlbumImagesMap&)> |
| 38 DoneCallback; |
36 | 39 |
37 SafePicasaAlbumsIndexer(const AlbumMap& albums, | 40 SafePicasaAlbumsIndexer(const AlbumMap& albums, const AlbumMap& folders); |
38 const AlbumMap& folders, | |
39 const DoneCallback& callback); | |
40 | 41 |
41 void Start(); | 42 void Start(const DoneCallback& callback); |
42 | 43 |
43 private: | 44 private: |
44 enum ParserState { | 45 enum ParserState { |
45 INITIAL_STATE, | 46 INITIAL_STATE, |
46 STARTED_PARSING_STATE, | 47 STARTED_PARSING_STATE, |
47 FINISHED_PARSING_STATE, | 48 FINISHED_PARSING_STATE, |
48 }; | 49 }; |
49 | 50 |
50 // Private because content::UtilityProcessHostClient is ref-counted. | 51 // Private because content::UtilityProcessHostClient is ref-counted. |
51 virtual ~SafePicasaAlbumsIndexer(); | 52 virtual ~SafePicasaAlbumsIndexer(); |
(...skipping 15 matching lines...) Expand all Loading... |
67 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 68 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
68 | 69 |
69 AlbumUIDSet album_uids_; | 70 AlbumUIDSet album_uids_; |
70 | 71 |
71 // List of folders that still need their INI files read. | 72 // List of folders that still need their INI files read. |
72 std::queue<base::FilePath> folders_queue_; | 73 std::queue<base::FilePath> folders_queue_; |
73 | 74 |
74 std::vector<picasa::FolderINIContents> folders_inis_; | 75 std::vector<picasa::FolderINIContents> folders_inis_; |
75 | 76 |
76 // Only accessed on the Media Task Runner. | 77 // Only accessed on the Media Task Runner. |
77 const DoneCallback callback_; | 78 DoneCallback callback_; |
78 | 79 |
79 // Verifies the messages from the utility process came at the right time. | 80 // Verifies the messages from the utility process came at the right time. |
80 // Initialized on the Media Task Runner, but only accessed on the IO thread. | 81 // Initialized on the Media Task Runner, but only accessed on the IO thread. |
81 ParserState parser_state_; | 82 ParserState parser_state_; |
82 | 83 |
83 DISALLOW_COPY_AND_ASSIGN(SafePicasaAlbumsIndexer); | 84 DISALLOW_COPY_AND_ASSIGN(SafePicasaAlbumsIndexer); |
84 }; | 85 }; |
85 | 86 |
86 } // namespace picasa | 87 } // namespace picasa |
87 | 88 |
88 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUMS_INDEXER_H_ | 89 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUMS_INDEXER_H_ |
OLD | NEW |