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

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: 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-trace-config.json
dsinclair 2015/06/11 14:37:08 Why not /data/local/chrome-telemetry/chrome-tracin
Zhen Wang 2015/06/12 01:26:05 Done.
19 // - POSIX other than Android: $HOME/.chrome-telemetry/chrome-trace-config.json
20 // - Win: %USERPROFILE%/.chrome-telemetry/chrome-trace-config.json
21 #if defined(OS_ANDROID)
22 const FilePath::CharType kAndroidTraceConfigDir[] =
23 FILE_PATH_LITERAL("/data/local");
24 #elif defined(OS_POSIX) || defined(OS_WIN)
25 const FilePath::CharType kChromeTelemetryDir[] =
26 FILE_PATH_LITERAL(".chrome-telemetry");
27 #endif
28
29 #if defined(OS_POSIX) || defined(OS_WIN)
dsinclair 2015/06/11 14:37:09 Is this ifdef needed? This is always the name of t
Zhen Wang 2015/06/12 01:26:05 This is for the cases where it is neither POSIX no
dsinclair 2015/06/12 14:04:14 I think we can still have those constant defined o
Zhen Wang 2015/06/12 15:41:34 OK. defined is now removed.
30 const FilePath::CharType kTraceConfigFileName[] =
31 FILE_PATH_LITERAL("chrome-trace-config.json");
32 #endif
33
34 FilePath GetTraceConfigFilePath() {
35 #if defined(OS_ANDROID)
36 FilePath path(kAndroidTraceConfigDir);
37 path = path.Append(kTraceConfigFileName);
38 #elif defined(OS_POSIX) || defined(OS_WIN)
39 FilePath path;
40 PathService::Get(DIR_HOME, &path);
41 path = path.Append(kChromeTelemetryDir);
42 path = path.Append(kTraceConfigFileName);
43 #else
44 FilePath path;
dsinclair 2015/06/11 14:37:09 Should this log a warning that the config file pat
Zhen Wang 2015/06/12 01:26:05 This is for the cases where it is neither POSIX no
45 #endif
46 return path;
47 }
48
49 } // namespace
50
51 void EnableStartupTracingFromConfigFile() {
dsinclair 2015/06/11 14:37:09 This seems slightly misnamed? EnableStartupTracin
Zhen Wang 2015/06/12 01:26:05 Makes sense. Renamed.
52 base::FilePath trace_config_file_path = GetTraceConfigFilePath();
53 if (!trace_config_file_path.empty() && PathExists(trace_config_file_path)) {
dsinclair 2015/06/11 14:37:09 if (trace_config_file_path.empty() || !PathExists(
Zhen Wang 2015/06/12 01:26:05 Done.
54 std::string trace_config_str;
55 base::ReadFileToString(trace_config_file_path, &trace_config_str);
dsinclair 2015/06/11 14:37:09 Can this fail?
Zhen Wang 2015/06/12 01:26:05 Thanks for catching this. Now checking the return
56 TraceConfig trace_config(trace_config_str);
dsinclair 2015/06/11 14:37:09 Was TraceConfig converted over to SafeJSONReader?
Zhen Wang 2015/06/12 01:26:05 No. It still uses normal json reader. So the decis
57 TraceLog::GetInstance()->SetEnabled(trace_config, TraceLog::RECORDING_MODE);
58 }
59 }
60
61 } // namespace trace_event
62 } // 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