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 |
27 // SafePicasaAlbumsIndexer indexes the contents of Picasa Albums by parsing the | 28 // SafePicasaAlbumsIndexer indexes the contents of Picasa Albums by parsing the |
28 // INI files found in Folders. The SafePicasaAlbumsIndexer object is ref-counted | 29 // INI files found in Folders. The SafePicasaAlbumsIndexer object is ref-counted |
29 // and kept alive after Start() is called until the ParserCallback is called. | 30 // and kept alive after Start() is called until the ParserCallback is called. |
30 // The ParserCallback is guaranteed to be called eventually either when the | 31 // The ParserCallback is guaranteed to be called eventually either when the |
31 // utility process replies or when it dies. | 32 // utility process replies or when it dies. |
32 class SafePicasaAlbumsIndexer : public content::UtilityProcessHostClient { | 33 class SafePicasaAlbumsIndexer : public content::UtilityProcessHostClient { |
33 public: | 34 public: |
34 typedef base::Callback<void(bool success, | 35 // Callback includes a refptr to itself to guarantee that this object |
| 36 // survives past the execution of its last posted callback. |
| 37 typedef base::Callback<void(scoped_refptr<SafePicasaAlbumsIndexer>, |
| 38 bool success, |
35 const picasa::AlbumImagesMap&)> DoneCallback; | 39 const picasa::AlbumImagesMap&)> DoneCallback; |
36 | 40 |
37 SafePicasaAlbumsIndexer(const AlbumMap& albums, | 41 SafePicasaAlbumsIndexer(const AlbumMap& albums, |
38 const AlbumMap& folders, | 42 const AlbumMap& folders, |
39 const DoneCallback& callback); | 43 const DoneCallback& callback); |
40 | 44 |
41 void Start(); | 45 void Start(); |
42 | 46 |
43 private: | 47 private: |
44 enum ParserState { | 48 enum ParserState { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 ParserState parser_state_; | 87 ParserState parser_state_; |
84 | 88 |
85 base::WeakPtrFactory<SafePicasaAlbumsIndexer> weak_factory_; | 89 base::WeakPtrFactory<SafePicasaAlbumsIndexer> weak_factory_; |
86 | 90 |
87 DISALLOW_COPY_AND_ASSIGN(SafePicasaAlbumsIndexer); | 91 DISALLOW_COPY_AND_ASSIGN(SafePicasaAlbumsIndexer); |
88 }; | 92 }; |
89 | 93 |
90 } // namespace picasa | 94 } // namespace picasa |
91 | 95 |
92 #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 |