| 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 // PicasaDataProvider keeps a reference to the last-dispatched instance of |
| 35 const picasa::AlbumImagesMap&)> DoneCallback; | 38 // this class so it can ignore callbacks from 'stale' instances. The callback |
| 39 // also keeps a reference so it doesn't get destroyed prematurely. |
| 40 typedef base::Callback<void(scoped_refptr<SafePicasaAlbumsIndexer>, |
| 41 bool parse_success, |
| 42 const picasa::AlbumImagesMap&)> |
| 43 DoneCallback; |
| 36 | 44 |
| 37 SafePicasaAlbumsIndexer(const AlbumMap& albums, | 45 SafePicasaAlbumsIndexer(const AlbumMap& albums, |
| 38 const AlbumMap& folders, | 46 const AlbumMap& folders, |
| 39 const DoneCallback& callback); | 47 const DoneCallback& callback); |
| 40 | 48 |
| 41 void Start(); | 49 void Start(); |
| 42 | 50 |
| 43 private: | 51 private: |
| 44 enum ParserState { | 52 enum ParserState { |
| 45 INITIAL_STATE, | 53 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. | 87 // 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. | 88 // Initialized on the Media Task Runner, but only accessed on the IO thread. |
| 81 ParserState parser_state_; | 89 ParserState parser_state_; |
| 82 | 90 |
| 83 DISALLOW_COPY_AND_ASSIGN(SafePicasaAlbumsIndexer); | 91 DISALLOW_COPY_AND_ASSIGN(SafePicasaAlbumsIndexer); |
| 84 }; | 92 }; |
| 85 | 93 |
| 86 } // namespace picasa | 94 } // namespace picasa |
| 87 | 95 |
| 88 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUMS_INDEXER_H_ | 96 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUMS_INDEXER_H_ |
| OLD | NEW |