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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
11 #include "chrome/common/chrome_utility_messages.h" | 11 #include "chrome/common/chrome_utility_messages.h" |
12 #include "chrome/grit/generated_resources.h" | |
12 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
13 #include "content/public/browser/utility_process_host.h" | 14 #include "content/public/browser/utility_process_host.h" |
15 #include "ui/base/l10n/l10n_util.h" | |
14 | 16 |
15 using content::BrowserThread; | 17 using content::BrowserThread; |
16 using content::UtilityProcessHost; | 18 using content::UtilityProcessHost; |
17 | 19 |
18 namespace { | 20 namespace { |
19 | 21 |
20 // Creates the destination zip file only if it does not already exist. | 22 // Creates the destination zip file only if it does not already exist. |
21 base::File OpenFileHandleOnBlockingThreadPool(const base::FilePath& zip_path) { | 23 base::File OpenFileHandleOnBlockingThreadPool(const base::FilePath& zip_path) { |
22 return base::File(zip_path, base::File::FLAG_CREATE | base::File::FLAG_WRITE); | 24 return base::File(zip_path, base::File::FLAG_CREATE | base::File::FLAG_WRITE); |
23 } | 25 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 } | 86 } |
85 | 87 |
86 void ZipFileCreator::StartProcessOnIOThread(base::File dest_file) { | 88 void ZipFileCreator::StartProcessOnIOThread(base::File dest_file) { |
87 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 89 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
88 | 90 |
89 base::FileDescriptor dest_fd(dest_file.Pass()); | 91 base::FileDescriptor dest_fd(dest_file.Pass()); |
90 | 92 |
91 UtilityProcessHost* host = UtilityProcessHost::Create( | 93 UtilityProcessHost* host = UtilityProcessHost::Create( |
92 this, | 94 this, |
93 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI).get()); | 95 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI).get()); |
96 host->SetName( | |
97 l10n_util::GetStringUTF16(IDS_UTILITY_PROCESS_PROXY_RESOLVER_NAME)); | |
Charlie Reis
2015/04/06 23:47:40
This should be IDS_UTILITY_PROCESS_ZIP_FILE_CREATO
| |
94 host->SetExposedDir(src_dir_); | 98 host->SetExposedDir(src_dir_); |
95 host->Send(new ChromeUtilityMsg_CreateZipFile(src_dir_, src_relative_paths_, | 99 host->Send(new ChromeUtilityMsg_CreateZipFile(src_dir_, src_relative_paths_, |
96 dest_fd)); | 100 dest_fd)); |
97 } | 101 } |
98 | 102 |
99 void ZipFileCreator::OnCreateZipFileSucceeded() { | 103 void ZipFileCreator::OnCreateZipFileSucceeded() { |
100 ReportDone(true); | 104 ReportDone(true); |
101 } | 105 } |
102 | 106 |
103 void ZipFileCreator::OnCreateZipFileFailed() { | 107 void ZipFileCreator::OnCreateZipFileFailed() { |
104 ReportDone(false); | 108 ReportDone(false); |
105 } | 109 } |
106 | 110 |
107 void ZipFileCreator::ReportDone(bool success) { | 111 void ZipFileCreator::ReportDone(bool success) { |
108 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 112 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
109 | 113 |
110 // Guard against calling observer multiple times. | 114 // Guard against calling observer multiple times. |
111 if (!callback_.is_null()) | 115 if (!callback_.is_null()) |
112 base::ResetAndReturn(&callback_).Run(success); | 116 base::ResetAndReturn(&callback_).Run(success); |
113 } | 117 } |
114 | 118 |
115 } // namespace file_manager | 119 } // namespace file_manager |
OLD | NEW |