| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 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 | 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 "components/browser_watcher/exit_code_watcher_win.h" | 5 #include "components/browser_watcher/exit_code_watcher_win.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/process/kill.h" | 10 #include "base/process/kill.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/win/registry.h" | 12 #include "base/win/registry.h" |
| 13 | 13 |
| 14 namespace browser_watcher { | 14 namespace browser_watcher { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 base::string16 GetValueName(const base::Time creation_time, | 18 base::string16 GetValueName(const base::Time creation_time, |
| 19 base::ProcessId pid) { | 19 base::ProcessId pid) { |
| 20 // Convert the PID and creation time to a string value unique to this | 20 // Convert the PID and creation time to a string value unique to this |
| 21 // process instance. | 21 // process instance. |
| 22 return base::StringPrintf(L"%d-%lld", pid, creation_time.ToInternalValue()); | 22 return base::StringPrintf(L"%d-%lld", pid, creation_time.ToInternalValue()); |
| 23 } | 23 } |
| 24 | 24 |
| 25 } // namespace | 25 } // namespace |
| 26 | 26 |
| 27 ExitCodeWatcher::ExitCodeWatcher(const base::char16* registry_path) : | 27 ExitCodeWatcher::ExitCodeWatcher(base::StringPiece16 registry_path) |
| 28 registry_path_(registry_path), exit_code_(STILL_ACTIVE) { | 28 : registry_path_(registry_path.as_string()), exit_code_(STILL_ACTIVE) {} |
| 29 } | |
| 30 | 29 |
| 31 ExitCodeWatcher::~ExitCodeWatcher() { | 30 ExitCodeWatcher::~ExitCodeWatcher() { |
| 32 } | 31 } |
| 33 | 32 |
| 34 bool ExitCodeWatcher::Initialize(base::Process process) { | 33 bool ExitCodeWatcher::Initialize(base::Process process) { |
| 35 if (!process.IsValid()) { | 34 if (!process.IsValid()) { |
| 36 LOG(ERROR) << "Invalid parent handle, can't get parent process ID."; | 35 LOG(ERROR) << "Invalid parent handle, can't get parent process ID."; |
| 37 return false; | 36 return false; |
| 38 } | 37 } |
| 39 | 38 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 ULONG result = key.WriteValue(value_name.c_str(), exit_code); | 79 ULONG result = key.WriteValue(value_name.c_str(), exit_code); |
| 81 if (result != ERROR_SUCCESS) { | 80 if (result != ERROR_SUCCESS) { |
| 82 LOG(ERROR) << "Unable to write to registry, error " << result; | 81 LOG(ERROR) << "Unable to write to registry, error " << result; |
| 83 return false; | 82 return false; |
| 84 } | 83 } |
| 85 | 84 |
| 86 return true; | 85 return true; |
| 87 } | 86 } |
| 88 | 87 |
| 89 } // namespace browser_watcher | 88 } // namespace browser_watcher |
| OLD | NEW |