diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-28 17:27:17 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-28 17:27:17 +0000 |
commit | 79b663c6e6ddf89e85cdc566b5d4f368465bb858 (patch) | |
tree | 868c35191ee02c8bd7da15b69edc7114007e211a /chrome_frame/chrome_launcher_utils.cc | |
parent | 84b5647e4a43a55b9b0e8b211684f48222569218 (diff) | |
download | chromium_src-79b663c6e6ddf89e85cdc566b5d4f368465bb858.zip chromium_src-79b663c6e6ddf89e85cdc566b5d4f368465bb858.tar.gz chromium_src-79b663c6e6ddf89e85cdc566b5d4f368465bb858.tar.bz2 |
Rewrite of chrome_launcher.exe. ETW-based perf tests suggest that this is on average about 50% faster than the previous version.
Review URL: http://codereview.chromium.org/2278003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48500 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/chrome_launcher_utils.cc')
-rw-r--r-- | chrome_frame/chrome_launcher_utils.cc | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/chrome_frame/chrome_launcher_utils.cc b/chrome_frame/chrome_launcher_utils.cc new file mode 100644 index 0000000..913ff14 --- /dev/null +++ b/chrome_frame/chrome_launcher_utils.cc @@ -0,0 +1,68 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome_frame/chrome_launcher_utils.h" + +#include "base/base_switches.h" +#include "base/command_line.h" +#include "base/file_util.h" +#include "base/logging.h" +#include "base/path_service.h" +#include "base/win_util.h" +#include "chrome/common/chrome_constants.h" +#include "chrome/common/chrome_switches.h" +#include "chrome_frame/chrome_frame_automation.h" + +namespace chrome_launcher { + +const wchar_t kLauncherExeBaseName[] = L"chrome_launcher.exe"; + +CommandLine* CreateLaunchCommandLine() { + // Shortcut for OS versions that don't need the integrity broker. + if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { + return new CommandLine(GetChromeExecutablePath()); + } + + // The launcher EXE will be in the same directory as the Chrome Frame DLL, + // so create a full path to it based on this assumption. Since our unit + // tests also use this function, and live in the directory above, we test + // existence of the file and try the path that includes the /servers/ + // directory if needed. + FilePath module_path; + if (PathService::Get(base::FILE_MODULE, &module_path)) { + FilePath current_dir = module_path.DirName(); + FilePath same_dir_path = current_dir.Append(kLauncherExeBaseName); + if (file_util::PathExists(same_dir_path)) { + return new CommandLine(same_dir_path); + } else { + FilePath servers_path = + current_dir.Append(L"servers").Append(kLauncherExeBaseName); + DCHECK(file_util::PathExists(servers_path)) << + "What module is this? It's not in 'servers' or main output dir."; + return new CommandLine(servers_path); + } + } else { + NOTREACHED(); + return NULL; + } +} + +FilePath GetChromeExecutablePath() { + FilePath cur_path; + PathService::Get(base::DIR_MODULE, &cur_path); + cur_path = cur_path.Append(chrome::kBrowserProcessExecutableName); + + // The installation model for Chrome places the DLLs in a versioned + // sub-folder one down from the Chrome executable. If we fail to find + // chrome.exe in the current path, try looking one up and launching that + // instead. + if (!file_util::PathExists(cur_path)) { + PathService::Get(base::DIR_MODULE, &cur_path); + cur_path = cur_path.DirName().Append(chrome::kBrowserProcessExecutableName); + } + + return cur_path; +} + +} // namespace chrome_launcher |