| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <windows.h> | 5 #include <windows.h> |
| 6 | 6 |
| 7 #include <fstream> | 7 #include <fstream> |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 ASSERT_TRUE(file_util::PathExists(file_name_delete_2)); | 174 ASSERT_TRUE(file_util::PathExists(file_name_delete_2)); |
| 175 | 175 |
| 176 // Create a key path file. | 176 // Create a key path file. |
| 177 base::FilePath key_path(dir_name_delete); | 177 base::FilePath key_path(dir_name_delete); |
| 178 key_path = key_path.AppendASCII("key_file.exe"); | 178 key_path = key_path.AppendASCII("key_file.exe"); |
| 179 | 179 |
| 180 wchar_t exe_full_path_str[MAX_PATH]; | 180 wchar_t exe_full_path_str[MAX_PATH]; |
| 181 ::GetModuleFileNameW(NULL, exe_full_path_str, MAX_PATH); | 181 ::GetModuleFileNameW(NULL, exe_full_path_str, MAX_PATH); |
| 182 base::FilePath exe_full_path(exe_full_path_str); | 182 base::FilePath exe_full_path(exe_full_path_str); |
| 183 | 183 |
| 184 file_util::CopyFile(exe_full_path, key_path); | 184 base::CopyFile(exe_full_path, key_path); |
| 185 ASSERT_TRUE(file_util::PathExists(key_path)); | 185 ASSERT_TRUE(file_util::PathExists(key_path)); |
| 186 | 186 |
| 187 VLOG(1) << "copy ourself from " << exe_full_path.value() | 187 VLOG(1) << "copy ourself from " << exe_full_path.value() |
| 188 << " to " << key_path.value(); | 188 << " to " << key_path.value(); |
| 189 | 189 |
| 190 // Run the key path file to keep it in use. | 190 // Run the key path file to keep it in use. |
| 191 STARTUPINFOW si = {sizeof(si)}; | 191 STARTUPINFOW si = {sizeof(si)}; |
| 192 PROCESS_INFORMATION pi = {0}; | 192 PROCESS_INFORMATION pi = {0}; |
| 193 ASSERT_TRUE( | 193 ASSERT_TRUE( |
| 194 ::CreateProcessW(NULL, const_cast<wchar_t*>(key_path.value().c_str()), | 194 ::CreateProcessW(NULL, const_cast<wchar_t*>(key_path.value().c_str()), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 211 | 211 |
| 212 // verify everything is still there. | 212 // verify everything is still there. |
| 213 EXPECT_TRUE(file_util::PathExists(key_path)); | 213 EXPECT_TRUE(file_util::PathExists(key_path)); |
| 214 EXPECT_TRUE(file_util::PathExists(file_name_delete_1)); | 214 EXPECT_TRUE(file_util::PathExists(file_name_delete_1)); |
| 215 EXPECT_TRUE(file_util::PathExists(file_name_delete_2)); | 215 EXPECT_TRUE(file_util::PathExists(file_name_delete_2)); |
| 216 | 216 |
| 217 TerminateProcess(pi.hProcess, 0); | 217 TerminateProcess(pi.hProcess, 0); |
| 218 // make sure the handle is closed. | 218 // make sure the handle is closed. |
| 219 WaitForSingleObject(pi.hProcess, INFINITE); | 219 WaitForSingleObject(pi.hProcess, INFINITE); |
| 220 } | 220 } |
| OLD | NEW |