Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(551)

Side by Side Diff: chrome/browser/safe_browsing/sandboxed_zip_analyzer.cc

Issue 1551503002: Convert Pass()→std::move() in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/safe_browsing/sandboxed_zip_analyzer.h" 5 #include "chrome/browser/safe_browsing/sandboxed_zip_analyzer.h"
6 6
7 #include <utility>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/command_line.h" 10 #include "base/command_line.h"
9 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
10 #include "base/location.h" 12 #include "base/location.h"
11 #include "base/logging.h" 13 #include "base/logging.h"
12 #include "base/threading/sequenced_worker_pool.h" 14 #include "base/threading/sequenced_worker_pool.h"
13 #include "chrome/common/chrome_utility_messages.h" 15 #include "chrome/common/chrome_utility_messages.h"
14 #include "chrome/common/safe_browsing/zip_analyzer_results.h" 16 #include "chrome/common/safe_browsing/zip_analyzer_results.h"
15 #include "chrome/grit/generated_resources.h" 17 #include "chrome/grit/generated_resources.h"
16 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // the UI or IO thread. 52 // the UI or IO thread.
51 CloseTemporaryFile(); 53 CloseTemporaryFile();
52 } 54 }
53 55
54 void SandboxedZipAnalyzer::CloseTemporaryFile() { 56 void SandboxedZipAnalyzer::CloseTemporaryFile() {
55 if (!temp_file_.IsValid()) 57 if (!temp_file_.IsValid())
56 return; 58 return;
57 // Close the temporary file in the blocking pool since doing so will delete 59 // Close the temporary file in the blocking pool since doing so will delete
58 // the file. 60 // the file.
59 if (!BrowserThread::GetBlockingPool()->PostWorkerTaskWithShutdownBehavior( 61 if (!BrowserThread::GetBlockingPool()->PostWorkerTaskWithShutdownBehavior(
60 FROM_HERE, base::Bind(&base::File::Close, 62 FROM_HERE,
61 base::Owned(new base::File(temp_file_.Pass()))), 63 base::Bind(&base::File::Close,
64 base::Owned(new base::File(std::move(temp_file_)))),
62 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN)) { 65 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN)) {
63 NOTREACHED(); 66 NOTREACHED();
64 } 67 }
65 } 68 }
66 69
67 void SandboxedZipAnalyzer::AnalyzeInSandbox() { 70 void SandboxedZipAnalyzer::AnalyzeInSandbox() {
68 // This zip file will be closed on the IO thread once it has been handed 71 // This zip file will be closed on the IO thread once it has been handed
69 // off to the child process. 72 // off to the child process.
70 zip_file_.Initialize(zip_file_name_, 73 zip_file_.Initialize(zip_file_name_,
71 base::File::FLAG_OPEN | base::File::FLAG_READ); 74 base::File::FLAG_OPEN | base::File::FLAG_READ);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 base::ProcessHandle utility_process = 132 base::ProcessHandle utility_process =
130 content::RenderProcessHost::run_renderer_in_process() ? 133 content::RenderProcessHost::run_renderer_in_process() ?
131 base::GetCurrentProcessHandle() : 134 base::GetCurrentProcessHandle() :
132 utility_process_host_->GetData().handle; 135 utility_process_host_->GetData().handle;
133 136
134 if (utility_process == base::kNullProcessHandle) { 137 if (utility_process == base::kNullProcessHandle) {
135 DLOG(ERROR) << "Child process handle is null"; 138 DLOG(ERROR) << "Child process handle is null";
136 } 139 }
137 utility_process_host_->Send( 140 utility_process_host_->Send(
138 new ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection( 141 new ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection(
139 IPC::TakeFileHandleForProcess(zip_file_.Pass(), utility_process), 142 IPC::TakeFileHandleForProcess(std::move(zip_file_), utility_process),
140 IPC::GetFileHandleForProcess(temp_file_.GetPlatformFile(), 143 IPC::GetFileHandleForProcess(temp_file_.GetPlatformFile(),
141 utility_process, 144 utility_process,
142 false /* !close_source_handle */))); 145 false /* !close_source_handle */)));
143 } 146 }
144 147
145 void SandboxedZipAnalyzer::OnAnalyzeZipFileFinished( 148 void SandboxedZipAnalyzer::OnAnalyzeZipFileFinished(
146 const zip_analyzer::Results& results) { 149 const zip_analyzer::Results& results) {
147 DCHECK_CURRENTLY_ON(BrowserThread::IO); 150 DCHECK_CURRENTLY_ON(BrowserThread::IO);
148 if (callback_called_) 151 if (callback_called_)
149 return; 152 return;
150 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 153 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
151 base::Bind(callback_, results)); 154 base::Bind(callback_, results));
152 callback_called_ = true; 155 callback_called_ = true;
153 CloseTemporaryFile(); 156 CloseTemporaryFile();
154 } 157 }
155 158
156 } // namespace safe_browsing 159 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698