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_ALBUM_TABLE_READER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUM_TABLE_READER_H_ |
6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUM_TABLE_READER_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUM_TABLE_READER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 namespace picasa { | 25 namespace picasa { |
26 | 26 |
27 // SafePicasaAlbumTableReader parses the given Picasa PMP Album Table safely | 27 // SafePicasaAlbumTableReader parses the given Picasa PMP Album Table safely |
28 // via a utility process. The SafePicasaAlbumTableReader object is ref-counted | 28 // via a utility process. The SafePicasaAlbumTableReader object is ref-counted |
29 // and kept alive after Start() is called until the ParserCallback is called. | 29 // and kept alive after Start() is called until the ParserCallback is called. |
30 // The ParserCallback is guaranteed to be called eventually either when the | 30 // The ParserCallback is guaranteed to be called eventually either when the |
31 // utility process replies or when it dies. | 31 // utility process replies or when it dies. |
32 class SafePicasaAlbumTableReader : public content::UtilityProcessHostClient { | 32 class SafePicasaAlbumTableReader : public content::UtilityProcessHostClient { |
33 public: | 33 public: |
34 typedef base::Callback<void(bool, | 34 // PicasaDataProvider keeps a reference to the last-dispatched instance of |
| 35 // this class so it can ignore callbacks from 'stale' instances. The callback |
| 36 // also keeps a reference so it doesn't get destroyed prematurely. |
| 37 typedef base::Callback<void(scoped_refptr<SafePicasaAlbumTableReader>, |
| 38 bool parse_success, |
35 const std::vector<AlbumInfo>&, | 39 const std::vector<AlbumInfo>&, |
36 const std::vector<AlbumInfo>&)> ParserCallback; | 40 const std::vector<AlbumInfo>&)> |
| 41 ParserCallback; |
37 | 42 |
38 SafePicasaAlbumTableReader(const AlbumTableFiles& album_table_files, | 43 SafePicasaAlbumTableReader(const AlbumTableFiles& album_table_files, |
39 const ParserCallback& callback); | 44 const ParserCallback& callback); |
40 | 45 |
41 void Start(); | 46 void Start(); |
42 | 47 |
43 private: | 48 private: |
44 enum ParserState { | 49 enum ParserState { |
45 INITIAL_STATE, | 50 INITIAL_STATE, |
46 PINGED_UTILITY_PROCESS_STATE, | 51 PINGED_UTILITY_PROCESS_STATE, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // 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. |
83 // 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. |
84 ParserState parser_state_; | 89 ParserState parser_state_; |
85 | 90 |
86 DISALLOW_COPY_AND_ASSIGN(SafePicasaAlbumTableReader); | 91 DISALLOW_COPY_AND_ASSIGN(SafePicasaAlbumTableReader); |
87 }; | 92 }; |
88 | 93 |
89 } // namespace picasa | 94 } // namespace picasa |
90 | 95 |
91 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUM_TABLE_READER
_H_ | 96 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUM_TABLE_READER
_H_ |
OLD | NEW |