| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> |
| 9 #include <set> | 10 #include <set> |
| 10 #include <string> | 11 #include <string> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/base64.h" | 14 #include "base/base64.h" |
| 14 #include "base/bind.h" | 15 #include "base/bind.h" |
| 15 #include "base/bind_helpers.h" | 16 #include "base/bind_helpers.h" |
| 16 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 17 #include "base/format_macros.h" | 18 #include "base/format_macros.h" |
| 18 #include "base/json/json_reader.h" | 19 #include "base/json/json_reader.h" |
| 19 #include "base/json/json_writer.h" | 20 #include "base/json/json_writer.h" |
| 20 #include "base/memory/scoped_ptr.h" | |
| 21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
| 22 #include "base/strings/string_split.h" | 22 #include "base/strings/string_split.h" |
| 23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
| 24 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
| 25 #include "base/trace_event/trace_event.h" | 25 #include "base/trace_event/trace_event.h" |
| 26 #include "base/values.h" | 26 #include "base/values.h" |
| 27 #include "content/browser/tracing/grit/tracing_resources.h" | 27 #include "content/browser/tracing/grit/tracing_resources.h" |
| 28 #include "content/browser/tracing/tracing_controller_impl.h" | 28 #include "content/browser/tracing/tracing_controller_impl.h" |
| 29 #include "content/public/browser/browser_context.h" | 29 #include "content/public/browser/browser_context.h" |
| 30 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 55 } | 55 } |
| 56 | 56 |
| 57 bool GetTracingOptions(const std::string& data64, | 57 bool GetTracingOptions(const std::string& data64, |
| 58 base::trace_event::TraceConfig* trace_config) { | 58 base::trace_event::TraceConfig* trace_config) { |
| 59 std::string data; | 59 std::string data; |
| 60 if (!base::Base64Decode(data64, &data)) { | 60 if (!base::Base64Decode(data64, &data)) { |
| 61 LOG(ERROR) << "Options were not base64 encoded."; | 61 LOG(ERROR) << "Options were not base64 encoded."; |
| 62 return false; | 62 return false; |
| 63 } | 63 } |
| 64 | 64 |
| 65 scoped_ptr<base::Value> optionsRaw = base::JSONReader::Read(data); | 65 std::unique_ptr<base::Value> optionsRaw = base::JSONReader::Read(data); |
| 66 if (!optionsRaw) { | 66 if (!optionsRaw) { |
| 67 LOG(ERROR) << "Options were not valid JSON"; | 67 LOG(ERROR) << "Options were not valid JSON"; |
| 68 return false; | 68 return false; |
| 69 } | 69 } |
| 70 base::DictionaryValue* options; | 70 base::DictionaryValue* options; |
| 71 if (!optionsRaw->GetAsDictionary(&options)) { | 71 if (!optionsRaw->GetAsDictionary(&options)) { |
| 72 LOG(ERROR) << "Options must be dict"; | 72 LOG(ERROR) << "Options must be dict"; |
| 73 return false; | 73 return false; |
| 74 } | 74 } |
| 75 | 75 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 std::string status_json; | 140 std::string status_json; |
| 141 base::JSONWriter::Write(status, &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 TracingCallbackWrapperBase64( | 148 void TracingCallbackWrapperBase64( |
| 149 const WebUIDataSource::GotDataCallback& callback, | 149 const WebUIDataSource::GotDataCallback& callback, |
| 150 scoped_ptr<const base::DictionaryValue> metadata, | 150 std::unique_ptr<const base::DictionaryValue> metadata, |
| 151 base::RefCountedString* data) { | 151 base::RefCountedString* data) { |
| 152 base::RefCountedString* data_base64 = new base::RefCountedString(); | 152 base::RefCountedString* data_base64 = new base::RefCountedString(); |
| 153 base::Base64Encode(data->data(), &data_base64->data()); | 153 base::Base64Encode(data->data(), &data_base64->data()); |
| 154 callback.Run(data_base64); | 154 callback.Run(data_base64); |
| 155 } | 155 } |
| 156 | 156 |
| 157 void AddCustomMetadata(TracingControllerImpl::TraceDataSink* trace_data_sink) { | 157 void AddCustomMetadata(TracingControllerImpl::TraceDataSink* trace_data_sink) { |
| 158 base::DictionaryValue metadata_dict; | 158 base::DictionaryValue metadata_dict; |
| 159 metadata_dict.SetString( | 159 metadata_dict.SetString( |
| 160 "command_line", | 160 "command_line", |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 web_ui()->CallJavascriptFunction("onUploadComplete", | 317 web_ui()->CallJavascriptFunction("onUploadComplete", |
| 318 base::StringValue(feedback)); | 318 base::StringValue(feedback)); |
| 319 } else { | 319 } else { |
| 320 web_ui()->CallJavascriptFunction("onUploadError", | 320 web_ui()->CallJavascriptFunction("onUploadError", |
| 321 base::StringValue(feedback)); | 321 base::StringValue(feedback)); |
| 322 } | 322 } |
| 323 trace_uploader_.reset(); | 323 trace_uploader_.reset(); |
| 324 } | 324 } |
| 325 | 325 |
| 326 } // namespace content | 326 } // namespace content |
| OLD | NEW |