| 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> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/logging.h" | 10 #include "base/logging.h" |
| 9 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" | 11 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" |
| 10 #include "chrome/common/chrome_utility_messages.h" | 12 #include "chrome/common/chrome_utility_messages.h" |
| 11 #include "chrome/common/extensions/chrome_utility_extensions_messages.h" | 13 #include "chrome/common/extensions/chrome_utility_extensions_messages.h" |
| 12 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
| 13 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/child_process_data.h" | 16 #include "content/public/browser/child_process_data.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 16 | 18 |
| 17 using content::BrowserThread; | 19 using content::BrowserThread; |
| 18 | 20 |
| 19 namespace picasa { | 21 namespace picasa { |
| 20 | 22 |
| 21 SafePicasaAlbumTableReader::SafePicasaAlbumTableReader( | 23 SafePicasaAlbumTableReader::SafePicasaAlbumTableReader( |
| 22 AlbumTableFiles album_table_files) | 24 AlbumTableFiles album_table_files) |
| 23 : album_table_files_(album_table_files.Pass()), | 25 : album_table_files_(std::move(album_table_files)), |
| 24 parser_state_(INITIAL_STATE) { | 26 parser_state_(INITIAL_STATE) { |
| 25 // TODO(tommycli): Add DCHECK to make sure |album_table_files| are all | 27 // TODO(tommycli): Add DCHECK to make sure |album_table_files| are all |
| 26 // opened read-only once security adds ability to check PlatformFiles. | 28 // opened read-only once security adds ability to check PlatformFiles. |
| 27 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); | 29 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); |
| 28 } | 30 } |
| 29 | 31 |
| 30 void SafePicasaAlbumTableReader::Start(const ParserCallback& callback) { | 32 void SafePicasaAlbumTableReader::Start(const ParserCallback& callback) { |
| 31 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); | 33 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); |
| 32 DCHECK(!callback.is_null()); | 34 DCHECK(!callback.is_null()); |
| 33 | 35 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 void SafePicasaAlbumTableReader::OnProcessStarted() { | 80 void SafePicasaAlbumTableReader::OnProcessStarted() { |
| 79 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 81 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 80 if (parser_state_ != PINGED_UTILITY_PROCESS_STATE) | 82 if (parser_state_ != PINGED_UTILITY_PROCESS_STATE) |
| 81 return; | 83 return; |
| 82 | 84 |
| 83 if (utility_process_host_->GetData().handle == base::kNullProcessHandle) { | 85 if (utility_process_host_->GetData().handle == base::kNullProcessHandle) { |
| 84 DLOG(ERROR) << "Child process handle is null"; | 86 DLOG(ERROR) << "Child process handle is null"; |
| 85 } | 87 } |
| 86 AlbumTableFilesForTransit files_for_transit; | 88 AlbumTableFilesForTransit files_for_transit; |
| 87 files_for_transit.indicator_file = IPC::TakeFileHandleForProcess( | 89 files_for_transit.indicator_file = IPC::TakeFileHandleForProcess( |
| 88 album_table_files_.indicator_file.Pass(), | 90 std::move(album_table_files_.indicator_file), |
| 89 utility_process_host_->GetData().handle); | 91 utility_process_host_->GetData().handle); |
| 90 files_for_transit.category_file = IPC::TakeFileHandleForProcess( | 92 files_for_transit.category_file = |
| 91 album_table_files_.category_file.Pass(), | 93 IPC::TakeFileHandleForProcess(std::move(album_table_files_.category_file), |
| 92 utility_process_host_->GetData().handle); | 94 utility_process_host_->GetData().handle); |
| 93 files_for_transit.date_file = IPC::TakeFileHandleForProcess( | 95 files_for_transit.date_file = |
| 94 album_table_files_.date_file.Pass(), | 96 IPC::TakeFileHandleForProcess(std::move(album_table_files_.date_file), |
| 95 utility_process_host_->GetData().handle); | 97 utility_process_host_->GetData().handle); |
| 96 files_for_transit.filename_file = IPC::TakeFileHandleForProcess( | 98 files_for_transit.filename_file = |
| 97 album_table_files_.filename_file.Pass(), | 99 IPC::TakeFileHandleForProcess(std::move(album_table_files_.filename_file), |
| 98 utility_process_host_->GetData().handle); | 100 utility_process_host_->GetData().handle); |
| 99 files_for_transit.name_file = IPC::TakeFileHandleForProcess( | 101 files_for_transit.name_file = |
| 100 album_table_files_.name_file.Pass(), | 102 IPC::TakeFileHandleForProcess(std::move(album_table_files_.name_file), |
| 101 utility_process_host_->GetData().handle); | 103 utility_process_host_->GetData().handle); |
| 102 files_for_transit.token_file = IPC::TakeFileHandleForProcess( | 104 files_for_transit.token_file = |
| 103 album_table_files_.token_file.Pass(), | 105 IPC::TakeFileHandleForProcess(std::move(album_table_files_.token_file), |
| 104 utility_process_host_->GetData().handle); | 106 utility_process_host_->GetData().handle); |
| 105 files_for_transit.uid_file = IPC::TakeFileHandleForProcess( | 107 files_for_transit.uid_file = |
| 106 album_table_files_.uid_file.Pass(), | 108 IPC::TakeFileHandleForProcess(std::move(album_table_files_.uid_file), |
| 107 utility_process_host_->GetData().handle); | 109 utility_process_host_->GetData().handle); |
| 108 utility_process_host_->Send(new ChromeUtilityMsg_ParsePicasaPMPDatabase( | 110 utility_process_host_->Send(new ChromeUtilityMsg_ParsePicasaPMPDatabase( |
| 109 files_for_transit)); | 111 files_for_transit)); |
| 110 parser_state_ = STARTED_PARSING_STATE; | 112 parser_state_ = STARTED_PARSING_STATE; |
| 111 } | 113 } |
| 112 | 114 |
| 113 void SafePicasaAlbumTableReader::OnParsePicasaPMPDatabaseFinished( | 115 void SafePicasaAlbumTableReader::OnParsePicasaPMPDatabaseFinished( |
| 114 bool parse_success, | 116 bool parse_success, |
| 115 const std::vector<AlbumInfo>& albums, | 117 const std::vector<AlbumInfo>& albums, |
| 116 const std::vector<AlbumInfo>& folders) { | 118 const std::vector<AlbumInfo>& folders) { |
| 117 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 119 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 137 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ProcessStarted, | 139 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ProcessStarted, |
| 138 OnProcessStarted) | 140 OnProcessStarted) |
| 139 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParsePicasaPMPDatabase_Finished, | 141 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ParsePicasaPMPDatabase_Finished, |
| 140 OnParsePicasaPMPDatabaseFinished) | 142 OnParsePicasaPMPDatabaseFinished) |
| 141 IPC_MESSAGE_UNHANDLED(handled = false) | 143 IPC_MESSAGE_UNHANDLED(handled = false) |
| 142 IPC_END_MESSAGE_MAP() | 144 IPC_END_MESSAGE_MAP() |
| 143 return handled; | 145 return handled; |
| 144 } | 146 } |
| 145 | 147 |
| 146 } // namespace picasa | 148 } // namespace picasa |
| OLD | NEW |