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

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

Issue 2522583002: Roll third_party/inspector_protocol to 4ad35c45aca9834b67ec2cb152c816ea1b7ceb48 (Closed)
Patch Set: updated README.chromium 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..387a8189a7bbf2dbc829283e45e5381da53f18d3 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorSession.cpp
+++ b/third_party/WebKit/Source/core/inspector/InspectorSession.cpp
@@ -91,12 +91,27 @@ 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::sendResponse(
+ int callId,
+ std::unique_ptr<v8_inspector::StringBuffer> 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->string()));
+}
+
void InspectorSession::sendProtocolResponse(int callId, const String& message) {
if (m_disposed)
return;
flushProtocolNotifications();
m_state->setString(kV8StateKey, toCoreString(m_v8Session->stateJSON()));
- String stateToSend = m_state->toJSONString();
+ String stateToSend = m_state->serialize();
if (stateToSend == m_lastSentState)
stateToSend = String();
else
@@ -104,24 +119,58 @@ 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(
+ std::unique_ptr<v8_inspector::StringBuffer> notification) {
+ return std::unique_ptr<Notification>(
+ new Notification(std::move(notification)));
+ }
+
+ String serialize() {
+ if (m_blinkNotification) {
+ m_serialized = m_blinkNotification->serialize();
+ m_blinkNotification.reset();
+ } else if (m_v8Notification) {
+ m_serialized = toCoreString(m_v8Notification->string());
+ m_v8Notification.reset();
+ }
+ return m_serialized;
+ }
+
+ private:
+ explicit Notification(std::unique_ptr<protocol::Serializable> notification)
+ : m_blinkNotification(std::move(notification)) {}
-void InspectorSession::sendProtocolNotification(const String& message) {
+ explicit Notification(
+ std::unique_ptr<v8_inspector::StringBuffer> notification)
+ : m_v8Notification(std::move(notification)) {}
+
+ std::unique_ptr<protocol::Serializable> m_blinkNotification;
+ std::unique_ptr<v8_inspector::StringBuffer> m_v8Notification;
+ String m_serialized;
+};
+
+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));
+void InspectorSession::sendNotification(
+ std::unique_ptr<v8_inspector::StringBuffer> notification) {
+ if (m_disposed)
+ return;
+ m_notificationQueue.append(
+ Notification::createForV8(std::move(notification)));
}
void InspectorSession::flushProtocolNotifications() {
@@ -129,9 +178,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();
}
« no previous file with comments | « third_party/WebKit/Source/core/inspector/InspectorSession.h ('k') | third_party/WebKit/Source/core/inspector/LayoutEditor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698