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

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

Issue 2856923002: Rejig stability intstrumentation filenames and targets (Closed)
Patch Set: Missing include Created 3 years, 7 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/stability_debugging.h" 5 #include "components/browser_watcher/stability_paths.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/debug/activity_tracker.h"
10 #include "base/feature_list.h" 9 #include "base/feature_list.h"
11 #include "base/files/file.h" 10 #include "base/files/file.h"
12 #include "base/metrics/persistent_memory_allocator.h" 11 #include "base/metrics/persistent_memory_allocator.h"
13 #include "base/path_service.h"
14 #include "base/process/process.h"
15 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
16 #include "base/time/time.h" 13 #include "base/time/time.h"
17 #include "components/browser_watcher/features.h" 14 #include "components/browser_watcher/features.h"
18 15
16 #if defined(OS_WIN)
17
19 namespace browser_watcher { 18 namespace browser_watcher {
20
21 namespace { 19 namespace {
22 20
23 #if defined(OS_WIN)
24 bool GetCreationTime(const base::Process& process, base::Time* time) { 21 bool GetCreationTime(const base::Process& process, base::Time* time) {
25 DCHECK(time); 22 DCHECK(time);
26 23
27 FILETIME creation_time = {}; 24 FILETIME creation_time = {};
28 FILETIME ignore1 = {}; 25 FILETIME ignore1 = {};
29 FILETIME ignore2 = {}; 26 FILETIME ignore2 = {};
30 FILETIME ignore3 = {}; 27 FILETIME ignore3 = {};
31 if (!::GetProcessTimes(process.Handle(), &creation_time, &ignore1, &ignore2, 28 if (!::GetProcessTimes(process.Handle(), &creation_time, &ignore1, &ignore2,
32 &ignore3)) { 29 &ignore3)) {
33 return false; 30 return false;
34 } 31 }
35 *time = base::Time::FromFileTime(creation_time); 32 *time = base::Time::FromFileTime(creation_time);
36 return true; 33 return true;
37 } 34 }
38 #endif // defined(OS_WIN)
39 35
40 } // namespace 36 } // namespace
41 37
42 #if defined(OS_WIN)
43
44 base::FilePath GetStabilityDir(const base::FilePath& user_data_dir) { 38 base::FilePath GetStabilityDir(const base::FilePath& user_data_dir) {
45 return user_data_dir.AppendASCII("Stability"); 39 return user_data_dir.AppendASCII("Stability");
46 } 40 }
47 41
48 bool GetStabilityFileForProcess(const base::Process& process, 42 bool GetStabilityFileForProcess(const base::Process& process,
49 const base::FilePath& user_data_dir, 43 const base::FilePath& user_data_dir,
50 base::FilePath* file_path) { 44 base::FilePath* file_path) {
51 DCHECK(file_path); 45 DCHECK(file_path);
52 base::FilePath stability_dir = GetStabilityDir(user_data_dir); 46 base::FilePath stability_dir = GetStabilityDir(user_data_dir);
53 47
(...skipping 28 matching lines...) Expand all
82 return; 76 return;
83 } 77 }
84 78
85 // Open (with delete) and then immediately close the file by going out of 79 // Open (with delete) and then immediately close the file by going out of
86 // scope. This should cause the stability debugging file to be deleted prior 80 // scope. This should cause the stability debugging file to be deleted prior
87 // to the next execution. 81 // to the next execution.
88 base::File file(stability_file, base::File::FLAG_OPEN | 82 base::File file(stability_file, base::File::FLAG_OPEN |
89 base::File::FLAG_READ | 83 base::File::FLAG_READ |
90 base::File::FLAG_DELETE_ON_CLOSE); 84 base::File::FLAG_DELETE_ON_CLOSE);
91 } 85 }
92 #endif // defined(OS_WIN)
93
94 void SetStabilityDataInt(base::StringPiece name, int64_t value) {
95 base::debug::GlobalActivityTracker* global_tracker =
96 base::debug::GlobalActivityTracker::Get();
97 if (!global_tracker)
98 return; // Activity tracking isn't enabled.
99
100 global_tracker->process_data().SetInt(name, value);
101 }
102 86
103 } // namespace browser_watcher 87 } // namespace browser_watcher
88
89 #endif // defined(OS_WIN)
OLDNEW
« no previous file with comments | « components/browser_watcher/stability_paths.h ('k') | components/browser_watcher/stability_report_extractor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698