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

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

Issue 1060033003: [chrome/browser/safe_browsing] favor DCHECK_CURRENTLY_ON for better logs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed unit test break now Created 5 years, 8 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 16 matching lines...) Expand all
27 27
28 SandboxedZipAnalyzer::SandboxedZipAnalyzer( 28 SandboxedZipAnalyzer::SandboxedZipAnalyzer(
29 const base::FilePath& zip_file, 29 const base::FilePath& zip_file,
30 const ResultCallback& result_callback) 30 const ResultCallback& result_callback)
31 : zip_file_name_(zip_file), 31 : zip_file_name_(zip_file),
32 callback_(result_callback), 32 callback_(result_callback),
33 callback_called_(false) { 33 callback_called_(false) {
34 } 34 }
35 35
36 void SandboxedZipAnalyzer::Start() { 36 void SandboxedZipAnalyzer::Start() {
37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 37 DCHECK_CURRENTLY_ON(BrowserThread::UI);
38 // Starting the analyzer will block on opening the zip file, so run this 38 // Starting the analyzer will block on opening the zip file, so run this
39 // on a worker thread. The task does not need to block shutdown. 39 // on a worker thread. The task does not need to block shutdown.
40 if (!BrowserThread::GetBlockingPool()->PostWorkerTaskWithShutdownBehavior( 40 if (!BrowserThread::GetBlockingPool()->PostWorkerTaskWithShutdownBehavior(
41 FROM_HERE, 41 FROM_HERE,
42 base::Bind(&SandboxedZipAnalyzer::AnalyzeInSandbox, this), 42 base::Bind(&SandboxedZipAnalyzer::AnalyzeInSandbox, this),
43 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN)) { 43 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN)) {
44 NOTREACHED(); 44 NOTREACHED();
45 } 45 }
46 } 46 }
47 47
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 OnUtilityProcessStarted) 105 OnUtilityProcessStarted)
106 IPC_MESSAGE_HANDLER( 106 IPC_MESSAGE_HANDLER(
107 ChromeUtilityHostMsg_AnalyzeZipFileForDownloadProtection_Finished, 107 ChromeUtilityHostMsg_AnalyzeZipFileForDownloadProtection_Finished,
108 OnAnalyzeZipFileFinished) 108 OnAnalyzeZipFileFinished)
109 IPC_MESSAGE_UNHANDLED(handled = false) 109 IPC_MESSAGE_UNHANDLED(handled = false)
110 IPC_END_MESSAGE_MAP() 110 IPC_END_MESSAGE_MAP()
111 return handled; 111 return handled;
112 } 112 }
113 113
114 void SandboxedZipAnalyzer::StartProcessOnIOThread() { 114 void SandboxedZipAnalyzer::StartProcessOnIOThread() {
115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 115 DCHECK_CURRENTLY_ON(BrowserThread::IO);
116 utility_process_host_ = content::UtilityProcessHost::Create( 116 utility_process_host_ = content::UtilityProcessHost::Create(
117 this, 117 this,
118 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get()) 118 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get())
119 ->AsWeakPtr(); 119 ->AsWeakPtr();
120 utility_process_host_->SetName(l10n_util::GetStringUTF16( 120 utility_process_host_->SetName(l10n_util::GetStringUTF16(
121 IDS_UTILITY_PROCESS_SAFE_BROWSING_ZIP_FILE_ANALYZER_NAME)); 121 IDS_UTILITY_PROCESS_SAFE_BROWSING_ZIP_FILE_ANALYZER_NAME));
122 utility_process_host_->Send(new ChromeUtilityMsg_StartupPing); 122 utility_process_host_->Send(new ChromeUtilityMsg_StartupPing);
123 // Wait for the startup notification before sending the main IPC to the 123 // Wait for the startup notification before sending the main IPC to the
124 // utility process, so that we can dup the file handle. 124 // utility process, so that we can dup the file handle.
125 } 125 }
126 126
127 void SandboxedZipAnalyzer::OnUtilityProcessStarted() { 127 void SandboxedZipAnalyzer::OnUtilityProcessStarted() {
128 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 128 DCHECK_CURRENTLY_ON(BrowserThread::IO);
129 base::ProcessHandle utility_process = 129 base::ProcessHandle utility_process =
130 content::RenderProcessHost::run_renderer_in_process() ? 130 content::RenderProcessHost::run_renderer_in_process() ?
131 base::GetCurrentProcessHandle() : 131 base::GetCurrentProcessHandle() :
132 utility_process_host_->GetData().handle; 132 utility_process_host_->GetData().handle;
133 133
134 if (utility_process == base::kNullProcessHandle) { 134 if (utility_process == base::kNullProcessHandle) {
135 DLOG(ERROR) << "Child process handle is null"; 135 DLOG(ERROR) << "Child process handle is null";
136 } 136 }
137 utility_process_host_->Send( 137 utility_process_host_->Send(
138 new ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection( 138 new ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection(
139 IPC::TakeFileHandleForProcess(zip_file_.Pass(), utility_process), 139 IPC::TakeFileHandleForProcess(zip_file_.Pass(), utility_process),
140 IPC::GetFileHandleForProcess(temp_file_.GetPlatformFile(), 140 IPC::GetFileHandleForProcess(temp_file_.GetPlatformFile(),
141 utility_process, 141 utility_process,
142 false /* !close_source_handle */))); 142 false /* !close_source_handle */)));
143 } 143 }
144 144
145 void SandboxedZipAnalyzer::OnAnalyzeZipFileFinished( 145 void SandboxedZipAnalyzer::OnAnalyzeZipFileFinished(
146 const zip_analyzer::Results& results) { 146 const zip_analyzer::Results& results) {
147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 147 DCHECK_CURRENTLY_ON(BrowserThread::IO);
148 if (callback_called_) 148 if (callback_called_)
149 return; 149 return;
150 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 150 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
151 base::Bind(callback_, results)); 151 base::Bind(callback_, results));
152 callback_called_ = true; 152 callback_called_ = true;
153 CloseTemporaryFile(); 153 CloseTemporaryFile();
154 } 154 }
155 155
156 } // namespace safe_browsing 156 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service.cc ('k') | chrome/browser/safe_browsing/ui_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698