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

Unified Diff: chrome/browser/media_galleries/fileapi/safe_picasa_albums_indexer.cc

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: update comment Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media_galleries/fileapi/safe_picasa_albums_indexer.cc
diff --git a/chrome/browser/media_galleries/fileapi/safe_picasa_albums_indexer.cc b/chrome/browser/media_galleries/fileapi/safe_picasa_albums_indexer.cc
index 57ea926b534a50ad185d4017f5595fa1b1df24a7..e8f941db40651cfc7684c3b69f818b298167d62b 100644
--- a/chrome/browser/media_galleries/fileapi/safe_picasa_albums_indexer.cc
+++ b/chrome/browser/media_galleries/fileapi/safe_picasa_albums_indexer.cc
@@ -19,25 +19,21 @@ namespace picasa {
namespace {
+// Arbitrarily chosen to be a decent size but not block thread too much.
+const int kPicasaINIReadBatchSize = 10;
+
+} // namespace
+
// Picasa INI files are named "picasa.ini" on Picasa for Windows before version
// 71.18. Later versions and Picasa for Mac uses ".picasa.ini".
// See: https://support.google.com/picasa/answer/11257?hl=en
const char kPicasaINIFilename[] = ".picasa.ini";
const char kPicasaINIFilenameLegacy[] = "picasa.ini";
-// Arbitrarily chosen to be a decent size but not block thread too much.
-const int kPicasaINIReadBatchSize = 10;
-
-} // namespace
-
-SafePicasaAlbumsIndexer::SafePicasaAlbumsIndexer(
- const AlbumMap& albums,
- const AlbumMap& folders,
- const DoneCallback& callback)
- : callback_(callback),
- parser_state_(INITIAL_STATE) {
+SafePicasaAlbumsIndexer::SafePicasaAlbumsIndexer(const AlbumMap& albums,
+ const AlbumMap& folders)
+ : parser_state_(INITIAL_STATE) {
DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread());
- DCHECK(!callback_.is_null());
folders_inis_.reserve(folders.size());
@@ -48,9 +44,11 @@ SafePicasaAlbumsIndexer::SafePicasaAlbumsIndexer(
folders_queue_.push(it->second.path);
}
-void SafePicasaAlbumsIndexer::Start() {
+void SafePicasaAlbumsIndexer::Start(const DoneCallback& callback) {
DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread());
+ DCHECK(!callback.is_null());
+ callback_ = callback;
ProcessFoldersBatch();
}
@@ -109,6 +107,7 @@ void SafePicasaAlbumsIndexer::StartWorkOnIOThread() {
void SafePicasaAlbumsIndexer::OnIndexPicasaAlbumsContentsFinished(
const AlbumImagesMap& albums_images) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK(!callback_.is_null());
if (parser_state_ != STARTED_PARSING_STATE)
return;
@@ -120,6 +119,7 @@ void SafePicasaAlbumsIndexer::OnIndexPicasaAlbumsContentsFinished(
void SafePicasaAlbumsIndexer::OnProcessCrashed(int exit_code) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ DCHECK(!callback_.is_null());
MediaFileSystemBackend::MediaTaskRunner()->PostTask(
FROM_HERE,

Powered by Google App Engine
This is Rietveld 408576698