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

Side by Side 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: Add invalidate call. 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 #include "chrome/browser/media_galleries/fileapi/safe_picasa_albums_indexer.h" 5 #include "chrome/browser/media_galleries/fileapi/safe_picasa_albums_indexer.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" 8 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h"
9 #include "chrome/common/chrome_utility_messages.h" 9 #include "chrome/common/chrome_utility_messages.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
11 #include "content/public/browser/child_process_data.h" 11 #include "content/public/browser/child_process_data.h"
12 #include "content/public/browser/utility_process_host.h"
13 12
14 using chrome::MediaFileSystemBackend; 13 using chrome::MediaFileSystemBackend;
15 using content::BrowserThread; 14 using content::BrowserThread;
16 using content::UtilityProcessHost; 15 using content::UtilityProcessHost;
17 16
18 namespace picasa { 17 namespace picasa {
19 18
20 namespace { 19 namespace {
21 20
22 // Picasa INI files are named "picasa.ini" on Picasa for Windows before version 21 // Picasa INI files are named "picasa.ini" on Picasa for Windows before version
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 BrowserThread::IO, 92 BrowserThread::IO,
94 FROM_HERE, 93 FROM_HERE,
95 base::Bind(&SafePicasaAlbumsIndexer::StartWorkOnIOThread, this)); 94 base::Bind(&SafePicasaAlbumsIndexer::StartWorkOnIOThread, this));
96 } 95 }
97 } 96 }
98 97
99 void SafePicasaAlbumsIndexer::StartWorkOnIOThread() { 98 void SafePicasaAlbumsIndexer::StartWorkOnIOThread() {
100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
101 DCHECK_EQ(FINISHED_READING_INI_FILES_STATE, parser_state_); 100 DCHECK_EQ(FINISHED_READING_INI_FILES_STATE, parser_state_);
102 101
103 UtilityProcessHost* host = 102 utility_process_host_ = content::UtilityProcessHost::Create(
104 UtilityProcessHost::Create(this, base::MessageLoopProxy::current()); 103 this,
105 host->EnableZygote(); 104 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get())
106 host->Send(new ChromeUtilityMsg_IndexPicasaAlbumsContents(album_uids_, 105 ->AsWeakPtr();
107 folders_inis_)); 106
107 utility_process_host_->EnableZygote();
108 utility_process_host_->Send(new ChromeUtilityMsg_IndexPicasaAlbumsContents(
109 album_uids_, folders_inis_));
108 parser_state_ = STARTED_PARSING_STATE; 110 parser_state_ = STARTED_PARSING_STATE;
109 } 111 }
110 112
111 void SafePicasaAlbumsIndexer::OnIndexPicasaAlbumsContentsFinished( 113 void SafePicasaAlbumsIndexer::OnIndexPicasaAlbumsContentsFinished(
112 const AlbumImagesMap& albums_images) { 114 const AlbumImagesMap& albums_images) {
113 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
114 if (parser_state_ != STARTED_PARSING_STATE) 116 if (parser_state_ != STARTED_PARSING_STATE)
115 return; 117 return;
116 118
117 MediaFileSystemBackend::MediaTaskRunner()->PostTask( 119 MediaFileSystemBackend::MediaTaskRunner()->PostTask(
118 FROM_HERE, 120 FROM_HERE,
119 base::Bind(callback_, albums_images)); 121 base::Bind(callback_,
122 scoped_refptr<SafePicasaAlbumsIndexer>(this),
123 albums_images));
120 parser_state_ = FINISHED_PARSING_STATE; 124 parser_state_ = FINISHED_PARSING_STATE;
121 } 125 }
122 126
123 void SafePicasaAlbumsIndexer::OnProcessCrashed(int exit_code) { 127 void SafePicasaAlbumsIndexer::OnProcessCrashed(int exit_code) {
124 OnIndexPicasaAlbumsContentsFinished(AlbumImagesMap()); 128 OnIndexPicasaAlbumsContentsFinished(AlbumImagesMap());
125 } 129 }
126 130
127 bool SafePicasaAlbumsIndexer::OnMessageReceived( 131 bool SafePicasaAlbumsIndexer::OnMessageReceived(
128 const IPC::Message& message) { 132 const IPC::Message& message) {
129 bool handled = true; 133 bool handled = true;
130 IPC_BEGIN_MESSAGE_MAP(SafePicasaAlbumsIndexer, message) 134 IPC_BEGIN_MESSAGE_MAP(SafePicasaAlbumsIndexer, message)
131 IPC_MESSAGE_HANDLER( 135 IPC_MESSAGE_HANDLER(
132 ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished, 136 ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished,
133 OnIndexPicasaAlbumsContentsFinished) 137 OnIndexPicasaAlbumsContentsFinished)
134 IPC_MESSAGE_UNHANDLED(handled = false) 138 IPC_MESSAGE_UNHANDLED(handled = false)
135 IPC_END_MESSAGE_MAP() 139 IPC_END_MESSAGE_MAP()
136 return handled; 140 return handled;
137 } 141 }
138 142
139 } // namespace picasa 143 } // namespace picasa
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698