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/devtools/devtools_tracing_handler.h" | 5 #include "content/browser/devtools/devtools_tracing_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 base::Bind(&ReadFile, path, | 62 base::Bind(&ReadFile, path, |
63 base::Bind(&DevToolsTracingHandler::ReadRecordingResult, | 63 base::Bind(&DevToolsTracingHandler::ReadRecordingResult, |
64 weak_factory_.GetWeakPtr()))); | 64 weak_factory_.GetWeakPtr()))); |
65 } | 65 } |
66 | 66 |
67 void DevToolsTracingHandler::ReadRecordingResult( | 67 void DevToolsTracingHandler::ReadRecordingResult( |
68 const scoped_refptr<base::RefCountedString>& trace_data) { | 68 const scoped_refptr<base::RefCountedString>& trace_data) { |
69 if (trace_data->data().size()) { | 69 if (trace_data->data().size()) { |
70 scoped_ptr<base::Value> trace_value(base::JSONReader::Read( | 70 scoped_ptr<base::Value> trace_value(base::JSONReader::Read( |
71 trace_data->data())); | 71 trace_data->data())); |
72 DictionaryValue* dictionary = NULL; | 72 base::DictionaryValue* dictionary = NULL; |
73 bool ok = trace_value->GetAsDictionary(&dictionary); | 73 bool ok = trace_value->GetAsDictionary(&dictionary); |
74 DCHECK(ok); | 74 DCHECK(ok); |
75 ListValue* list = NULL; | 75 base::ListValue* list = NULL; |
76 ok = dictionary->GetList("traceEvents", &list); | 76 ok = dictionary->GetList("traceEvents", &list); |
77 DCHECK(ok); | 77 DCHECK(ok); |
78 std::string buffer; | 78 std::string buffer; |
79 for (size_t i = 0; i < list->GetSize(); ++i) { | 79 for (size_t i = 0; i < list->GetSize(); ++i) { |
80 std::string item; | 80 std::string item; |
81 base::Value* item_value; | 81 base::Value* item_value; |
82 list->Get(i, &item_value); | 82 list->Get(i, &item_value); |
83 base::JSONWriter::Write(item_value, &item); | 83 base::JSONWriter::Write(item_value, &item); |
84 if (buffer.size()) | 84 if (buffer.size()) |
85 buffer.append(","); | 85 buffer.append(","); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 DevToolsTracingHandler::OnEnd( | 152 DevToolsTracingHandler::OnEnd( |
153 scoped_refptr<DevToolsProtocol::Command> command) { | 153 scoped_refptr<DevToolsProtocol::Command> command) { |
154 TracingController::GetInstance()->DisableRecording( | 154 TracingController::GetInstance()->DisableRecording( |
155 base::FilePath(), | 155 base::FilePath(), |
156 base::Bind(&DevToolsTracingHandler::BeginReadingRecordingResult, | 156 base::Bind(&DevToolsTracingHandler::BeginReadingRecordingResult, |
157 weak_factory_.GetWeakPtr())); | 157 weak_factory_.GetWeakPtr())); |
158 return command->SuccessResponse(NULL); | 158 return command->SuccessResponse(NULL); |
159 } | 159 } |
160 | 160 |
161 } // namespace content | 161 } // namespace content |
OLD | NEW |