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 // Callback includes a refptr to itself to guarantee that this object |
| 35 // survives past the execution of its last posted callback. |
| 36 typedef base::Callback<void(scoped_refptr<SafePicasaAlbumTableReader>, |
| 37 bool, |
35 const std::vector<AlbumInfo>&, | 38 const std::vector<AlbumInfo>&, |
36 const std::vector<AlbumInfo>&)> ParserCallback; | 39 const std::vector<AlbumInfo>&)> ParserCallback; |
37 | 40 |
38 SafePicasaAlbumTableReader(const AlbumTableFiles& album_table_files, | 41 SafePicasaAlbumTableReader(const AlbumTableFiles& album_table_files, |
39 const ParserCallback& callback); | 42 const ParserCallback& callback); |
40 | 43 |
41 void Start(); | 44 void Start(); |
42 | 45 |
43 private: | 46 private: |
44 enum ParserState { | 47 enum ParserState { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // Verifies the messages from the utility process came at the right time. | 85 // 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. | 86 // Initialized on the Media Task Runner, but only accessed on the IO thread. |
84 ParserState parser_state_; | 87 ParserState parser_state_; |
85 | 88 |
86 DISALLOW_COPY_AND_ASSIGN(SafePicasaAlbumTableReader); | 89 DISALLOW_COPY_AND_ASSIGN(SafePicasaAlbumTableReader); |
87 }; | 90 }; |
88 | 91 |
89 } // namespace picasa | 92 } // namespace picasa |
90 | 93 |
91 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUM_TABLE_READER
_H_ | 94 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUM_TABLE_READER
_H_ |
OLD | NEW |