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 #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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 BrowserThread::IO, | 97 BrowserThread::IO, |
99 FROM_HERE, | 98 FROM_HERE, |
100 base::Bind(&SafePicasaAlbumsIndexer::StartWorkOnIOThread, this)); | 99 base::Bind(&SafePicasaAlbumsIndexer::StartWorkOnIOThread, this)); |
101 } | 100 } |
102 } | 101 } |
103 | 102 |
104 void SafePicasaAlbumsIndexer::StartWorkOnIOThread() { | 103 void SafePicasaAlbumsIndexer::StartWorkOnIOThread() { |
105 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
106 DCHECK_EQ(FINISHED_READING_INI_FILES_STATE, parser_state_); | 105 DCHECK_EQ(FINISHED_READING_INI_FILES_STATE, parser_state_); |
107 | 106 |
108 UtilityProcessHost* host = | 107 utility_process_host_ = content::UtilityProcessHost::Create( |
109 UtilityProcessHost::Create(this, base::MessageLoopProxy::current()); | 108 this, |
110 host->EnableZygote(); | 109 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get()) |
vandebo (ex-Chrome)
2013/07/12 18:29:59
make a local temp variable to get nicer indenting.
vandebo (ex-Chrome)
2013/07/12 18:29:59
Why not use the current() method, you've already a
tommycli
2013/07/12 21:37:19
Done.
tommycli
2013/07/12 21:37:19
Done.
| |
111 host->Send(new ChromeUtilityMsg_IndexPicasaAlbumsContents(album_uids_, | 110 ->AsWeakPtr(); |
112 folders_inis_)); | 111 |
112 utility_process_host_->EnableZygote(); | |
113 utility_process_host_->Send(new ChromeUtilityMsg_IndexPicasaAlbumsContents( | |
114 album_uids_, folders_inis_)); | |
113 parser_state_ = STARTED_PARSING_STATE; | 115 parser_state_ = STARTED_PARSING_STATE; |
114 } | 116 } |
115 | 117 |
116 void SafePicasaAlbumsIndexer::OnIndexPicasaAlbumsContentsFinished( | 118 void SafePicasaAlbumsIndexer::OnIndexPicasaAlbumsContentsFinished( |
117 const AlbumImagesMap& albums_images) { | 119 const AlbumImagesMap& albums_images) { |
118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 120 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
119 if (parser_state_ != STARTED_PARSING_STATE) | 121 if (parser_state_ != STARTED_PARSING_STATE) |
120 return; | 122 return; |
121 | 123 |
122 MediaFileSystemBackend::MediaTaskRunner()->PostTask( | 124 MediaFileSystemBackend::MediaTaskRunner()->PostTask( |
123 FROM_HERE, | 125 FROM_HERE, |
124 base::Bind(callback_, true, albums_images)); | 126 base::Bind(callback_, |
127 make_scoped_refptr(this), | |
128 true, | |
129 albums_images)); | |
125 parser_state_ = FINISHED_PARSING_STATE; | 130 parser_state_ = FINISHED_PARSING_STATE; |
126 } | 131 } |
127 | 132 |
128 void SafePicasaAlbumsIndexer::OnProcessCrashed(int exit_code) { | 133 void SafePicasaAlbumsIndexer::OnProcessCrashed(int exit_code) { |
129 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 134 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
130 | 135 |
131 MediaFileSystemBackend::MediaTaskRunner()->PostTask( | 136 MediaFileSystemBackend::MediaTaskRunner()->PostTask( |
132 FROM_HERE, | 137 FROM_HERE, |
133 base::Bind(callback_, false, AlbumImagesMap())); | 138 base::Bind(callback_, |
139 make_scoped_refptr(this), | |
140 false, | |
141 AlbumImagesMap())); | |
134 } | 142 } |
135 | 143 |
136 bool SafePicasaAlbumsIndexer::OnMessageReceived( | 144 bool SafePicasaAlbumsIndexer::OnMessageReceived( |
137 const IPC::Message& message) { | 145 const IPC::Message& message) { |
138 bool handled = true; | 146 bool handled = true; |
139 IPC_BEGIN_MESSAGE_MAP(SafePicasaAlbumsIndexer, message) | 147 IPC_BEGIN_MESSAGE_MAP(SafePicasaAlbumsIndexer, message) |
140 IPC_MESSAGE_HANDLER( | 148 IPC_MESSAGE_HANDLER( |
141 ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished, | 149 ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished, |
142 OnIndexPicasaAlbumsContentsFinished) | 150 OnIndexPicasaAlbumsContentsFinished) |
143 IPC_MESSAGE_UNHANDLED(handled = false) | 151 IPC_MESSAGE_UNHANDLED(handled = false) |
144 IPC_END_MESSAGE_MAP() | 152 IPC_END_MESSAGE_MAP() |
145 return handled; | 153 return handled; |
146 } | 154 } |
147 | 155 |
148 } // namespace picasa | 156 } // namespace picasa |
OLD | NEW |