Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: chrome/browser/media_galleries/fileapi/safe_picasa_albums_indexer.h

Issue 18986012: Media Galleries API Picasa: Make PicasaDataProvider handle async PMP and INI parsing robustly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@0039-picasa-import-sandbox-ini-parsing
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
16 #include "content/public/browser/utility_process_host.h"
15 #include "content/public/browser/utility_process_host_client.h" 17 #include "content/public/browser/utility_process_host_client.h"
16 18
17 namespace base { 19 namespace base {
18 class FilePath; 20 class FilePath;
19 } 21 }
20 22
21 namespace IPC { 23 namespace IPC {
22 class Message; 24 class Message;
23 } 25 }
24 26
25 namespace picasa { 27 namespace picasa {
26 28
27 // SafePicasaAlbumsIndexer indexes the contents of Picasa Albums by parsing the 29 // SafePicasaAlbumsIndexer indexes the contents of Picasa Albums by parsing the
28 // INI files found in Folders. The SafePicasaAlbumsIndexer object is ref-counted 30 // INI files found in Folders. The SafePicasaAlbumsIndexer object is ref-counted
29 // and kept alive after Start() is called until the ParserCallback is called. 31 // and kept alive after Start() is called until the ParserCallback is called.
30 // The ParserCallback is guaranteed to be called eventually either when the 32 // The ParserCallback is guaranteed to be called eventually either when the
31 // utility process replies or when it dies. 33 // utility process replies or when it dies.
32 class SafePicasaAlbumsIndexer : public content::UtilityProcessHostClient { 34 class SafePicasaAlbumsIndexer : public content::UtilityProcessHostClient {
33 public: 35 public:
34 typedef base::Callback<void(bool success, 36 // Callback includes a refptr to itself to guarantee that this object
37 // survives past the execution of its last posted callback.
38 typedef base::Callback<void(scoped_refptr<SafePicasaAlbumsIndexer>,
39 bool success,
35 const picasa::AlbumImagesMap&)> DoneCallback; 40 const picasa::AlbumImagesMap&)> DoneCallback;
36 41
37 SafePicasaAlbumsIndexer(const AlbumMap& albums, 42 SafePicasaAlbumsIndexer(const AlbumMap& albums,
38 const AlbumMap& folders, 43 const AlbumMap& folders,
39 const DoneCallback& callback); 44 const DoneCallback& callback);
40 45
41 void Start(); 46 void Start();
42 47
43 private: 48 private:
44 enum ParserState { 49 enum ParserState {
(...skipping 23 matching lines...) Expand all
68 virtual void OnProcessCrashed(int exit_code) OVERRIDE; 73 virtual void OnProcessCrashed(int exit_code) OVERRIDE;
69 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 74 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
70 75
71 AlbumUIDSet album_uids_; 76 AlbumUIDSet album_uids_;
72 77
73 // List of folders that still need their INI files read. 78 // List of folders that still need their INI files read.
74 std::queue<base::FilePath> folders_queue_; 79 std::queue<base::FilePath> folders_queue_;
75 80
76 std::vector<picasa::FolderINIContents> folders_inis_; 81 std::vector<picasa::FolderINIContents> folders_inis_;
77 82
83 // Only accessed on the IO thread.
84 base::WeakPtr<content::UtilityProcessHost> utility_process_host_;
vandebo (ex-Chrome) 2013/07/12 18:29:59 This isn't used in this CL?
tommycli 2013/07/12 21:37:19 This is an aborted attempt to make the utility pro
85
78 // Only accessed on the Media Task Runner. 86 // Only accessed on the Media Task Runner.
79 const DoneCallback callback_; 87 const DoneCallback callback_;
80 88
81 // Verifies the messages from the utility process came at the right time. 89 // Verifies the messages from the utility process came at the right time.
82 // Initialized on the Media Task Runner, but only accessed on the IO thread. 90 // Initialized on the Media Task Runner, but only accessed on the IO thread.
83 ParserState parser_state_; 91 ParserState parser_state_;
84 92
85 base::WeakPtrFactory<SafePicasaAlbumsIndexer> weak_factory_; 93 base::WeakPtrFactory<SafePicasaAlbumsIndexer> weak_factory_;
86 94
87 DISALLOW_COPY_AND_ASSIGN(SafePicasaAlbumsIndexer); 95 DISALLOW_COPY_AND_ASSIGN(SafePicasaAlbumsIndexer);
88 }; 96 };
89 97
90 } // namespace picasa 98 } // namespace picasa
91 99
92 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUMS_INDEXER_H_ 100 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_SAFE_PICASA_ALBUMS_INDEXER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698