Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/chrome_cleaner/mock_chrome_cleaner_proces s_win.h" | 5 #include "chrome/browser/safe_browsing/chrome_cleaner/mock_chrome_cleaner_proces s_win.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 chrome_prompt_ptr_->Bind(std::move(prompt_ptr_info)); | 194 chrome_prompt_ptr_->Bind(std::move(prompt_ptr_info)); |
| 195 | 195 |
| 196 if (options_.crash_point() == CrashPoint::kAfterRequestSent) { | 196 if (options_.crash_point() == CrashPoint::kAfterRequestSent) { |
| 197 // This task is posted to the IPC thread so that it will happen after the | 197 // This task is posted to the IPC thread so that it will happen after the |
| 198 // request is sent to the parent process and before the response gets | 198 // request is sent to the parent process and before the response gets |
| 199 // handled on the IPC thread. | 199 // handled on the IPC thread. |
| 200 base::SequencedTaskRunnerHandle::Get()->PostTask( | 200 base::SequencedTaskRunnerHandle::Get()->PostTask( |
| 201 FROM_HERE, base::Bind([]() { exit(kDeliberateCrashExitCode); })); | 201 FROM_HERE, base::Bind([]() { exit(kDeliberateCrashExitCode); })); |
| 202 } | 202 } |
| 203 | 203 |
| 204 std::vector<chrome_cleaner::mojom::FilePathPtr> files_to_delete; | |
|
Fabio Tirelo
2017/06/12 18:20:46
This only needs to be done if condition in line 21
proberge
2017/06/12 19:02:53
Line 214 looks like a pointer deref? Not a conditi
| |
| 205 for (const base::FilePath& file_path : options_.files_to_delete()) { | |
| 206 auto data = reinterpret_cast<const uint16_t*>(file_path.value().c_str()); | |
| 207 size_t data_size = file_path.value().size(); | |
| 208 chrome_cleaner::mojom::FilePathPtr path = | |
| 209 chrome_cleaner::mojom::FilePath::New( | |
| 210 std::vector<uint16_t>(data, data + data_size)); | |
| 211 files_to_delete.push_back(std::move(path)); | |
| 212 } | |
| 213 | |
| 204 (*chrome_prompt_ptr_) | 214 (*chrome_prompt_ptr_) |
| 205 ->PromptUser( | 215 ->PromptUser( |
| 206 std::vector<base::FilePath>(options_.files_to_delete().begin(), | 216 std::move(files_to_delete), |
| 207 options_.files_to_delete().end()), | |
| 208 base::BindOnce(&MockChromeCleanerProcess::PromptUserCallback, | 217 base::BindOnce(&MockChromeCleanerProcess::PromptUserCallback, |
| 209 base::Unretained(this), std::move(quit_closure))); | 218 base::Unretained(this), std::move(quit_closure))); |
| 210 } | 219 } |
| 211 | 220 |
| 212 void MockChromeCleanerProcess::PromptUserCallback( | 221 void MockChromeCleanerProcess::PromptUserCallback( |
| 213 base::OnceClosure quit_closure, | 222 base::OnceClosure quit_closure, |
| 214 PromptAcceptance prompt_acceptance) { | 223 PromptAcceptance prompt_acceptance) { |
| 215 delete chrome_prompt_ptr_; | 224 delete chrome_prompt_ptr_; |
| 216 chrome_prompt_ptr_ = nullptr; | 225 chrome_prompt_ptr_ = nullptr; |
| 217 | 226 |
| 218 received_prompt_acceptance_ = prompt_acceptance; | 227 received_prompt_acceptance_ = prompt_acceptance; |
| 219 | 228 |
| 220 if (options_.crash_point() == CrashPoint::kAfterResponseReceived) | 229 if (options_.crash_point() == CrashPoint::kAfterResponseReceived) |
| 221 exit(kDeliberateCrashExitCode); | 230 exit(kDeliberateCrashExitCode); |
| 222 | 231 |
| 223 std::move(quit_closure).Run(); | 232 std::move(quit_closure).Run(); |
| 224 } | 233 } |
| 225 | 234 |
| 226 } // namespace safe_browsing | 235 } // namespace safe_browsing |
| OLD | NEW |