Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(489)

Unified Diff: third_party/WebKit/Source/core/inspector/InspectorSession.cpp

Issue 2522583002: Roll third_party/inspector_protocol to 4ad35c45aca9834b67ec2cb152c816ea1b7ceb48 (Closed)
Patch Set: removed redundant new line Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..e124c53c07e91447d190425a68e1207145abaae3 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->serializeValue()->toJSONString());
+}
+
+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,49 @@ 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 string() {
+ if (m_notification)
+ return m_notification->serializeValue()->toJSONString();
dgozman 2016/11/21 22:29:16 Let's clear m_notification here to not store extra
kozy 2016/11/22 01:25:38 Done.
+ 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 +169,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]->string(), String());
+ }
m_notificationQueue.clear();
}

Powered by Google App Engine
This is Rietveld 408576698