Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: chrome/app/client_util.cc

Issue 901673002: Instantiate a Kasko reporter inside the Chrome watcher process, when SyzyASAN instrumented. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ship_kasko
Patch Set: Various tweaks. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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> 5 #include <windows.h>
6 #include <shlwapi.h> 6 #include <shlwapi.h>
7 7
8 #include "base/base_paths.h"
8 #include "base/command_line.h" 9 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
10 #include "base/debug/trace_event.h" 11 #include "base/debug/trace_event.h"
11 #include "base/environment.h" 12 #include "base/environment.h"
12 #include "base/file_version_info.h" 13 #include "base/file_version_info.h"
13 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/path_service.h"
16 #include "base/strings/string16.h" 18 #include "base/strings/string16.h"
17 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
18 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
19 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
20 #include "base/version.h" 22 #include "base/version.h"
21 #include "base/win/scoped_handle.h" 23 #include "base/win/scoped_handle.h"
22 #include "base/win/windows_version.h" 24 #include "base/win/windows_version.h"
23 #include "chrome/app/chrome_crash_reporter_client.h" 25 #include "chrome/app/chrome_crash_reporter_client.h"
24 #include "chrome/app/chrome_watcher_client_win.h" 26 #include "chrome/app/chrome_watcher_client_win.h"
25 #include "chrome/app/chrome_watcher_command_line_win.h" 27 #include "chrome/app/chrome_watcher_command_line_win.h"
26 #include "chrome/app/client_util.h" 28 #include "chrome/app/client_util.h"
27 #include "chrome/app/image_pre_reader_win.h" 29 #include "chrome/app/image_pre_reader_win.h"
28 #include "chrome/chrome_watcher/chrome_watcher_main_api.h" 30 #include "chrome/chrome_watcher/chrome_watcher_main_api.h"
29 #include "chrome/common/chrome_constants.h" 31 #include "chrome/common/chrome_constants.h"
32 #include "chrome/common/chrome_paths.h"
30 #include "chrome/common/chrome_result_codes.h" 33 #include "chrome/common/chrome_result_codes.h"
31 #include "chrome/common/chrome_switches.h" 34 #include "chrome/common/chrome_switches.h"
32 #include "chrome/common/env_vars.h" 35 #include "chrome/common/env_vars.h"
33 #include "chrome/installer/util/google_update_constants.h" 36 #include "chrome/installer/util/google_update_constants.h"
34 #include "chrome/installer/util/google_update_settings.h" 37 #include "chrome/installer/util/google_update_settings.h"
35 #include "chrome/installer/util/install_util.h" 38 #include "chrome/installer/util/install_util.h"
36 #include "chrome/installer/util/util_constants.h" 39 #include "chrome/installer/util/util_constants.h"
37 #include "components/crash/app/breakpad_win.h" 40 #include "components/crash/app/breakpad_win.h"
38 #include "components/crash/app/crash_reporter_client.h" 41 #include "components/crash/app/crash_reporter_client.h"
39 #include "components/metrics/client_info.h" 42 #include "components/metrics/client_info.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 } 182 }
180 183
181 if (process_type_ == "watcher") { 184 if (process_type_ == "watcher") {
182 base::win::ScopedHandle parent_process; 185 base::win::ScopedHandle parent_process;
183 base::win::ScopedHandle on_initialized_event; 186 base::win::ScopedHandle on_initialized_event;
184 if (!InterpretChromeWatcherCommandLine(cmd_line, &parent_process, 187 if (!InterpretChromeWatcherCommandLine(cmd_line, &parent_process,
185 &on_initialized_event)) { 188 &on_initialized_event)) {
186 return chrome::RESULT_CODE_UNSUPPORTED_PARAM; 189 return chrome::RESULT_CODE_UNSUPPORTED_PARAM;
187 } 190 }
188 191
192 base::FilePath watcher_data_directory;
193 if (!PathService::Get(chrome::DIR_WATCHER_DATA, &watcher_data_directory))
194 return chrome::RESULT_CODE_MISSING_DATA;
195
189 // Intentionally leaked. 196 // Intentionally leaked.
190 HMODULE watcher_dll = Load(&version, &file); 197 HMODULE watcher_dll = Load(&version, &file);
191 if (!watcher_dll) 198 if (!watcher_dll)
192 return chrome::RESULT_CODE_MISSING_DATA; 199 return chrome::RESULT_CODE_MISSING_DATA;
193 200
194 ChromeWatcherMainFunction watcher_main = 201 ChromeWatcherMainFunction watcher_main =
195 reinterpret_cast<ChromeWatcherMainFunction>( 202 reinterpret_cast<ChromeWatcherMainFunction>(
196 ::GetProcAddress(watcher_dll, kChromeWatcherDLLEntrypoint)); 203 ::GetProcAddress(watcher_dll, kChromeWatcherDLLEntrypoint));
197 return watcher_main(chrome::kBrowserExitCodesRegistryPath, 204 return watcher_main(chrome::kBrowserExitCodesRegistryPath,
198 parent_process.Take(), on_initialized_event.Take()); 205 parent_process.Take(), on_initialized_event.Take(),
206 watcher_data_directory.value().c_str());
199 } 207 }
200 208
201 // Initialize the sandbox services. 209 // Initialize the sandbox services.
202 sandbox::SandboxInterfaceInfo sandbox_info = {0}; 210 sandbox::SandboxInterfaceInfo sandbox_info = {0};
203 content::InitializeSandboxInfo(&sandbox_info); 211 content::InitializeSandboxInfo(&sandbox_info);
204 212
205 crash_reporter::SetCrashReporterClient(g_chrome_crash_client.Pointer()); 213 crash_reporter::SetCrashReporterClient(g_chrome_crash_client.Pointer());
206 bool exit_now = true; 214 bool exit_now = true;
207 if (process_type_.empty()) { 215 if (process_type_.empty()) {
208 if (breakpad::ShowRestartDialogIfCrashed(&exit_now)) { 216 if (breakpad::ShowRestartDialogIfCrashed(&exit_now)) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 int OnBeforeExit(int return_code, const base::FilePath& dll_path) override; 261 int OnBeforeExit(int return_code, const base::FilePath& dll_path) override;
254 }; 262 };
255 263
256 void ChromeDllLoader::OnBeforeLaunch(const std::string& process_type, 264 void ChromeDllLoader::OnBeforeLaunch(const std::string& process_type,
257 const base::FilePath& dll_path) { 265 const base::FilePath& dll_path) {
258 if (process_type.empty()) { 266 if (process_type.empty()) {
259 RecordDidRun(dll_path); 267 RecordDidRun(dll_path);
260 268
261 // Launch the watcher process if stats collection consent has been granted. 269 // Launch the watcher process if stats collection consent has been granted.
262 if (g_chrome_crash_client.Get().GetCollectStatsConsent()) { 270 if (g_chrome_crash_client.Get().GetCollectStatsConsent()) {
263 base::char16 exe_path[MAX_PATH]; 271 base::FilePath exe_path;
264 ::GetModuleFileNameW(nullptr, exe_path, arraysize(exe_path)); 272 if (PathService::Get(base::FILE_EXE, &exe_path)) {
265 ChromeWatcherClient watcher_client(base::Bind( 273 ChromeWatcherClient watcher_client(
266 &GenerateChromeWatcherCommandLine, base::FilePath(exe_path))); 274 base::Bind(&GenerateChromeWatcherCommandLine, exe_path));
267 watcher_client.LaunchWatcher(); 275 watcher_client.LaunchWatcher();
276 } else {
277 NOTREACHED();
278 }
268 } 279 }
269 } 280 }
270 } 281 }
271 282
272 int ChromeDllLoader::OnBeforeExit(int return_code, 283 int ChromeDllLoader::OnBeforeExit(int return_code,
273 const base::FilePath& dll_path) { 284 const base::FilePath& dll_path) {
274 // NORMAL_EXIT_CANCEL is used for experiments when the user cancels 285 // NORMAL_EXIT_CANCEL is used for experiments when the user cancels
275 // so we need to reset the did_run signal so omaha does not count 286 // so we need to reset the did_run signal so omaha does not count
276 // this run as active usage. 287 // this run as active usage.
277 if (chrome::RESULT_CODE_NORMAL_EXIT_CANCEL == return_code) { 288 if (chrome::RESULT_CODE_NORMAL_EXIT_CANCEL == return_code) {
(...skipping 13 matching lines...) Expand all
291 } 302 }
292 }; 303 };
293 304
294 MainDllLoader* MakeMainDllLoader() { 305 MainDllLoader* MakeMainDllLoader() {
295 #if defined(GOOGLE_CHROME_BUILD) 306 #if defined(GOOGLE_CHROME_BUILD)
296 return new ChromeDllLoader(); 307 return new ChromeDllLoader();
297 #else 308 #else
298 return new ChromiumDllLoader(); 309 return new ChromiumDllLoader();
299 #endif 310 #endif
300 } 311 }
OLDNEW
« no previous file with comments | « DEPS ('k') | chrome/chrome_exe.gypi » ('j') | chrome/chrome_exe.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698