OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/test/chromedriver/performance_logger.h" | 5 #include "chrome/test/chromedriver/performance_logger.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/memory/ptr_util.h" |
12 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
13 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
14 #include "base/values.h" | 15 #include "base/values.h" |
15 #include "chrome/test/chromedriver/chrome/browser_info.h" | 16 #include "chrome/test/chromedriver/chrome/browser_info.h" |
16 #include "chrome/test/chromedriver/chrome/chrome.h" | 17 #include "chrome/test/chromedriver/chrome/chrome.h" |
17 #include "chrome/test/chromedriver/chrome/devtools_client.h" | 18 #include "chrome/test/chromedriver/chrome/devtools_client.h" |
18 #include "chrome/test/chromedriver/chrome/devtools_client_impl.h" | 19 #include "chrome/test/chromedriver/chrome/devtools_client_impl.h" |
19 #include "chrome/test/chromedriver/chrome/log.h" | 20 #include "chrome/test/chromedriver/chrome/log.h" |
20 #include "chrome/test/chromedriver/chrome/status.h" | 21 #include "chrome/test/chromedriver/chrome/status.h" |
21 #include "chrome/test/chromedriver/net/timeout.h" | 22 #include "chrome/test/chromedriver/net/timeout.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 } | 120 } |
120 | 121 |
121 void PerformanceLogger::AddLogEntry( | 122 void PerformanceLogger::AddLogEntry( |
122 Log::Level level, | 123 Log::Level level, |
123 const std::string& webview, | 124 const std::string& webview, |
124 const std::string& method, | 125 const std::string& method, |
125 const base::DictionaryValue& params) { | 126 const base::DictionaryValue& params) { |
126 base::DictionaryValue log_message_dict; | 127 base::DictionaryValue log_message_dict; |
127 log_message_dict.SetString("webview", webview); | 128 log_message_dict.SetString("webview", webview); |
128 log_message_dict.SetString("message.method", method); | 129 log_message_dict.SetString("message.method", method); |
129 log_message_dict.Set("message.params", params.DeepCopy()); | 130 log_message_dict.Set("message.params", base::MakeUnique<base::Value>(params)); |
130 std::string log_message_json; | 131 std::string log_message_json; |
131 base::JSONWriter::Write(log_message_dict, &log_message_json); | 132 base::JSONWriter::Write(log_message_dict, &log_message_json); |
132 | 133 |
133 // TODO(klm): extract timestamp from params? | 134 // TODO(klm): extract timestamp from params? |
134 // Look at where it is for Page, Network, Timeline, and trace events. | 135 // Look at where it is for Page, Network, Timeline, and trace events. |
135 log_->AddEntry(level, log_message_json); | 136 log_->AddEntry(level, log_message_json); |
136 } | 137 } |
137 | 138 |
138 void PerformanceLogger::AddLogEntry( | 139 void PerformanceLogger::AddLogEntry( |
139 const std::string& webview, | 140 const std::string& webview, |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 if (status.IsError()) | 288 if (status.IsError()) |
288 return status; | 289 return status; |
289 | 290 |
290 return StartTrace(); | 291 return StartTrace(); |
291 } | 292 } |
292 | 293 |
293 Status PerformanceLogger::IsTraceDone(bool* trace_done) const { | 294 Status PerformanceLogger::IsTraceDone(bool* trace_done) const { |
294 *trace_done = !trace_buffering_; | 295 *trace_done = !trace_buffering_; |
295 return Status(kOk); | 296 return Status(kOk); |
296 } | 297 } |
OLD | NEW |