OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 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 | 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/tracing/trace_config_file.h" | 5 #include "components/tracing/trace_config_file.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
| 9 #include <memory> |
9 #include <string> | 10 #include <string> |
10 | 11 |
11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
12 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
13 #include "base/json/json_reader.h" | 14 #include "base/json/json_reader.h" |
14 #include "base/logging.h" | 15 #include "base/logging.h" |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "base/memory/singleton.h" | 16 #include "base/memory/singleton.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 #include "components/tracing/tracing_switches.h" | 19 #include "components/tracing/tracing_switches.h" |
20 | 20 |
21 namespace tracing { | 21 namespace tracing { |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 // Maximum trace config file size that will be loaded, in bytes. | 25 // Maximum trace config file size that will be loaded, in bytes. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 90 } |
91 is_enabled_ = ParseTraceConfigFileContent(trace_config_file_content); | 91 is_enabled_ = ParseTraceConfigFileContent(trace_config_file_content); |
92 if (!is_enabled_) | 92 if (!is_enabled_) |
93 DLOG(WARNING) << "Cannot parse the trace config file correctly."; | 93 DLOG(WARNING) << "Cannot parse the trace config file correctly."; |
94 } | 94 } |
95 | 95 |
96 TraceConfigFile::~TraceConfigFile() { | 96 TraceConfigFile::~TraceConfigFile() { |
97 } | 97 } |
98 | 98 |
99 bool TraceConfigFile::ParseTraceConfigFileContent(const std::string& content) { | 99 bool TraceConfigFile::ParseTraceConfigFileContent(const std::string& content) { |
100 scoped_ptr<base::Value> value(base::JSONReader::Read(content)); | 100 std::unique_ptr<base::Value> value(base::JSONReader::Read(content)); |
101 if (!value || !value->IsType(base::Value::TYPE_DICTIONARY)) | 101 if (!value || !value->IsType(base::Value::TYPE_DICTIONARY)) |
102 return false; | 102 return false; |
103 | 103 |
104 scoped_ptr<base::DictionaryValue> dict( | 104 std::unique_ptr<base::DictionaryValue> dict( |
105 static_cast<base::DictionaryValue*>(value.release())); | 105 static_cast<base::DictionaryValue*>(value.release())); |
106 | 106 |
107 base::DictionaryValue* trace_config_dict = NULL; | 107 base::DictionaryValue* trace_config_dict = NULL; |
108 if (!dict->GetDictionary(kTraceConfigParam, &trace_config_dict)) | 108 if (!dict->GetDictionary(kTraceConfigParam, &trace_config_dict)) |
109 return false; | 109 return false; |
110 | 110 |
111 trace_config_ = base::trace_event::TraceConfig(*trace_config_dict); | 111 trace_config_ = base::trace_event::TraceConfig(*trace_config_dict); |
112 | 112 |
113 if (!dict->GetInteger(kStartupDurationParam, &startup_duration_)) | 113 if (!dict->GetInteger(kStartupDurationParam, &startup_duration_)) |
114 startup_duration_ = 0; | 114 startup_duration_ = 0; |
(...skipping 23 matching lines...) Expand all Loading... |
138 } | 138 } |
139 | 139 |
140 #if !defined(OS_ANDROID) | 140 #if !defined(OS_ANDROID) |
141 base::FilePath TraceConfigFile::GetResultFile() const { | 141 base::FilePath TraceConfigFile::GetResultFile() const { |
142 DCHECK(IsEnabled()); | 142 DCHECK(IsEnabled()); |
143 return result_file_; | 143 return result_file_; |
144 } | 144 } |
145 #endif | 145 #endif |
146 | 146 |
147 } // namespace tracing | 147 } // namespace tracing |
OLD | NEW |