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

Side by Side Diff: components/tracing/startup_tracing.cc

Issue 1319093002: Revert of [Startup Tracing] Add --trace-config-file flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 | « components/tracing/startup_tracing.h ('k') | components/tracing/trace_config_file.h » ('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 "components/tracing/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.h"
11
12 namespace tracing {
13
14 namespace {
15
16 // Maximum trace config file size that will be loaded, in bytes.
17 const size_t kTraceConfigFileSizeLimit = 64 * 1024;
18
19 // Trace config file path:
20 // - Android: /data/local/.config/chrome-trace-config.json
21 // - POSIX other than Android: $HOME/.config/chrome-trace-config.json
22 // - Win: %USERPROFILE%/.config/chrome-trace-config.json
23 #if defined(OS_ANDROID)
24 const base::FilePath::CharType kAndroidTraceConfigDir[] =
25 FILE_PATH_LITERAL("/data/local");
26 #endif
27
28 const base::FilePath::CharType kChromeConfigDir[] =
29 FILE_PATH_LITERAL(".config");
30 const base::FilePath::CharType kTraceConfigFileName[] =
31 FILE_PATH_LITERAL("chrome-trace-config.json");
32
33 base::FilePath GetTraceConfigFilePath() {
34 #if defined(OS_ANDROID)
35 base::FilePath path(kAndroidTraceConfigDir);
36 #elif defined(OS_POSIX) || defined(OS_WIN)
37 base::FilePath path;
38 PathService::Get(base::DIR_HOME, &path);
39 #else
40 base::FilePath path;
41 #endif
42 path = path.Append(kChromeConfigDir);
43 path = path.Append(kTraceConfigFileName);
44 return path;
45 }
46
47 } // namespace
48
49 void EnableStartupTracingIfConfigFileExists() {
50 base::FilePath trace_config_file_path = GetTraceConfigFilePath();
51 if (!base::PathExists(trace_config_file_path))
52 return;
53
54 std::string trace_config_str;
55 if (!base::ReadFileToString(trace_config_file_path,
56 &trace_config_str,
57 kTraceConfigFileSizeLimit)) {
58 return;
59 }
60
61 base::trace_event::TraceConfig trace_config(trace_config_str);
62 base::trace_event::TraceLog::GetInstance()->SetEnabled(
63 trace_config, base::trace_event::TraceLog::RECORDING_MODE);
64 }
65
66 } // namespace tracing
OLDNEW
« no previous file with comments | « components/tracing/startup_tracing.h ('k') | components/tracing/trace_config_file.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698