| 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 "content/common/sandbox_win.h" | 5 #include "content/common/sandbox_win.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 policy->SetStdoutHandle(GetStdHandle(STD_OUTPUT_HANDLE)); | 790 policy->SetStdoutHandle(GetStdHandle(STD_OUTPUT_HANDLE)); |
| 791 policy->SetStderrHandle(GetStdHandle(STD_ERROR_HANDLE)); | 791 policy->SetStderrHandle(GetStdHandle(STD_ERROR_HANDLE)); |
| 792 #endif | 792 #endif |
| 793 | 793 |
| 794 if (!delegate->PreSpawnTarget(policy)) | 794 if (!delegate->PreSpawnTarget(policy)) |
| 795 return sandbox::SBOX_ERROR_DELEGATE_PRE_SPAWN; | 795 return sandbox::SBOX_ERROR_DELEGATE_PRE_SPAWN; |
| 796 | 796 |
| 797 TRACE_EVENT_BEGIN0("startup", "StartProcessWithAccess::LAUNCHPROCESS"); | 797 TRACE_EVENT_BEGIN0("startup", "StartProcessWithAccess::LAUNCHPROCESS"); |
| 798 | 798 |
| 799 PROCESS_INFORMATION temp_process_info = {}; | 799 PROCESS_INFORMATION temp_process_info = {}; |
| 800 sandbox::ResultCode last_warning = sandbox::SBOX_ALL_OK; |
| 801 DWORD last_error = ERROR_SUCCESS; |
| 800 result = g_broker_services->SpawnTarget( | 802 result = g_broker_services->SpawnTarget( |
| 801 cmd_line->GetProgram().value().c_str(), | 803 cmd_line->GetProgram().value().c_str(), |
| 802 cmd_line->GetCommandLineString().c_str(), policy, &temp_process_info); | 804 cmd_line->GetCommandLineString().c_str(), policy, &last_warning, |
| 803 DWORD last_error = ::GetLastError(); | 805 &last_error, &temp_process_info); |
| 806 |
| 804 base::win::ScopedProcessInformation target(temp_process_info); | 807 base::win::ScopedProcessInformation target(temp_process_info); |
| 805 | 808 |
| 806 TRACE_EVENT_END0("startup", "StartProcessWithAccess::LAUNCHPROCESS"); | 809 TRACE_EVENT_END0("startup", "StartProcessWithAccess::LAUNCHPROCESS"); |
| 807 | 810 |
| 808 if (sandbox::SBOX_ALL_OK != result) { | 811 if (sandbox::SBOX_ALL_OK != result) { |
| 809 UMA_HISTOGRAM_SPARSE_SLOWLY("Process.Sandbox.Launch.Error", last_error); | 812 UMA_HISTOGRAM_SPARSE_SLOWLY("Process.Sandbox.Launch.Error", last_error); |
| 810 if (result == sandbox::SBOX_ERROR_GENERIC) | 813 if (result == sandbox::SBOX_ERROR_GENERIC) |
| 811 DPLOG(ERROR) << "Failed to launch process"; | 814 DPLOG(ERROR) << "Failed to launch process"; |
| 812 else | 815 else |
| 813 DLOG(ERROR) << "Failed to launch process. Error: " << result; | 816 DLOG(ERROR) << "Failed to launch process. Error: " << result; |
| 814 | 817 |
| 815 return result; | 818 return result; |
| 816 } | 819 } |
| 817 | 820 |
| 821 if (sandbox::SBOX_ALL_OK != last_warning) { |
| 822 UMA_HISTOGRAM_SPARSE_SLOWLY("Process.Sandbox.Launch.WarningResultCode", |
| 823 last_warning); |
| 824 UMA_HISTOGRAM_SPARSE_SLOWLY("Process.Sandbox.Launch.Warning", last_error); |
| 825 } |
| 826 |
| 818 delegate->PostSpawnTarget(target.process_handle()); | 827 delegate->PostSpawnTarget(target.process_handle()); |
| 819 | 828 |
| 820 CHECK(ResumeThread(target.thread_handle()) != static_cast<DWORD>(-1)); | 829 CHECK(ResumeThread(target.thread_handle()) != static_cast<DWORD>(-1)); |
| 821 *process = base::Process(target.TakeProcessHandle()); | 830 *process = base::Process(target.TakeProcessHandle()); |
| 822 return sandbox::SBOX_ALL_OK; | 831 return sandbox::SBOX_ALL_OK; |
| 823 } | 832 } |
| 824 | 833 |
| 825 } // namespace content | 834 } // namespace content |
| OLD | NEW |