| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 for (const auto& trace : *traces) { | 192 for (const auto& trace : *traces) { |
| 193 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("value", &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 |
| 205 // buffer is full, just fail silently instead of spamming the logs. | 205 // buffer is full, just fail silently instead of spamming the logs. |
| 206 return Status(kOk); | 206 return Status(kOk); |
| 207 } | 207 } |
| 208 if (buffer_usage >= 0.99999) { | 208 if (buffer_usage >= 0.99999) { |
| 209 base::DictionaryValue params; | 209 base::DictionaryValue params; |
| 210 std::string err("Chrome's trace buffer filled while collecting events, " | 210 std::string err("Chrome's trace buffer filled while collecting events, " |
| 211 "so some trace events may have been lost"); | 211 "so some trace events may have been lost"); |
| 212 params.SetString("error", err); | 212 params.SetString("error", err); |
| (...skipping 74 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 |