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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 sandbox::TargetPolicy* policy = broker_services->CreatePolicy(); | 572 sandbox::TargetPolicy* policy = broker_services->CreatePolicy(); |
573 sandbox::ResultCode result = policy->CreateAlternateDesktop(true); | 573 sandbox::ResultCode result = policy->CreateAlternateDesktop(true); |
574 CHECK(sandbox::SBOX_ERROR_FAILED_TO_SWITCH_BACK_WINSTATION != result); | 574 CHECK(sandbox::SBOX_ERROR_FAILED_TO_SWITCH_BACK_WINSTATION != result); |
575 policy->Release(); | 575 policy->Release(); |
576 } | 576 } |
577 } | 577 } |
578 #endif | 578 #endif |
579 return ChromeTestSuite(argc, argv).Run(); | 579 return ChromeTestSuite(argc, argv).Run(); |
580 } | 580 } |
581 | 581 |
| 582 // The exit manager is in charge of calling the dtors of singleton objects. |
| 583 // On Windows, the call to ChromeMain() below will construct one for the |
| 584 // chrome.dll module, but that global is not shared with this module, so if |
| 585 // chrome.dll calls back out to this module and the called code uses a |
| 586 // singleton, we'll need this. On other platforms, ChromeMain() isn't called |
| 587 // at all below, so this is the lone exit manager for any code after this |
| 588 // point. |
| 589 // NOTE: We can't init this atop main() because ChromeTestSuite, as a subclass |
| 590 // of TestSuite, creates one. So we wait until after the Run() call above to |
| 591 // create the manager for the code path that _doesn't_ use ChromeTestSuite. |
| 592 base::AtExitManager exit_manager; |
| 593 |
582 #if defined(OS_WIN) | 594 #if defined(OS_WIN) |
583 if (command_line->HasSwitch(switches::kProcessType)) { | 595 if (command_line->HasSwitch(switches::kProcessType)) { |
584 // This is a child process, call ChromeMain. | 596 // This is a child process, call ChromeMain. |
585 FilePath chrome_path(command_line->GetProgram().DirName()); | 597 FilePath chrome_path(command_line->GetProgram().DirName()); |
586 chrome_path = chrome_path.Append(chrome::kBrowserResourcesDll); | 598 chrome_path = chrome_path.Append(chrome::kBrowserResourcesDll); |
587 HMODULE dll = LoadLibrary(chrome_path.value().c_str()); | 599 HMODULE dll = LoadLibrary(chrome_path.value().c_str()); |
588 DLL_MAIN entry_point = | 600 DLL_MAIN entry_point = |
589 reinterpret_cast<DLL_MAIN>(::GetProcAddress(dll, "ChromeMain")); | 601 reinterpret_cast<DLL_MAIN>(::GetProcAddress(dll, "ChromeMain")); |
590 if (!entry_point) | 602 if (!entry_point) |
591 return -1; | 603 return -1; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 exit_code = 1; | 640 exit_code = 1; |
629 break; | 641 break; |
630 } | 642 } |
631 | 643 |
632 // Special value "-1" means "repeat indefinitely". | 644 // Special value "-1" means "repeat indefinitely". |
633 if (cycles != -1) | 645 if (cycles != -1) |
634 cycles--; | 646 cycles--; |
635 } | 647 } |
636 return exit_code; | 648 return exit_code; |
637 } | 649 } |
OLD | NEW |