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 "chrome_frame/test/chrome_frame_test_utils.h" | 5 #include "chrome_frame/test/chrome_frame_test_utils.h" |
6 | 6 |
7 #include <atlapp.h> | 7 #include <atlapp.h> |
8 #include <atlmisc.h> | 8 #include <atlmisc.h> |
9 #include <iepmapi.h> | 9 #include <iepmapi.h> |
10 #include <sddl.h> | 10 #include <sddl.h> |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 "existing process and leave it running after tests complete."; | 633 "existing process and leave it running after tests complete."; |
634 return NULL; | 634 return NULL; |
635 } | 635 } |
636 | 636 |
637 base::FilePath exe_dir; | 637 base::FilePath exe_dir; |
638 if (!PathService::Get(base::DIR_EXE, &exe_dir)) { | 638 if (!PathService::Get(base::DIR_EXE, &exe_dir)) { |
639 DCHECK(false); | 639 DCHECK(false); |
640 return NULL; | 640 return NULL; |
641 } | 641 } |
642 | 642 |
643 base::win::ScopedHandle crash_service; | 643 base::ProcessHandle crash_service = NULL; |
644 | 644 |
645 VLOG(1) << "Starting crash_service.exe so you know if a test crashes!"; | 645 VLOG(1) << "Starting crash_service.exe so you know if a test crashes!"; |
646 | 646 |
647 base::FilePath crash_service_path = exe_dir.AppendASCII("crash_service.exe"); | 647 base::FilePath crash_service_path = exe_dir.AppendASCII("crash_service.exe"); |
648 if (!base::LaunchProcess(crash_service_path.value(), base::LaunchOptions(), | 648 if (!base::LaunchProcess(crash_service_path.value(), base::LaunchOptions(), |
649 &crash_service)) { | 649 &crash_service)) { |
650 LOG(ERROR) << "Couldn't start crash_service.exe"; | 650 LOG(ERROR) << "Couldn't start crash_service.exe"; |
651 return NULL; | 651 return NULL; |
652 } | 652 } |
653 | 653 |
654 base::Time start = base::Time::Now(); | 654 base::Time start = base::Time::Now(); |
655 | 655 |
656 if (DetectRunningCrashService(kCrashServiceStartupTimeoutMs)) { | 656 if (DetectRunningCrashService(kCrashServiceStartupTimeoutMs)) { |
657 VLOG(1) << "crash_service.exe is ready for clients in " | 657 VLOG(1) << "crash_service.exe is ready for clients in " |
658 << (base::Time::Now() - start).InMilliseconds() << " ms."; | 658 << (base::Time::Now() - start).InMilliseconds() << " ms."; |
659 return crash_service.Take(); | 659 return crash_service; |
660 } else { | 660 } else { |
661 LOG(ERROR) << "crash_service.exe failed to accept client connections " | 661 LOG(ERROR) << "crash_service.exe failed to accept client connections " |
662 "within " << kCrashServiceStartupTimeoutMs << " ms. " | 662 "within " << kCrashServiceStartupTimeoutMs << " ms. " |
663 "Terminating it now."; | 663 "Terminating it now."; |
664 | 664 |
665 // First check to see if it's even still running just to minimize the | 665 // First check to see if it's even still running just to minimize the |
666 // likelihood of spurious error messages from KillProcess. | 666 // likelihood of spurious error messages from KillProcess. |
667 if (WAIT_OBJECT_0 != ::WaitForSingleObject(crash_service.Get(), 0)) { | 667 if (WAIT_OBJECT_0 != ::WaitForSingleObject(crash_service, 0)) { |
668 base::KillProcess(crash_service.Get(), 0, false); | 668 base::KillProcess(crash_service, 0, false); |
669 } | 669 } |
670 return NULL; | 670 return NULL; |
671 } | 671 } |
672 } | 672 } |
673 | 673 |
674 ScopedVirtualizeHklmAndHkcu::ScopedVirtualizeHklmAndHkcu() { | 674 ScopedVirtualizeHklmAndHkcu::ScopedVirtualizeHklmAndHkcu() { |
675 override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE, L"hklm_fake"); | 675 override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE, L"hklm_fake"); |
676 override_manager_.OverrideRegistry(HKEY_CURRENT_USER, L"hkcu_fake"); | 676 override_manager_.OverrideRegistry(HKEY_CURRENT_USER, L"hkcu_fake"); |
677 } | 677 } |
678 | 678 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 if (address.empty()) { | 736 if (address.empty()) { |
737 LOG(ERROR) << "Failed to find a non-loopback IP_V4 address. Tests will be " | 737 LOG(ERROR) << "Failed to find a non-loopback IP_V4 address. Tests will be " |
738 << "run over the loopback adapter, which may result in hangs."; | 738 << "run over the loopback adapter, which may result in hangs."; |
739 address.assign("127.0.0.1"); | 739 address.assign("127.0.0.1"); |
740 } | 740 } |
741 | 741 |
742 return address; | 742 return address; |
743 } | 743 } |
744 | 744 |
745 } // namespace chrome_frame_test | 745 } // namespace chrome_frame_test |
OLD | NEW |