| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/inspector/InspectorLogAgent.h" | 5 #include "core/inspector/InspectorLogAgent.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/SourceLocation.h" | 7 #include "bindings/core/v8/SourceLocation.h" |
| 8 #include "core/frame/PerformanceMonitor.h" | 8 #include "core/frame/PerformanceMonitor.h" |
| 9 #include "core/inspector/ConsoleMessage.h" | 9 #include "core/inspector/ConsoleMessage.h" |
| 10 #include "core/inspector/ConsoleMessageStorage.h" | 10 #include "core/inspector/ConsoleMessageStorage.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 85 } |
| 86 | 86 |
| 87 void InspectorLogAgent::restore() { | 87 void InspectorLogAgent::restore() { |
| 88 if (!m_state->booleanProperty(LogAgentState::logEnabled, false)) | 88 if (!m_state->booleanProperty(LogAgentState::logEnabled, false)) |
| 89 return; | 89 return; |
| 90 enable(); | 90 enable(); |
| 91 protocol::Value* config = m_state->get(LogAgentState::logViolations); | 91 protocol::Value* config = m_state->get(LogAgentState::logViolations); |
| 92 if (config) { | 92 if (config) { |
| 93 protocol::ErrorSupport errors; | 93 protocol::ErrorSupport errors; |
| 94 startViolationsReport( | 94 startViolationsReport( |
| 95 protocol::Array<ViolationSetting>::parse(config, &errors)); | 95 protocol::Array<ViolationSetting>::fromValue(config, &errors)); |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 | 98 |
| 99 void InspectorLogAgent::consoleMessageAdded(ConsoleMessage* message) { | 99 void InspectorLogAgent::consoleMessageAdded(ConsoleMessage* message) { |
| 100 DCHECK(m_enabled); | 100 DCHECK(m_enabled); |
| 101 | 101 |
| 102 std::unique_ptr<protocol::Log::LogEntry> entry = | 102 std::unique_ptr<protocol::Log::LogEntry> entry = |
| 103 protocol::Log::LogEntry::create() | 103 protocol::Log::LogEntry::create() |
| 104 .setSource(messageSourceValue(message->source())) | 104 .setSource(messageSourceValue(message->source())) |
| 105 .setLevel(messageLevelValue(message->level())) | 105 .setLevel(messageLevelValue(message->level())) |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 return PerformanceMonitor::kHandler; | 177 return PerformanceMonitor::kHandler; |
| 178 if (name == ViolationSetting::NameEnum::RecurringHandler) | 178 if (name == ViolationSetting::NameEnum::RecurringHandler) |
| 179 return PerformanceMonitor::kRecurringHandler; | 179 return PerformanceMonitor::kRecurringHandler; |
| 180 return PerformanceMonitor::kAfterLast; | 180 return PerformanceMonitor::kAfterLast; |
| 181 } | 181 } |
| 182 | 182 |
| 183 Response InspectorLogAgent::startViolationsReport( | 183 Response InspectorLogAgent::startViolationsReport( |
| 184 std::unique_ptr<protocol::Array<ViolationSetting>> settings) { | 184 std::unique_ptr<protocol::Array<ViolationSetting>> settings) { |
| 185 if (!m_enabled) | 185 if (!m_enabled) |
| 186 return Response::Error("Log is not enabled"); | 186 return Response::Error("Log is not enabled"); |
| 187 m_state->setValue(LogAgentState::logViolations, settings->serialize()); | 187 m_state->setValue(LogAgentState::logViolations, settings->toValue()); |
| 188 if (!m_performanceMonitor) | 188 if (!m_performanceMonitor) |
| 189 return Response::Error("Violations are not supported for this target"); | 189 return Response::Error("Violations are not supported for this target"); |
| 190 m_performanceMonitor->unsubscribeAll(this); | 190 m_performanceMonitor->unsubscribeAll(this); |
| 191 for (size_t i = 0; i < settings->length(); ++i) { | 191 for (size_t i = 0; i < settings->length(); ++i) { |
| 192 PerformanceMonitor::Violation violation = | 192 PerformanceMonitor::Violation violation = |
| 193 parseViolation(settings->get(i)->getName()); | 193 parseViolation(settings->get(i)->getName()); |
| 194 if (violation == PerformanceMonitor::kAfterLast) | 194 if (violation == PerformanceMonitor::kAfterLast) |
| 195 continue; | 195 continue; |
| 196 m_performanceMonitor->subscribe( | 196 m_performanceMonitor->subscribe( |
| 197 violation, settings->get(i)->getThreshold() / 1000, this); | 197 violation, settings->get(i)->getThreshold() / 1000, this); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 219 void InspectorLogAgent::reportGenericViolation(PerformanceMonitor::Violation, | 219 void InspectorLogAgent::reportGenericViolation(PerformanceMonitor::Violation, |
| 220 const String& text, | 220 const String& text, |
| 221 double time, | 221 double time, |
| 222 SourceLocation* location) { | 222 SourceLocation* location) { |
| 223 ConsoleMessage* message = ConsoleMessage::create( | 223 ConsoleMessage* message = ConsoleMessage::create( |
| 224 ViolationMessageSource, WarningMessageLevel, text, location->clone()); | 224 ViolationMessageSource, WarningMessageLevel, text, location->clone()); |
| 225 consoleMessageAdded(message); | 225 consoleMessageAdded(message); |
| 226 }; | 226 }; |
| 227 | 227 |
| 228 } // namespace blink | 228 } // namespace blink |
| OLD | NEW |