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/watcher_metrics_provider_win.h" | 5 #include "components/browser_watcher/watcher_metrics_provider_win.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/metrics/sparse_histogram.h" | 10 #include "base/metrics/sparse_histogram.h" |
11 #include "base/process/process_handle.h" | 11 #include "base/process/process_handle.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/win/registry.h" | 15 #include "base/win/registry.h" |
16 | 16 |
17 namespace browser_watcher { | 17 namespace browser_watcher { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 void CompileAsserts() { | 21 void CompileAsserts() { |
22 // Process ID APIs on Windows talk in DWORDs, whereas for string formatting | 22 // Process ID APIs on Windows talk in DWORDs, whereas for string formatting |
23 // and parsing, this code uses int. In practice there are no process IDs with | 23 // and parsing, this code uses int. In practice there are no process IDs with |
24 // the high bit set on Windows, so there's no danger of overflow if this is | 24 // the high bit set on Windows, so there's no danger of overflow if this is |
25 // done consistently. | 25 // done consistently. |
26 COMPILE_ASSERT(sizeof(DWORD) == sizeof(int), | 26 static_assert(sizeof(DWORD) == sizeof(int), |
27 process_ids_have_outgrown_an_int); | 27 "process ids are expected to be no larger than int"); |
28 } | 28 } |
29 | 29 |
30 // This function does soft matching on the PID recorded in the key only. | 30 // This function does soft matching on the PID recorded in the key only. |
31 // Due to PID reuse, the possibility exists that the process that's now live | 31 // Due to PID reuse, the possibility exists that the process that's now live |
32 // with the given PID is not the same process the data was recorded for. | 32 // with the given PID is not the same process the data was recorded for. |
33 // This doesn't matter for the purpose, as eventually the data will be | 33 // This doesn't matter for the purpose, as eventually the data will be |
34 // scavenged and reported. | 34 // scavenged and reported. |
35 bool IsDeadProcess(base::StringPiece16 key_or_value_name) { | 35 bool IsDeadProcess(base::StringPiece16 key_or_value_name) { |
36 // Truncate the input string to the first occurrence of '-', if one exists. | 36 // Truncate the input string to the first occurrence of '-', if one exists. |
37 size_t num_end = key_or_value_name.find(L'-'); | 37 size_t num_end = key_or_value_name.find(L'-'); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 // user account, there's a small race that will double-report the exit codes | 228 // user account, there's a small race that will double-report the exit codes |
229 // from both/multiple instances. This ought to be vanishingly rare and will | 229 // from both/multiple instances. This ought to be vanishingly rare and will |
230 // only manifest as low-level "random" noise. To work around this it would be | 230 // only manifest as low-level "random" noise. To work around this it would be |
231 // necessary to implement some form of global locking, which is not worth it | 231 // necessary to implement some form of global locking, which is not worth it |
232 // here. | 232 // here. |
233 RecordExitCodes(registry_path_); | 233 RecordExitCodes(registry_path_); |
234 RecordExitFunnels(registry_path_); | 234 RecordExitFunnels(registry_path_); |
235 } | 235 } |
236 | 236 |
237 } // namespace browser_watcher | 237 } // namespace browser_watcher |
OLD | NEW |