| 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/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 14 #include "chrome/common/media_galleries/picasa_types.h" | 15 #include "chrome/common/media_galleries/picasa_types.h" |
| 15 #include "content/public/browser/utility_process_host_client.h" | 16 #include "content/public/browser/utility_process_host_client.h" |
| 16 | 17 |
| 17 namespace base { | 18 namespace base { |
| 18 class FilePath; | 19 class FilePath; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace IPC { | 22 namespace IPC { |
| 22 class Message; | 23 class Message; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace picasa { | 26 namespace picasa { |
| 26 | 27 |
| 28 extern const char kPicasaINIFilename[]; |
| 29 |
| 27 // SafePicasaAlbumsIndexer indexes the contents of Picasa Albums by parsing the | 30 // SafePicasaAlbumsIndexer indexes the contents of Picasa Albums by parsing the |
| 28 // INI files found in Folders. The SafePicasaAlbumsIndexer object is ref-counted | 31 // INI files found in Folders. The SafePicasaAlbumsIndexer object is ref-counted |
| 29 // and kept alive after Start() is called until the ParserCallback is called. | 32 // and kept alive after Start() is called until the ParserCallback is called. |
| 30 // The ParserCallback is guaranteed to be called eventually either when the | 33 // The ParserCallback is guaranteed to be called eventually either when the |
| 31 // utility process replies or when it dies. | 34 // utility process replies or when it dies. |
| 32 class SafePicasaAlbumsIndexer : public content::UtilityProcessHostClient { | 35 class SafePicasaAlbumsIndexer : public content::UtilityProcessHostClient { |
| 33 public: | 36 public: |
| 34 typedef base::Callback<void(bool /* success */, | 37 // Callback includes a refptr to itself to guarantee that this object |
| 35 const picasa::AlbumImagesMap&)> DoneCallback; | 38 // survives past the execution of its last posted callback. |
| 39 typedef base::Callback<void(scoped_refptr<SafePicasaAlbumsIndexer>, |
| 40 bool success, |
| 41 const picasa::AlbumImagesMap&)> |
| 42 DoneCallback; |
| 36 | 43 |
| 37 SafePicasaAlbumsIndexer(const AlbumMap& albums, | 44 SafePicasaAlbumsIndexer(const AlbumMap& albums, |
| 38 const AlbumMap& folders, | 45 const AlbumMap& folders, |
| 39 const DoneCallback& callback); | 46 const DoneCallback& callback); |
| 40 | 47 |
| 41 void Start(); | 48 void Start(); |
| 42 | 49 |
| 43 private: | 50 private: |
| 44 enum ParserState { | 51 enum ParserState { |
| 45 INITIAL_STATE, | 52 INITIAL_STATE, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // Verifies the messages from the utility process came at the right time. | 86 // 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. | 87 // Initialized on the Media Task Runner, but only accessed on the IO thread. |
| 81 ParserState parser_state_; | 88 ParserState parser_state_; |
| 82 | 89 |
| 83 DISALLOW_COPY_AND_ASSIGN(SafePicasaAlbumsIndexer); | 90 DISALLOW_COPY_AND_ASSIGN(SafePicasaAlbumsIndexer); |
| 84 }; | 91 }; |
| 85 | 92 |
| 86 } // namespace picasa | 93 } // namespace picasa |
| 87 | 94 |
| 88 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUMS_INDEXER_H_ | 95 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUMS_INDEXER_H_ |
| OLD | NEW |