| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/file_manager/zip_file_creator.h" | 5 #include "chrome/browser/chromeos/file_manager/zip_file_creator.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 base::Bind( | 86 base::Bind( |
| 87 &ZipFileCreator::StartProcessOnIOThread, this, base::Passed(&file))); | 87 &ZipFileCreator::StartProcessOnIOThread, this, base::Passed(&file))); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void ZipFileCreator::StartProcessOnIOThread(base::File dest_file) { | 90 void ZipFileCreator::StartProcessOnIOThread(base::File dest_file) { |
| 91 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 91 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 92 | 92 |
| 93 base::FileDescriptor dest_fd(std::move(dest_file)); | 93 base::FileDescriptor dest_fd(std::move(dest_file)); |
| 94 | 94 |
| 95 UtilityProcessHost* host = UtilityProcessHost::Create( | 95 UtilityProcessHost* host = UtilityProcessHost::Create( |
| 96 this, | 96 this, BrowserThread::GetTaskRunnerForThread(BrowserThread::UI).get()); |
| 97 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI).get()); | |
| 98 host->SetName( | 97 host->SetName( |
| 99 l10n_util::GetStringUTF16(IDS_UTILITY_PROCESS_ZIP_FILE_CREATOR_NAME)); | 98 l10n_util::GetStringUTF16(IDS_UTILITY_PROCESS_ZIP_FILE_CREATOR_NAME)); |
| 100 host->SetExposedDir(src_dir_); | 99 host->SetExposedDir(src_dir_); |
| 101 host->Send(new ChromeUtilityMsg_CreateZipFile(src_dir_, src_relative_paths_, | 100 host->Send(new ChromeUtilityMsg_CreateZipFile(src_dir_, src_relative_paths_, |
| 102 dest_fd)); | 101 dest_fd)); |
| 103 } | 102 } |
| 104 | 103 |
| 105 void ZipFileCreator::OnCreateZipFileSucceeded() { | 104 void ZipFileCreator::OnCreateZipFileSucceeded() { |
| 106 ReportDone(true); | 105 ReportDone(true); |
| 107 } | 106 } |
| 108 | 107 |
| 109 void ZipFileCreator::OnCreateZipFileFailed() { | 108 void ZipFileCreator::OnCreateZipFileFailed() { |
| 110 ReportDone(false); | 109 ReportDone(false); |
| 111 } | 110 } |
| 112 | 111 |
| 113 void ZipFileCreator::ReportDone(bool success) { | 112 void ZipFileCreator::ReportDone(bool success) { |
| 114 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 113 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 115 | 114 |
| 116 // Guard against calling observer multiple times. | 115 // Guard against calling observer multiple times. |
| 117 if (!callback_.is_null()) | 116 if (!callback_.is_null()) |
| 118 base::ResetAndReturn(&callback_).Run(success); | 117 base::ResetAndReturn(&callback_).Run(success); |
| 119 } | 118 } |
| 120 | 119 |
| 121 } // namespace file_manager | 120 } // namespace file_manager |
| OLD | NEW |