Chromium Code Reviews| 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 <windows.h> // NOLINT | 5 #include <windows.h> // NOLINT |
| 6 #include <shlwapi.h> // NOLINT | 6 #include <shlwapi.h> // NOLINT |
| 7 | 7 |
| 8 #include "chrome/app/main_dll_loader_win.h" | 8 #include "chrome/app/main_dll_loader_win.h" |
| 9 | 9 |
| 10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
| 11 #include "base/base_switches.h" | 11 #include "base/base_switches.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/environment.h" | 14 #include "base/environment.h" |
| 15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 19 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
| 20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 21 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
| 22 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 23 #include "base/threading/platform_thread.h" | 23 #include "base/threading/platform_thread.h" |
| 24 #include "base/trace_event/trace_event.h" | 24 #include "base/trace_event/trace_event.h" |
| 25 #include "base/win/metro.h" | 25 #include "base/win/metro.h" |
| 26 #include "base/win/scoped_handle.h" | 26 #include "base/win/scoped_handle.h" |
| 27 #include "base/win/windows_version.h" | 27 #include "base/win/windows_version.h" |
| 28 #include "chrome/app/chrome_crash_reporter_client.h" | |
| 29 #include "chrome/app/chrome_watcher_client_win.h" | 28 #include "chrome/app/chrome_watcher_client_win.h" |
| 30 #include "chrome/app/chrome_watcher_command_line_win.h" | 29 #include "chrome/app/chrome_watcher_command_line_win.h" |
| 31 #include "chrome/app/file_pre_reader_win.h" | 30 #include "chrome/app/file_pre_reader_win.h" |
| 32 #include "chrome/app/kasko_client.h" | 31 #include "chrome/app/kasko_client.h" |
| 33 #include "chrome/chrome_watcher/chrome_watcher_main_api.h" | 32 #include "chrome/chrome_watcher/chrome_watcher_main_api.h" |
| 34 #include "chrome/common/chrome_constants.h" | 33 #include "chrome/common/chrome_constants.h" |
| 35 #include "chrome/common/chrome_paths.h" | 34 #include "chrome/common/chrome_paths.h" |
| 36 #include "chrome/common/chrome_result_codes.h" | 35 #include "chrome/common/chrome_result_codes.h" |
| 37 #include "chrome/common/chrome_switches.h" | 36 #include "chrome/common/chrome_switches.h" |
| 38 #include "chrome/common/env_vars.h" | 37 #include "chrome/common/env_vars.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 HMODULE metro_dll = Load(&version, &file); | 162 HMODULE metro_dll = Load(&version, &file); |
| 164 if (!metro_dll) | 163 if (!metro_dll) |
| 165 return chrome::RESULT_CODE_MISSING_DATA; | 164 return chrome::RESULT_CODE_MISSING_DATA; |
| 166 | 165 |
| 167 InitMetro chrome_metro_main = | 166 InitMetro chrome_metro_main = |
| 168 reinterpret_cast<InitMetro>(::GetProcAddress(metro_dll, "InitMetro")); | 167 reinterpret_cast<InitMetro>(::GetProcAddress(metro_dll, "InitMetro")); |
| 169 return chrome_metro_main(); | 168 return chrome_metro_main(); |
| 170 } | 169 } |
| 171 | 170 |
| 172 if (process_type_ == "watcher") { | 171 if (process_type_ == "watcher") { |
| 173 chrome::RegisterPathProvider(); | |
| 174 | |
| 175 base::win::ScopedHandle parent_process; | 172 base::win::ScopedHandle parent_process; |
| 176 base::win::ScopedHandle on_initialized_event; | 173 base::win::ScopedHandle on_initialized_event; |
| 177 DWORD main_thread_id = 0; | 174 DWORD main_thread_id = 0; |
| 178 if (!InterpretChromeWatcherCommandLine(cmd_line, &parent_process, | 175 if (!InterpretChromeWatcherCommandLine(cmd_line, &parent_process, |
| 179 &main_thread_id, | 176 &main_thread_id, |
| 180 &on_initialized_event)) { | 177 &on_initialized_event)) { |
| 181 return chrome::RESULT_CODE_UNSUPPORTED_PARAM; | 178 return chrome::RESULT_CODE_UNSUPPORTED_PARAM; |
| 182 } | 179 } |
| 183 | 180 |
| 184 base::FilePath default_user_data_directory; | 181 base::FilePath default_user_data_directory; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 208 ::GetProcAddress(watcher_dll, kChromeWatcherDLLEntrypoint)); | 205 ::GetProcAddress(watcher_dll, kChromeWatcherDLLEntrypoint)); |
| 209 return watcher_main(chrome::kBrowserExitCodesRegistryPath, | 206 return watcher_main(chrome::kBrowserExitCodesRegistryPath, |
| 210 parent_process.Take(), main_thread_id, | 207 parent_process.Take(), main_thread_id, |
| 211 on_initialized_event.Take(), | 208 on_initialized_event.Take(), |
| 212 watcher_data_directory.value().c_str(), | 209 watcher_data_directory.value().c_str(), |
| 213 message_window_name.c_str(), channel_name.c_str()); | 210 message_window_name.c_str(), channel_name.c_str()); |
| 214 } | 211 } |
| 215 | 212 |
| 216 // Initialize the sandbox services. | 213 // Initialize the sandbox services. |
| 217 sandbox::SandboxInterfaceInfo sandbox_info = {0}; | 214 sandbox::SandboxInterfaceInfo sandbox_info = {0}; |
| 218 content::InitializeSandboxInfo(&sandbox_info); | 215 content::InitializeSandboxInfo(&sandbox_info); |
|
cpu_(ooo_6.6-7.5)
2015/12/02 19:12:26
this is what I was talking about sharing c++ acros
scottmg
2015/12/02 21:57:29
Thanks, copied something like that.
| |
| 219 | 216 |
| 220 dll_ = Load(&version, &file); | 217 dll_ = Load(&version, &file); |
| 221 if (!dll_) | 218 if (!dll_) |
| 222 return chrome::RESULT_CODE_MISSING_DATA; | 219 return chrome::RESULT_CODE_MISSING_DATA; |
| 223 | 220 |
| 224 scoped_ptr<base::Environment> env(base::Environment::Create()); | 221 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 225 env->SetVar(chrome::kChromeVersionEnvVar, base::WideToUTF8(version)); | 222 env->SetVar(chrome::kChromeVersionEnvVar, base::WideToUTF8(version)); |
| 226 | 223 |
| 227 OnBeforeLaunch(process_type_, file); | 224 OnBeforeLaunch(process_type_, file); |
| 228 DLL_MAIN chrome_main = | 225 DLL_MAIN chrome_main = |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 312 ::SetProcessShutdownParameters(0x280 - 1, SHUTDOWN_NORETRY); | 309 ::SetProcessShutdownParameters(0x280 - 1, SHUTDOWN_NORETRY); |
| 313 } | 310 } |
| 314 } | 311 } |
| 315 | 312 |
| 316 int ChromeDllLoader::OnBeforeExit(int return_code, | 313 int ChromeDllLoader::OnBeforeExit(int return_code, |
| 317 const base::FilePath& dll_path) { | 314 const base::FilePath& dll_path) { |
| 318 // NORMAL_EXIT_CANCEL is used for experiments when the user cancels | 315 // NORMAL_EXIT_CANCEL is used for experiments when the user cancels |
| 319 // so we need to reset the did_run signal so omaha does not count | 316 // so we need to reset the did_run signal so omaha does not count |
| 320 // this run as active usage. | 317 // this run as active usage. |
| 321 if (chrome::RESULT_CODE_NORMAL_EXIT_CANCEL == return_code) { | 318 if (chrome::RESULT_CODE_NORMAL_EXIT_CANCEL == return_code) { |
| 322 ClearDidRun(dll_path); | 319 ClearDidRun(dll_path); |
|
cpu_(ooo_6.6-7.5)
2015/12/02 19:12:26
can you place a breakpoint here? we want to make s
scottmg
2015/12/02 21:57:30
This function gets called for most processes (othe
| |
| 323 } | 320 } |
| 324 | 321 |
| 325 #if defined(KASKO) | 322 #if defined(KASKO) |
| 326 kasko_client_.reset(); | 323 kasko_client_.reset(); |
| 327 #endif // KASKO | 324 #endif // KASKO |
| 328 chrome_watcher_client_.reset(); | 325 chrome_watcher_client_.reset(); |
| 329 | 326 |
| 330 return return_code; | 327 return return_code; |
| 331 } | 328 } |
| 332 | 329 |
| 333 //============================================================================= | 330 //============================================================================= |
| 334 | 331 |
| 335 class ChromiumDllLoader : public MainDllLoader { | 332 class ChromiumDllLoader : public MainDllLoader { |
| 336 protected: | 333 protected: |
| 337 void OnBeforeLaunch(const std::string& process_type, | 334 void OnBeforeLaunch(const std::string& process_type, |
| 338 const base::FilePath& dll_path) override {} | 335 const base::FilePath& dll_path) override {} |
| 339 int OnBeforeExit(int return_code, const base::FilePath& dll_path) override { | 336 int OnBeforeExit(int return_code, const base::FilePath& dll_path) override { |
| 340 return return_code; | 337 return return_code; |
| 341 } | 338 } |
| 342 }; | 339 }; |
| 343 | 340 |
| 344 MainDllLoader* MakeMainDllLoader() { | 341 MainDllLoader* MakeMainDllLoader() { |
| 345 #if defined(GOOGLE_CHROME_BUILD) | 342 #if defined(GOOGLE_CHROME_BUILD) |
| 346 return new ChromeDllLoader(); | 343 return new ChromeDllLoader(); |
| 347 #else | 344 #else |
| 348 return new ChromiumDllLoader(); | 345 return new ChromiumDllLoader(); |
| 349 #endif | 346 #endif |
| 350 } | 347 } |
| OLD | NEW |