| 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();
|
| }
|
|
|
|
|