| 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_album_table_reader.
h" | 5 #include "chrome/browser/media_galleries/fileapi/safe_picasa_album_table_reader.
h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 void SafePicasaAlbumTableReader::StartWorkOnIOThread() { | 64 void SafePicasaAlbumTableReader::StartWorkOnIOThread() { |
| 65 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 65 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 66 DCHECK_EQ(INITIAL_STATE, parser_state_); | 66 DCHECK_EQ(INITIAL_STATE, parser_state_); |
| 67 | 67 |
| 68 utility_process_host_ = content::UtilityProcessHost::Create( | 68 utility_process_host_ = content::UtilityProcessHost::Create( |
| 69 this, | 69 this, |
| 70 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get()) | 70 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get()) |
| 71 ->AsWeakPtr(); | 71 ->AsWeakPtr(); |
| 72 utility_process_host_->SetName(l10n_util::GetStringUTF16( | 72 utility_process_host_->SetName(l10n_util::GetStringUTF16( |
| 73 IDS_UTILITY_PROCESS_MEDIA_LIBRARY_FILE_CHECKER_NAME)); | 73 IDS_UTILITY_PROCESS_MEDIA_LIBRARY_FILE_CHECKER_NAME)); |
| 74 // Wait for the startup notification before sending the main IPC to the | |
| 75 // utility process, so that we can dup the file handle. | |
| 76 utility_process_host_->Send(new ChromeUtilityMsg_StartupPing); | |
| 77 parser_state_ = PINGED_UTILITY_PROCESS_STATE; | |
| 78 } | |
| 79 | 74 |
| 80 void SafePicasaAlbumTableReader::OnProcessStarted() { | |
| 81 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 82 if (parser_state_ != PINGED_UTILITY_PROCESS_STATE) | |
| 83 return; | |
| 84 | |
| 85 if (utility_process_host_->GetData().handle == base::kNullProcessHandle) { | |
| 86 DLOG(ERROR) << "Child process handle is null"; | |
| 87 } | |
| 88 AlbumTableFilesForTransit files_for_transit; | 75 AlbumTableFilesForTransit files_for_transit; |
| 89 files_for_transit.indicator_file = IPC::TakePlatformFileForTransit( | 76 files_for_transit.indicator_file = IPC::TakePlatformFileForTransit( |
| 90 std::move(album_table_files_.indicator_file)); | 77 std::move(album_table_files_.indicator_file)); |
| 91 files_for_transit.category_file = IPC::TakePlatformFileForTransit( | 78 files_for_transit.category_file = IPC::TakePlatformFileForTransit( |
| 92 std::move(album_table_files_.category_file)); | 79 std::move(album_table_files_.category_file)); |
| 93 files_for_transit.date_file = | 80 files_for_transit.date_file = |
| 94 IPC::TakePlatformFileForTransit(std::move(album_table_files_.date_file)); | 81 IPC::TakePlatformFileForTransit(std::move(album_table_files_.date_file)); |
| 95 files_for_transit.filename_file = IPC::TakePlatformFileForTransit( | 82 files_for_transit.filename_file = IPC::TakePlatformFileForTransit( |
| 96 std::move(album_table_files_.filename_file)); | 83 std::move(album_table_files_.filename_file)); |
| 97 files_for_transit.name_file = | 84 files_for_transit.name_file = |
| (...skipping 24 matching lines...) Expand all Loading... |
| 122 void SafePicasaAlbumTableReader::OnProcessCrashed(int exit_code) { | 109 void SafePicasaAlbumTableReader::OnProcessCrashed(int exit_code) { |
| 123 DLOG(ERROR) << "SafePicasaAlbumTableReader::OnProcessCrashed()"; | 110 DLOG(ERROR) << "SafePicasaAlbumTableReader::OnProcessCrashed()"; |
| 124 OnParsePicasaPMPDatabaseFinished( | 111 OnParsePicasaPMPDatabaseFinished( |
| 125 false, std::vector<AlbumInfo>(), std::vector<AlbumInfo>()); | 112 false, std::vector<AlbumInfo>(), std::vector<AlbumInfo>()); |
| 126 } | 113 } |
| 127 | 114 |
| 128 bool SafePicasaAlbumTableReader::OnMessageReceived( | 115 bool SafePicasaAlbumTableReader::OnMessageReceived( |
| 129 const IPC::Message& message) { | 116 const IPC::Message& message) { |
| 130 bool handled = true; | 117 bool handled = true; |
| 131 IPC_BEGIN_MESSAGE_MAP(SafePicasaAlbumTableReader, message) | 118 IPC_BEGIN_MESSAGE_MAP(SafePicasaAlbumTableReader, message) |
| 132 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ProcessStarted, | |
| 133 OnProcessStarted) | |
| 134 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParsePicasaPMPDatabase_Finished, | 119 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParsePicasaPMPDatabase_Finished, |
| 135 OnParsePicasaPMPDatabaseFinished) | 120 OnParsePicasaPMPDatabaseFinished) |
| 136 IPC_MESSAGE_UNHANDLED(handled = false) | 121 IPC_MESSAGE_UNHANDLED(handled = false) |
| 137 IPC_END_MESSAGE_MAP() | 122 IPC_END_MESSAGE_MAP() |
| 138 return handled; | 123 return handled; |
| 139 } | 124 } |
| 140 | 125 |
| 141 } // namespace picasa | 126 } // namespace picasa |
| OLD | NEW |