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

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

Issue 1765153002: Update DevTools Tracing.Start to accept trace config as a parameter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review fix for primiano and petrcermak's comments Created 4 years, 9 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 (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 <string> 9 #include <string>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
14 #include "base/json/json_writer.h"
15 #include "base/logging.h" 14 #include "base/logging.h"
16 #include "base/memory/singleton.h" 15 #include "base/memory/singleton.h"
17 #include "base/values.h" 16 #include "base/values.h"
18 #include "build/build_config.h" 17 #include "build/build_config.h"
19 #include "components/tracing/tracing_switches.h" 18 #include "components/tracing/tracing_switches.h"
20 19
21 namespace tracing { 20 namespace tracing {
22 21
23 namespace { 22 namespace {
24 23
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 if (!value || !value->IsType(base::Value::TYPE_DICTIONARY)) 100 if (!value || !value->IsType(base::Value::TYPE_DICTIONARY))
102 return false; 101 return false;
103 102
104 scoped_ptr<base::DictionaryValue> dict( 103 scoped_ptr<base::DictionaryValue> dict(
105 static_cast<base::DictionaryValue*>(value.release())); 104 static_cast<base::DictionaryValue*>(value.release()));
106 105
107 base::DictionaryValue* trace_config_dict = NULL; 106 base::DictionaryValue* trace_config_dict = NULL;
108 if (!dict->GetDictionary(kTraceConfigParam, &trace_config_dict)) 107 if (!dict->GetDictionary(kTraceConfigParam, &trace_config_dict))
109 return false; 108 return false;
110 109
111 std::string trace_config_str; 110 DCHECK(trace_config_dict);
Primiano Tucci (use gerrit) 2016/03/15 12:22:41 If you dereference a ptr there is no point adding
Zhen Wang 2016/03/15 16:53:55 I see. removed.
112 base::JSONWriter::Write(*trace_config_dict, &trace_config_str); 111 trace_config_ = base::trace_event::TraceConfig(*trace_config_dict);
113 trace_config_ = base::trace_event::TraceConfig(trace_config_str);
114 112
115 if (!dict->GetInteger(kStartupDurationParam, &startup_duration_)) 113 if (!dict->GetInteger(kStartupDurationParam, &startup_duration_))
116 startup_duration_ = 0; 114 startup_duration_ = 0;
117 115
118 if (startup_duration_ < 0) 116 if (startup_duration_ < 0)
119 startup_duration_ = 0; 117 startup_duration_ = 0;
120 118
121 base::FilePath::StringType result_file_str; 119 base::FilePath::StringType result_file_str;
122 if (dict->GetString(kResultFileParam, &result_file_str)) 120 if (dict->GetString(kResultFileParam, &result_file_str))
123 result_file_ = base::FilePath(result_file_str); 121 result_file_ = base::FilePath(result_file_str);
(...skipping 16 matching lines...) Expand all
140 } 138 }
141 139
142 #if !defined(OS_ANDROID) 140 #if !defined(OS_ANDROID)
143 base::FilePath TraceConfigFile::GetResultFile() const { 141 base::FilePath TraceConfigFile::GetResultFile() const {
144 DCHECK(IsEnabled()); 142 DCHECK(IsEnabled());
145 return result_file_; 143 return result_file_;
146 } 144 }
147 #endif 145 #endif
148 146
149 } // namespace tracing 147 } // namespace tracing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698