Index: third_party/WebKit/Source/core/inspector/InspectorSession.cpp |
diff --git a/third_party/WebKit/Source/core/inspector/InspectorSession.cpp b/third_party/WebKit/Source/core/inspector/InspectorSession.cpp |
index a8ef5379fe4401b964e1448e028982b526c58bca..58ace0eb3dd66443082bd0476a42b978a356d19d 100644 |
--- a/third_party/WebKit/Source/core/inspector/InspectorSession.cpp |
+++ b/third_party/WebKit/Source/core/inspector/InspectorSession.cpp |
@@ -91,6 +91,21 @@ void InspectorSession::didCommitLoadForLocalFrame(LocalFrame* frame) { |
m_agents[i]->didCommitLoadForLocalFrame(frame); |
} |
+void InspectorSession::sendProtocolResponse( |
+ int callId, |
+ std::unique_ptr<protocol::Serializable> message) { |
+ sendProtocolResponse(callId, message->serialize()); |
+} |
+ |
+void InspectorSession::sendProtocolResponse( |
+ int callId, |
+ const v8_inspector::StringView& message) { |
+ // We can potentially avoid copies if WebString would convert to utf8 right |
+ // from StringView, but it uses StringImpl itself, so we don't create any |
+ // extra copies here. |
+ sendProtocolResponse(callId, toCoreString(message)); |
+} |
+ |
void InspectorSession::sendProtocolResponse(int callId, const String& message) { |
if (m_disposed) |
return; |
@@ -104,24 +119,51 @@ void InspectorSession::sendProtocolResponse(int callId, const String& message) { |
m_client->sendProtocolMessage(m_sessionId, callId, message, stateToSend); |
} |
-void InspectorSession::sendProtocolResponse( |
- int callId, |
- const v8_inspector::StringView& message) { |
- // We can potentially avoid copies if WebString would convert to utf8 right |
- // from StringView, but it uses StringImpl itself, so we don't create any |
- // extra copies here. |
- sendProtocolResponse(callId, toCoreString(message)); |
-} |
+class InspectorSession::Notification { |
+ public: |
+ static std::unique_ptr<Notification> createForBlink( |
+ std::unique_ptr<protocol::Serializable> notification) { |
+ return std::unique_ptr<Notification>( |
+ new Notification(std::move(notification))); |
+ } |
+ |
+ static std::unique_ptr<Notification> createForV8( |
+ const v8_inspector::StringView& notification) { |
+ return std::unique_ptr<Notification>(new Notification(notification)); |
+ } |
+ |
+ String serialize() { |
+ if (m_notification) { |
+ m_rawNotification = m_notification->serialize(); |
+ m_notification.reset(); |
+ } |
+ return m_rawNotification; |
+ } |
-void InspectorSession::sendProtocolNotification(const String& message) { |
+ private: |
+ explicit Notification(std::unique_ptr<protocol::Serializable> notification) |
+ : m_notification(std::move(notification)) {} |
+ |
+ explicit Notification(const v8_inspector::StringView& notification) |
+ : m_rawNotification(toCoreString(notification)) {} |
+ |
+ std::unique_ptr<protocol::Serializable> m_notification; |
+ String m_rawNotification; |
+}; |
+ |
+void InspectorSession::sendProtocolNotification( |
+ std::unique_ptr<protocol::Serializable> notification) { |
if (m_disposed) |
return; |
- m_notificationQueue.append(message); |
+ m_notificationQueue.append( |
+ Notification::createForBlink(std::move(notification))); |
} |
void InspectorSession::sendProtocolNotification( |
- const v8_inspector::StringView& message) { |
- sendProtocolNotification(toCoreString(message)); |
+ const v8_inspector::StringView& notification) { |
+ if (m_disposed) |
+ return; |
+ m_notificationQueue.append(Notification::createForV8(notification)); |
} |
void InspectorSession::flushProtocolNotifications() { |
@@ -129,9 +171,10 @@ void InspectorSession::flushProtocolNotifications() { |
return; |
for (size_t i = 0; i < m_agents.size(); i++) |
m_agents[i]->flushPendingProtocolNotifications(); |
- for (size_t i = 0; i < m_notificationQueue.size(); ++i) |
- m_client->sendProtocolMessage(m_sessionId, 0, m_notificationQueue[i], |
- String()); |
+ for (size_t i = 0; i < m_notificationQueue.size(); ++i) { |
+ m_client->sendProtocolMessage( |
+ m_sessionId, 0, m_notificationQueue[i]->serialize(), String()); |
+ } |
m_notificationQueue.clear(); |
} |