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

Side by Side Diff: components/browser_watcher/watcher_main_win.cc

Issue 717223002: Browser watcher end-end-to-end . (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/lkgr
Patch Set: Move to components Created 6 years, 1 month 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
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/at_exit.h"
6 #include "base/command_line.h"
7 #include "base/logging_win.h"
8 #include "components/browser_watcher/watcher_main_win.h"
9 #include "components/browser_watcher/watcher_win.h"
10
11 namespace {
12
13 // Use the same log facility as Chrome for convenience.
14 // {7FE69228-633E-4f06-80C1-527FEA23E3A7}
15 const GUID kChromeWatcherTraceProviderName = {
16 0x7fe69228, 0x633e, 0x4f06,
17 { 0x80, 0xc1, 0x52, 0x7f, 0xea, 0x23, 0xe3, 0xa7 } };
18
19 } // namespace
20
21 // The main entry point to the watcher, declared as extern "C" to avoid name
22 // mangling.
23 extern "C" int __declspec(dllexport) WatcherMain(const wchar_t* registry_path) {
24 // The exit manager is in charge of calling the dtors of singletons.
25 base::AtExitManager exit_manager;
26 // Initialize the commandline singleton from the environment.
27 base::CommandLine::Init(0, NULL);
28
29 logging::LogEventProvider::Initialize(kChromeWatcherTraceProviderName);
30
31 // Arrange to be shut down as late as possible, as we want to outlive
32 // chrome.exe in order to report its exit status.
33 // TODO(siggi): Does this (windowless) process need to register a console
34 // handler too, in order to get notice of logoff events?
35 ::SetProcessShutdownParameters(0x100, SHUTDOWN_NORETRY);
36
37 browser_watcher::ExitCodeWatcher exit_code_watcher(registry_path);
38 int ret = 1;
39 // Attempt to wait on our parent process, and record its exit status.
40 if (exit_code_watcher.ParseArguments(
41 *base::CommandLine::ForCurrentProcess())) {
42 // Wait on the process.
43 exit_code_watcher.WaitForExit();
44 ret = 0;
45 }
46
47 // Wind logging down.
48 logging::LogEventProvider::Uninitialize();
49
50 return ret;
51 }
52
53 static void CompileAsserts() {
erikwright (departed) 2014/11/14 19:46:09 should this go in an anonymous namespace?
Sigurður Ásgeirsson 2014/11/17 15:26:58 Done.
54 // Make sure the exported function's type matches the typedef.
55 browser_watcher::WatcherMainFunction fn = &WatcherMain;
56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698