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

Side by Side Diff: base/trace_event/startup_tracing.cc

Issue 1177853003: [Startup Tracing] Enable startup tracing from config file (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review fix Created 5 years, 6 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
« no previous file with comments | « base/trace_event/startup_tracing.h ('k') | base/trace_event/trace_event.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015 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/trace_event/startup_tracing.h"
6
7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h"
9 #include "base/path_service.h"
10 #include "base/trace_event/trace_event_impl.h"
11
12 namespace base {
13 namespace trace_event {
14
15 namespace {
16
17 // Trace config file path:
18 // - Android: /data/local/.chrome-telemetry/chrome-trace-config.json
19 // - POSIX other than Android: $HOME/.chrome-telemetry/chrome-trace-config.json
20 // - Win: %USERPROFILE%/.chrome-telemetry/chrome-trace-config.json
nednguyen 2015/06/12 20:12:18 I am not sure whether putting the name "telemetry"
Zhen Wang 2015/06/13 03:48:03 Now changed to .config, which is the convention. h
21 #if defined(OS_ANDROID)
22 const FilePath::CharType kAndroidTraceConfigDir[] =
23 FILE_PATH_LITERAL("/data/local");
24 #endif
25
26 const FilePath::CharType kChromeTelemetryDir[] =
27 FILE_PATH_LITERAL(".chrome-telemetry");
28 const FilePath::CharType kTraceConfigFileName[] =
29 FILE_PATH_LITERAL("chrome-trace-config.json");
30
31 FilePath GetTraceConfigFilePath() {
32 #if defined(OS_ANDROID)
33 FilePath path(kAndroidTraceConfigDir);
34 #elif defined(OS_POSIX) || defined(OS_WIN)
35 FilePath path;
36 PathService::Get(DIR_HOME, &path);
37 #else
38 FilePath path;
39 #endif
40 path = path.Append(kChromeTelemetryDir);
41 path = path.Append(kTraceConfigFileName);
42 return path;
43 }
44
45 } // namespace
46
47 void EnableStartupTracingIfConfigFileExists() {
48 FilePath trace_config_file_path = GetTraceConfigFilePath();
49 if (trace_config_file_path.empty() || !PathExists(trace_config_file_path))
50 return;
51
52 std::string trace_config_str;
53 if (!ReadFileToString(trace_config_file_path, &trace_config_str))
54 return;
55
56 TraceConfig trace_config(trace_config_str);
57 TraceLog::GetInstance()->SetEnabled(trace_config, TraceLog::RECORDING_MODE);
58 }
59
60 } // namespace trace_event
61 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/startup_tracing.h ('k') | base/trace_event/trace_event.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698