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

Side by Side Diff: content/browser/tracing/tracing_ui.cc

Issue 1131113004: Convert JsonWriter::Write to taking a const ref for the in-param (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another rebase Created 5 years, 7 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/tracing/tracing_ui.h" 5 #include "content/browser/tracing/tracing_ui.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 22 matching lines...) Expand all
33 #include "content/public/browser/web_ui.h" 33 #include "content/public/browser/web_ui.h"
34 #include "content/public/browser/web_ui_data_source.h" 34 #include "content/public/browser/web_ui_data_source.h"
35 #include "content/public/common/content_client.h" 35 #include "content/public/common/content_client.h"
36 #include "content/public/common/url_constants.h" 36 #include "content/public/common/url_constants.h"
37 37
38 namespace content { 38 namespace content {
39 namespace { 39 namespace {
40 40
41 void OnGotCategories(const WebUIDataSource::GotDataCallback& callback, 41 void OnGotCategories(const WebUIDataSource::GotDataCallback& callback,
42 const std::set<std::string>& categorySet) { 42 const std::set<std::string>& categorySet) {
43 scoped_ptr<base::ListValue> category_list(new base::ListValue()); 43 base::ListValue category_list;
44 for (std::set<std::string>::const_iterator it = categorySet.begin(); 44 for (std::set<std::string>::const_iterator it = categorySet.begin();
45 it != categorySet.end(); it++) { 45 it != categorySet.end(); it++) {
46 category_list->AppendString(*it); 46 category_list.AppendString(*it);
47 } 47 }
48 48
49 base::RefCountedString* res = new base::RefCountedString(); 49 base::RefCountedString* res = new base::RefCountedString();
50 base::JSONWriter::Write(category_list.get(), &res->data()); 50 base::JSONWriter::Write(category_list, &res->data());
51 callback.Run(res); 51 callback.Run(res);
52 } 52 }
53 53
54 bool GetTracingOptions(const std::string& data64, 54 bool GetTracingOptions(const std::string& data64,
55 base::trace_event::CategoryFilter* category_filter, 55 base::trace_event::CategoryFilter* category_filter,
56 base::trace_event::TraceOptions* tracing_options) { 56 base::trace_event::TraceOptions* tracing_options) {
57 std::string data; 57 std::string data;
58 if (!base::Base64Decode(data64, &data)) { 58 if (!base::Base64Decode(data64, &data)) {
59 LOG(ERROR) << "Options were not base64 encoded."; 59 LOG(ERROR) << "Options were not base64 encoded.";
60 return false; 60 return false;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 void OnTraceBufferUsageResult(const WebUIDataSource::GotDataCallback& callback, 126 void OnTraceBufferUsageResult(const WebUIDataSource::GotDataCallback& callback,
127 float percent_full, 127 float percent_full,
128 size_t approximate_event_count) { 128 size_t approximate_event_count) {
129 std::string str = base::DoubleToString(percent_full); 129 std::string str = base::DoubleToString(percent_full);
130 callback.Run(base::RefCountedString::TakeString(&str)); 130 callback.Run(base::RefCountedString::TakeString(&str));
131 } 131 }
132 132
133 void OnTraceBufferStatusResult(const WebUIDataSource::GotDataCallback& callback, 133 void OnTraceBufferStatusResult(const WebUIDataSource::GotDataCallback& callback,
134 float percent_full, 134 float percent_full,
135 size_t approximate_event_count) { 135 size_t approximate_event_count) {
136 scoped_ptr<base::DictionaryValue> status(new base::DictionaryValue()); 136 base::DictionaryValue status;
137 status->SetDouble("percentFull", percent_full); 137 status.SetDouble("percentFull", percent_full);
138 status->SetInteger("approximateEventCount", approximate_event_count); 138 status.SetInteger("approximateEventCount", approximate_event_count);
139 139
140 std::string status_json; 140 std::string status_json;
141 base::JSONWriter::Write(status.get(), &status_json); 141 base::JSONWriter::Write(status, &status_json);
142 142
143 base::RefCountedString* status_base64 = new base::RefCountedString(); 143 base::RefCountedString* status_base64 = new base::RefCountedString();
144 base::Base64Encode(status_json, &status_base64->data()); 144 base::Base64Encode(status_json, &status_base64->data());
145 callback.Run(status_base64); 145 callback.Run(status_base64);
146 } 146 }
147 147
148 void OnMonitoringEnabledAck(const WebUIDataSource::GotDataCallback& callback); 148 void OnMonitoringEnabledAck(const WebUIDataSource::GotDataCallback& callback);
149 149
150 bool EnableMonitoring(const std::string& data64, 150 bool EnableMonitoring(const std::string& data64,
151 const WebUIDataSource::GotDataCallback& callback) { 151 const WebUIDataSource::GotDataCallback& callback) {
(...skipping 18 matching lines...) Expand all
170 callback.Run(res); 170 callback.Run(res);
171 } 171 }
172 172
173 void GetMonitoringStatus(const WebUIDataSource::GotDataCallback& callback) { 173 void GetMonitoringStatus(const WebUIDataSource::GotDataCallback& callback) {
174 bool is_monitoring; 174 bool is_monitoring;
175 base::trace_event::CategoryFilter category_filter(""); 175 base::trace_event::CategoryFilter category_filter("");
176 base::trace_event::TraceOptions options; 176 base::trace_event::TraceOptions options;
177 TracingController::GetInstance()->GetMonitoringStatus( 177 TracingController::GetInstance()->GetMonitoringStatus(
178 &is_monitoring, &category_filter, &options); 178 &is_monitoring, &category_filter, &options);
179 179
180 scoped_ptr<base::DictionaryValue> 180 base::DictionaryValue monitoring_options;
181 monitoring_options(new base::DictionaryValue()); 181 monitoring_options.SetBoolean("isMonitoring", is_monitoring);
182 monitoring_options->SetBoolean("isMonitoring", is_monitoring); 182 monitoring_options.SetString("categoryFilter", category_filter.ToString());
183 monitoring_options->SetString("categoryFilter", category_filter.ToString()); 183 monitoring_options.SetBoolean("useSystemTracing", options.enable_systrace);
184 monitoring_options->SetBoolean("useSystemTracing", options.enable_systrace); 184 monitoring_options.SetBoolean(
185 monitoring_options->SetBoolean(
186 "useContinuousTracing", 185 "useContinuousTracing",
187 options.record_mode == base::trace_event::RECORD_CONTINUOUSLY); 186 options.record_mode == base::trace_event::RECORD_CONTINUOUSLY);
188 monitoring_options->SetBoolean("useSampling", options.enable_sampling); 187 monitoring_options.SetBoolean("useSampling", options.enable_sampling);
189 188
190 std::string monitoring_options_json; 189 std::string monitoring_options_json;
191 base::JSONWriter::Write(monitoring_options.get(), &monitoring_options_json); 190 base::JSONWriter::Write(monitoring_options, &monitoring_options_json);
192 191
193 base::RefCountedString* monitoring_options_base64 = 192 base::RefCountedString* monitoring_options_base64 =
194 new base::RefCountedString(); 193 new base::RefCountedString();
195 base::Base64Encode(monitoring_options_json, 194 base::Base64Encode(monitoring_options_json,
196 &monitoring_options_base64->data()); 195 &monitoring_options_base64->data());
197 callback.Run(monitoring_options_base64); 196 callback.Run(monitoring_options_base64);
198 } 197 }
199 198
200 void TracingCallbackWrapper(const WebUIDataSource::GotDataCallback& callback, 199 void TracingCallbackWrapper(const WebUIDataSource::GotDataCallback& callback,
201 base::RefCountedString* data) { 200 base::RefCountedString* data) {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 web_ui()->CallJavascriptFunction("onUploadComplete", 352 web_ui()->CallJavascriptFunction("onUploadComplete",
354 base::StringValue(feedback)); 353 base::StringValue(feedback));
355 } else { 354 } else {
356 web_ui()->CallJavascriptFunction("onUploadError", 355 web_ui()->CallJavascriptFunction("onUploadError",
357 base::StringValue(feedback)); 356 base::StringValue(feedback));
358 } 357 }
359 trace_uploader_.reset(); 358 trace_uploader_.reset();
360 } 359 }
361 360
362 } // namespace content 361 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_backing_store.cc ('k') | content/browser/web_contents/web_contents_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698