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

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

Issue 2344343002: Wire in postmortem report collection (Closed)
Patch Set: Merge Created 4 years, 2 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
(Empty)
1 // Copyright 2016 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 "components/browser_watcher/stability_debugging_win.h"
6
7 #include <string>
8
9 #include "base/metrics/persistent_memory_allocator.h"
10 #include "base/path_service.h"
11 #include "base/strings/stringprintf.h"
12 #include "base/time/time.h"
13
14 namespace browser_watcher {
15
16 namespace {
17
18 bool GetCreationTime(const base::Process& process, base::Time* time) {
19 DCHECK(time);
20
21 FILETIME creation_time = {};
22 FILETIME ignore1 = {};
23 FILETIME ignore2 = {};
24 FILETIME ignore3 = {};
25 if (!::GetProcessTimes(process.Handle(), &creation_time, &ignore1, &ignore2,
26 &ignore3)) {
27 return false;
28 }
29 *time = base::Time::FromFileTime(creation_time);
30 return true;
31 }
32
33 } // namespace
34
35 base::FilePath GetStabilityDir(const base::FilePath& user_data_dir) {
36 return user_data_dir.AppendASCII("Stability");
37 }
38
39 bool GetStabilityFileForProcess(const base::Process& process,
40 const base::FilePath& user_data_dir,
41 base::FilePath* file_path) {
42 DCHECK(file_path);
43 base::FilePath stability_dir = GetStabilityDir(user_data_dir);
44
45 // Build the name using the pid and creation time. On windows, this is unique
46 // even after the process exits.
47 base::Time creation_time;
48 if (!GetCreationTime(process, &creation_time))
49 return false;
50
51 std::string file_name =
52 base::StringPrintf("%u-%llu", process.Pid(), creation_time.ToJavaTime());
53 *file_path = stability_dir.AppendASCII(file_name).AddExtension(
54 base::PersistentMemoryAllocator::kFileExtension);
55 return true;
56 }
57
58 base::FilePath::StringType GetStabilityFilePattern() {
59 return base::FilePath::StringType(FILE_PATH_LITERAL("*-*")) +
60 base::PersistentMemoryAllocator::kFileExtension;
61 }
62
63 } // namespace browser_watcher
OLDNEW
« no previous file with comments | « components/browser_watcher/stability_debugging_win.h ('k') | components/browser_watcher/stability_debugging_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698