| 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" |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 trace_buffering_ = false; | 183 trace_buffering_ = false; |
| 184 } else if (method == "Tracing.dataCollected") { | 184 } else if (method == "Tracing.dataCollected") { |
| 185 // The Tracing.dataCollected event contains a list of trace events. | 185 // The Tracing.dataCollected event contains a list of trace events. |
| 186 // Add each one as an individual log entry of method Tracing.dataCollected. | 186 // Add each one as an individual log entry of method Tracing.dataCollected. |
| 187 const base::ListValue* traces; | 187 const base::ListValue* traces; |
| 188 if (!params.GetList("value", &traces)) { | 188 if (!params.GetList("value", &traces)) { |
| 189 return Status(kUnknownError, | 189 return Status(kUnknownError, |
| 190 "received DevTools trace data in unexpected format"); | 190 "received DevTools trace data in unexpected format"); |
| 191 } | 191 } |
| 192 for (const auto& trace : *traces) { | 192 for (const auto& trace : *traces) { |
| 193 const base::DictionaryValue* event_dict; | 193 base::DictionaryValue* event_dict; |
| 194 if (!trace.GetAsDictionary(&event_dict)) | 194 if (!trace->GetAsDictionary(&event_dict)) |
| 195 return Status(kUnknownError, "trace event must be a dictionary"); | 195 return Status(kUnknownError, "trace event must be a dictionary"); |
| 196 AddLogEntry(client->GetId(), "Tracing.dataCollected", *event_dict); | 196 AddLogEntry(client->GetId(), "Tracing.dataCollected", *event_dict); |
| 197 } | 197 } |
| 198 } else if (method == "Tracing.bufferUsage") { | 198 } else if (method == "Tracing.bufferUsage") { |
| 199 // 'value' will be between 0-1 and represents how full the DevTools trace | 199 // 'value' will be between 0-1 and represents how full the DevTools trace |
| 200 // buffer is. If the buffer is full, warn the user. | 200 // buffer is. If the buffer is full, warn the user. |
| 201 double buffer_usage = 0; | 201 double buffer_usage = 0; |
| 202 if (!params.GetDouble("percentFull", &buffer_usage)) { | 202 if (!params.GetDouble("percentFull", &buffer_usage)) { |
| 203 // Tracing.bufferUsage event will occur once per second, and it really | 203 // Tracing.bufferUsage event will occur once per second, and it really |
| 204 // only serves as a warning, so if we can't reliably tell whether the | 204 // only serves as a warning, so if we can't reliably tell whether the |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 if (status.IsError()) | 287 if (status.IsError()) |
| 288 return status; | 288 return status; |
| 289 | 289 |
| 290 return StartTrace(); | 290 return StartTrace(); |
| 291 } | 291 } |
| 292 | 292 |
| 293 Status PerformanceLogger::IsTraceDone(bool* trace_done) const { | 293 Status PerformanceLogger::IsTraceDone(bool* trace_done) const { |
| 294 *trace_done = !trace_buffering_; | 294 *trace_done = !trace_buffering_; |
| 295 return Status(kOk); | 295 return Status(kOk); |
| 296 } | 296 } |
| OLD | NEW |