diff options
author | macourteau <macourteau@chromium.org> | 2015-01-22 07:13:11 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-22 15:14:06 +0000 |
commit | f218aac1f47fe388852d54f80e92846377d98a54 (patch) | |
tree | cf60dfd0b7f300e16c2a17a705089b2507af0e19 | |
parent | 35621311376582986392d6bba1e3491f2ba09c4f (diff) | |
download | chromium_src-f218aac1f47fe388852d54f80e92846377d98a54.zip chromium_src-f218aac1f47fe388852d54f80e92846377d98a54.tar.gz chromium_src-f218aac1f47fe388852d54f80e92846377d98a54.tar.bz2 |
Revert of DevTools: update backend state along with the command acks (Chromium side). (patchset #5 id:100001 of https://codereview.chromium.org/826353005/)
Reason for revert:
Breaks the build (linking error) on Chromium Webkit Mac Builder (dbg):
http://build.chromium.org/p/chromium.webkit/builders/Mac%20Builder%20%28dbg%29/builds/72737/steps/compile/logs/stdio
Original issue's description:
> DevTools: update backend state along with the command acks (Chromium side).
>
> BUG=445587
>
> Committed: https://crrev.com/2f83dcd9da7588cc100bf6eadd1f3f9b245b95b8
> Cr-Commit-Position: refs/heads/master@{#312612}
TBR=dgozman@chromium.org,tsepez@chromium.org,jam@chromium.org,pfeldman@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=445587
Review URL: https://codereview.chromium.org/863283003
Cr-Commit-Position: refs/heads/master@{#312619}
16 files changed, 154 insertions, 155 deletions
diff --git a/content/browser/devtools/ipc_devtools_agent_host.cc b/content/browser/devtools/ipc_devtools_agent_host.cc index b6b52fe..9218d58 100644 --- a/content/browser/devtools/ipc_devtools_agent_host.cc +++ b/content/browser/devtools/ipc_devtools_agent_host.cc @@ -4,6 +4,8 @@ #include "content/browser/devtools/ipc_devtools_agent_host.h" +#include "content/common/devtools_messages.h" + namespace content { void IPCDevToolsAgentHost::Attach() { @@ -34,35 +36,31 @@ IPCDevToolsAgentHost::IPCDevToolsAgentHost() IPCDevToolsAgentHost::~IPCDevToolsAgentHost() { } -void IPCDevToolsAgentHost::Reattach() { +void IPCDevToolsAgentHost::Reattach(const std::string& saved_agent_state) { SendMessageToAgent(new DevToolsAgentMsg_Reattach( - MSG_ROUTING_NONE, GetId(), state_cookie_)); + MSG_ROUTING_NONE, GetId(), saved_agent_state)); OnClientAttached(); } void IPCDevToolsAgentHost::ProcessChunkedMessageFromAgent( - const DevToolsMessageChunk& chunk) { - if (chunk.is_last && !chunk.post_state.empty()) - state_cookie_ = chunk.post_state; - - if (chunk.is_first && chunk.is_last) { - CHECK(message_buffer_size_ == 0); - SendMessageToClient(chunk.data); + const std::string& message, uint32 total_size) { + if (total_size && total_size == message.length()) { + DCHECK(message_buffer_size_ == 0); + SendMessageToClient(message); return; } - if (chunk.is_first) { + if (total_size) { + DCHECK(message_buffer_size_ == 0); message_buffer_ = std::string(); - message_buffer_.reserve(chunk.message_size); - message_buffer_size_ = chunk.message_size; + message_buffer_.reserve(total_size); + message_buffer_size_ = total_size; } - CHECK(message_buffer_.size() + chunk.data.size() <= - message_buffer_size_); - message_buffer_.append(chunk.data); + message_buffer_.append(message); - if (chunk.is_last) { - CHECK(message_buffer_.size() == message_buffer_size_); + if (message_buffer_.size() >= message_buffer_size_) { + DCHECK(message_buffer_.size() == message_buffer_size_); SendMessageToClient(message_buffer_); message_buffer_ = std::string(); message_buffer_size_ = 0; diff --git a/content/browser/devtools/ipc_devtools_agent_host.h b/content/browser/devtools/ipc_devtools_agent_host.h index 6478bc3..a952588 100644 --- a/content/browser/devtools/ipc_devtools_agent_host.h +++ b/content/browser/devtools/ipc_devtools_agent_host.h @@ -6,7 +6,6 @@ #define CONTENT_BROWSER_DEVTOOLS_IPC_DEVTOOLS_AGENT_HOST_H_ #include "content/browser/devtools/devtools_agent_host_impl.h" -#include "content/common/devtools_messages.h" namespace IPC { class Message; @@ -26,8 +25,9 @@ class CONTENT_EXPORT IPCDevToolsAgentHost : public DevToolsAgentHostImpl { IPCDevToolsAgentHost(); ~IPCDevToolsAgentHost() override; - void Reattach(); - void ProcessChunkedMessageFromAgent(const DevToolsMessageChunk& chunk); + void Reattach(const std::string& saved_agent_state); + void ProcessChunkedMessageFromAgent(const std::string& message, + uint32 total_size); virtual void SendMessageToAgent(IPC::Message* msg) = 0; virtual void OnClientAttached() = 0; @@ -36,7 +36,6 @@ class CONTENT_EXPORT IPCDevToolsAgentHost : public DevToolsAgentHostImpl { private: std::string message_buffer_; uint32 message_buffer_size_; - std::string state_cookie_; }; } // namespace content diff --git a/content/browser/devtools/render_view_devtools_agent_host.cc b/content/browser/devtools/render_view_devtools_agent_host.cc index f863cc70..e6a12ca 100644 --- a/content/browser/devtools/render_view_devtools_agent_host.cc +++ b/content/browser/devtools/render_view_devtools_agent_host.cc @@ -23,6 +23,7 @@ #include "content/browser/renderer_host/render_view_host_impl.h" #include "content/browser/site_instance_impl.h" #include "content/browser/web_contents/web_contents_impl.h" +#include "content/common/devtools_messages.h" #include "content/common/view_messages.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/content_browser_client.h" @@ -353,6 +354,8 @@ bool RenderViewDevToolsAgentHost::OnMessageReceived( IPC_BEGIN_MESSAGE_MAP(RenderViewDevToolsAgentHost, message) IPC_MESSAGE_HANDLER(DevToolsClientMsg_DispatchOnInspectorFrontend, OnDispatchOnInspectorFrontend) + IPC_MESSAGE_HANDLER(DevToolsHostMsg_SaveAgentRuntimeState, + OnSaveAgentRuntimeState) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; @@ -474,7 +477,7 @@ bool RenderViewDevToolsAgentHost::Close() { void RenderViewDevToolsAgentHost::ConnectRenderFrameHost(RenderFrameHost* rfh) { SetRenderFrameHost(rfh); if (IsAttached()) - Reattach(); + Reattach(state_); } void RenderViewDevToolsAgentHost::DisconnectRenderFrameHost() { @@ -501,11 +504,19 @@ void RenderViewDevToolsAgentHost::SynchronousSwapCompositorFrame( page_handler_->OnSwapCompositorFrame(frame_metadata); } +void RenderViewDevToolsAgentHost::OnSaveAgentRuntimeState( + const std::string& state) { + if (!render_frame_host_) + return; + state_ = state; +} + void RenderViewDevToolsAgentHost::OnDispatchOnInspectorFrontend( - const DevToolsMessageChunk& message) { + const std::string& message, + uint32 total_size) { if (!IsAttached() || !render_frame_host_) return; - ProcessChunkedMessageFromAgent(message); + ProcessChunkedMessageFromAgent(message, total_size); } void RenderViewDevToolsAgentHost::DispatchOnInspectorFrontend( diff --git a/content/browser/devtools/render_view_devtools_agent_host.h b/content/browser/devtools/render_view_devtools_agent_host.h index af182b2..9b8b605 100644 --- a/content/browser/devtools/render_view_devtools_agent_host.h +++ b/content/browser/devtools/render_view_devtools_agent_host.h @@ -105,8 +105,10 @@ class CONTENT_EXPORT RenderViewDevToolsAgentHost void OnSwapCompositorFrame(const IPC::Message& message); bool OnSetTouchEventEmulationEnabled(const IPC::Message& message); - void OnDispatchOnInspectorFrontend(const DevToolsMessageChunk& message); + void OnDispatchOnInspectorFrontend(const std::string& message, + uint32 total_size); void DispatchOnInspectorFrontend(const std::string& message); + void OnSaveAgentRuntimeState(const std::string& state); void ClientDetachedFromRenderer(); @@ -125,6 +127,7 @@ class CONTENT_EXPORT RenderViewDevToolsAgentHost #if defined(OS_ANDROID) scoped_ptr<PowerSaveBlockerImpl> power_save_blocker_; #endif + std::string state_; NotificationRegistrar registrar_; bool reattaching_; diff --git a/content/browser/devtools/service_worker_devtools_manager.cc b/content/browser/devtools/service_worker_devtools_manager.cc index eb744af..18b3eb56f 100644 --- a/content/browser/devtools/service_worker_devtools_manager.cc +++ b/content/browser/devtools/service_worker_devtools_manager.cc @@ -9,6 +9,7 @@ #include "content/browser/devtools/service_worker_devtools_agent_host.h" #include "content/browser/devtools/shared_worker_devtools_agent_host.h" #include "content/browser/shared_worker/shared_worker_instance.h" +#include "content/common/devtools_messages.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/worker_service.h" diff --git a/content/browser/devtools/worker_devtools_agent_host.cc b/content/browser/devtools/worker_devtools_agent_host.cc index a95a50e..ceb9a79 100644 --- a/content/browser/devtools/worker_devtools_agent_host.cc +++ b/content/browser/devtools/worker_devtools_agent_host.cc @@ -4,8 +4,8 @@ #include "content/browser/devtools/worker_devtools_agent_host.h" -#include "content/browser/devtools/ipc_devtools_agent_host.h" #include "content/browser/devtools/protocol/devtools_protocol_handler.h" +#include "content/common/devtools_messages.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_process_host.h" @@ -60,6 +60,8 @@ bool WorkerDevToolsAgentHost::OnMessageReceived( IPC_BEGIN_MESSAGE_MAP(WorkerDevToolsAgentHost, msg) IPC_MESSAGE_HANDLER(DevToolsClientMsg_DispatchOnInspectorFrontend, OnDispatchOnInspectorFrontend) + IPC_MESSAGE_HANDLER(DevToolsHostMsg_SaveAgentRuntimeState, + OnSaveAgentRuntimeState) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; @@ -73,7 +75,7 @@ void WorkerDevToolsAgentHost::WorkerReadyForInspection() { DCHECK(IsAttached()); state_ = WORKER_INSPECTED; AttachToWorker(); - Reattach(); + Reattach(saved_agent_state_); } } @@ -131,11 +133,17 @@ void WorkerDevToolsAgentHost::WorkerCreated() { } void WorkerDevToolsAgentHost::OnDispatchOnInspectorFrontend( - const DevToolsMessageChunk& message) { + const std::string& message, + uint32 total_size) { if (!IsAttached()) return; - ProcessChunkedMessageFromAgent(message); + ProcessChunkedMessageFromAgent(message, total_size); +} + +void WorkerDevToolsAgentHost::OnSaveAgentRuntimeState( + const std::string& state) { + saved_agent_state_ = state; } } // namespace content diff --git a/content/browser/devtools/worker_devtools_agent_host.h b/content/browser/devtools/worker_devtools_agent_host.h index 34750ed..9a55c24 100644 --- a/content/browser/devtools/worker_devtools_agent_host.h +++ b/content/browser/devtools/worker_devtools_agent_host.h @@ -52,7 +52,9 @@ class WorkerDevToolsAgentHost : public IPCDevToolsAgentHost, void AttachToWorker(); void DetachFromWorker(); void WorkerCreated(); - void OnDispatchOnInspectorFrontend(const DevToolsMessageChunk& message); + void OnDispatchOnInspectorFrontend(const std::string& message, + uint32 total_size); + void OnSaveAgentRuntimeState(const std::string& state); void set_state(WorkerState state) { state_ = state; } const WorkerId& worker_id() const { return worker_id_; } @@ -62,6 +64,7 @@ class WorkerDevToolsAgentHost : public IPCDevToolsAgentHost, WorkerState state_; WorkerId worker_id_; + std::string saved_agent_state_; DISALLOW_COPY_AND_ASSIGN(WorkerDevToolsAgentHost); }; diff --git a/content/child/shared_worker_devtools_agent.cc b/content/child/shared_worker_devtools_agent.cc index 3a9b350..5d12737 100644 --- a/content/child/shared_worker_devtools_agent.cc +++ b/content/child/shared_worker_devtools_agent.cc @@ -44,37 +44,28 @@ bool SharedWorkerDevToolsAgent::OnMessageReceived(const IPC::Message& message) { } void SharedWorkerDevToolsAgent::SendDevToolsMessage( - int call_id, - const blink::WebString& msg, - const blink::WebString& state) { - std::string message = msg.utf8(); - std::string post_state = state.utf8(); - DevToolsMessageChunk chunk; - chunk.message_size = message.size(); - chunk.is_first = true; - + const blink::WebString& message) { + std::string msg(message.utf8()); if (message.length() < kMaxMessageChunkSize) { - chunk.data.swap(message); - chunk.call_id = call_id; - chunk.post_state = post_state; - chunk.is_last = true; Send(new DevToolsClientMsg_DispatchOnInspectorFrontend( - route_id_, chunk)); + route_id_, msg, msg.size())); return; } - for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) { - chunk.is_last = pos + kMaxMessageChunkSize >= message.length(); - chunk.call_id = chunk.is_last ? call_id : 0; - chunk.post_state = chunk.is_last ? post_state : std::string(); - chunk.data = message.substr(pos, kMaxMessageChunkSize); + for (size_t pos = 0; pos < msg.length(); pos += kMaxMessageChunkSize) { Send(new DevToolsClientMsg_DispatchOnInspectorFrontend( - route_id_, chunk)); - chunk.is_first = false; - chunk.message_size = 0; + route_id_, + msg.substr(pos, kMaxMessageChunkSize), + pos ? 0 : msg.size())); } } +void SharedWorkerDevToolsAgent::SaveDevToolsAgentState( + const blink::WebString& state) { + Send(new DevToolsHostMsg_SaveAgentRuntimeState(route_id_, + state.utf8())); +} + void SharedWorkerDevToolsAgent::OnAttach(const std::string& host_id) { webworker_->attachDevTools(WebString::fromUTF8(host_id)); } diff --git a/content/child/shared_worker_devtools_agent.h b/content/child/shared_worker_devtools_agent.h index 2d6a732..a2d028e 100644 --- a/content/child/shared_worker_devtools_agent.h +++ b/content/child/shared_worker_devtools_agent.h @@ -27,9 +27,8 @@ class SharedWorkerDevToolsAgent { // Called on the Worker thread. bool OnMessageReceived(const IPC::Message& message); - void SendDevToolsMessage(int call_id, - const blink::WebString& message, - const blink::WebString& post_state); + void SendDevToolsMessage(const blink::WebString&); + void SaveDevToolsAgentState(const blink::WebString& state); private: void OnAttach(const std::string& host_id); diff --git a/content/common/devtools_messages.h b/content/common/devtools_messages.h index ee475c8..276a82f 100644 --- a/content/common/devtools_messages.h +++ b/content/common/devtools_messages.h @@ -54,24 +54,14 @@ // These are messages sent from DevToolsAgent to DevToolsClient through the // browser. - -// Agent -> Client message chunk. -// |is_first| marks the first chunk, comes with the |message_size| for -// total message size. -// |is_last| marks the last chunk. |call_id| and |post_state| are optional -// parameters passed with the last chunk of the protocol response. -IPC_STRUCT_BEGIN(DevToolsMessageChunk) - IPC_STRUCT_MEMBER(bool, is_first) - IPC_STRUCT_MEMBER(bool, is_last) - IPC_STRUCT_MEMBER(int, message_size) - IPC_STRUCT_MEMBER(int, call_id) - IPC_STRUCT_MEMBER(std::string, data) - IPC_STRUCT_MEMBER(std::string, post_state) -IPC_STRUCT_END() +// WebKit-level transport. // Sends response from the agent to the client. Supports chunked encoding. -IPC_MESSAGE_ROUTED1(DevToolsClientMsg_DispatchOnInspectorFrontend, - DevToolsMessageChunk /* message */) +// First (the only) chunk arrives with the |total_size| != 0, +// remaining chunks arrive with |total_size| == 0. +IPC_MESSAGE_ROUTED2(DevToolsClientMsg_DispatchOnInspectorFrontend, + std::string /* message */, + uint32 /* total_size */) //----------------------------------------------------------------------------- // These are messages sent from DevToolsClient to DevToolsAgent through the @@ -121,6 +111,11 @@ IPC_MESSAGE_ROUTED0(DevToolsMsg_SetupDevToolsClient) IPC_MESSAGE_ROUTED1(DevToolsHostMsg_DispatchOnEmbedder, std::string /* message */) +// Updates agent runtime state stored in devtools manager in order to support +// cross-navigation instrumentation. +IPC_MESSAGE_ROUTED1(DevToolsHostMsg_SaveAgentRuntimeState, + std::string /* state */) + //----------------------------------------------------------------------------- // These are messages sent from the GPU process to the inspected renderer. diff --git a/content/renderer/devtools/devtools_agent.cc b/content/renderer/devtools/devtools_agent.cc index 780001c..c84cecd 100644 --- a/content/renderer/devtools/devtools_agent.cc +++ b/content/renderer/devtools/devtools_agent.cc @@ -118,12 +118,21 @@ bool DevToolsAgent::OnMessageReceived(const IPC::Message& message) { return handled; } -void DevToolsAgent::sendProtocolMessage( - int call_id, - const blink::WebString& message, - const blink::WebString& state_cookie) { - SendChunkedProtocolMessage( - this, routing_id(), call_id, message.utf8(), state_cookie.utf8()); +void DevToolsAgent::sendMessageToInspectorFrontend( + const blink::WebString& message) { + std::string msg(message.utf8()); + if (msg.length() < kMaxMessageChunkSize) { + Send(new DevToolsClientMsg_DispatchOnInspectorFrontend( + routing_id(), msg, msg.size())); + return; + } + + for (size_t pos = 0; pos < msg.length(); pos += kMaxMessageChunkSize) { + Send(new DevToolsClientMsg_DispatchOnInspectorFrontend( + routing_id(), + msg.substr(pos, kMaxMessageChunkSize), + pos ? 0 : msg.size())); + } } long DevToolsAgent::processId() { @@ -134,6 +143,11 @@ int DevToolsAgent::debuggerId() { return routing_id(); } +void DevToolsAgent::saveAgentRuntimeState( + const blink::WebString& state) { + Send(new DevToolsHostMsg_SaveAgentRuntimeState(routing_id(), state.utf8())); +} + blink::WebDevToolsAgentClient::WebKitClientMessageLoop* DevToolsAgent::createClientMessageLoop() { return new WebKitClientMessageLoopImpl(); @@ -261,39 +275,6 @@ DevToolsAgent* DevToolsAgent::FromRoutingId(int routing_id) { return NULL; } -// static -void DevToolsAgent::SendChunkedProtocolMessage( - IPC::Sender* sender, - int routing_id, - int call_id, - const std::string& message, - const std::string& post_state) { - DevToolsMessageChunk chunk; - chunk.message_size = message.size(); - chunk.is_first = true; - - if (message.length() < kMaxMessageChunkSize) { - chunk.data = message; - chunk.call_id = call_id; - chunk.post_state = post_state; - chunk.is_last = true; - sender->Send(new DevToolsClientMsg_DispatchOnInspectorFrontend( - routing_id, chunk)); - return; - } - - for (size_t pos = 0; pos < message.length(); pos += kMaxMessageChunkSize) { - chunk.is_last = pos + kMaxMessageChunkSize >= message.length(); - chunk.call_id = chunk.is_last ? call_id : 0; - chunk.post_state = chunk.is_last ? post_state : std::string(); - chunk.data = message.substr(pos, kMaxMessageChunkSize); - sender->Send(new DevToolsClientMsg_DispatchOnInspectorFrontend( - routing_id, chunk)); - chunk.is_first = false; - chunk.message_size = 0; - } -} - void DevToolsAgent::OnAttach(const std::string& host_id) { WebDevToolsAgent* web_agent = GetWebAgent(); if (web_agent) { diff --git a/content/renderer/devtools/devtools_agent.h b/content/renderer/devtools/devtools_agent.h index 5140a43..8a8d998 100644 --- a/content/renderer/devtools/devtools_agent.h +++ b/content/renderer/devtools/devtools_agent.h @@ -40,13 +40,6 @@ class DevToolsAgent : public RenderFrameObserver, // Returns agent instance for its routing id. static DevToolsAgent* FromRoutingId(int routing_id); - static void SendChunkedProtocolMessage( - IPC::Sender* sender, - int routing_id, - int call_id, - const std::string& message, - const std::string& post_state); - blink::WebDevToolsAgent* GetWebAgent(); bool IsAttached(); @@ -56,32 +49,32 @@ class DevToolsAgent : public RenderFrameObserver, bool OnMessageReceived(const IPC::Message& message) override; // WebDevToolsAgentClient implementation - void sendProtocolMessage(int call_id, - const blink::WebString& response, - const blink::WebString& state) override; - long processId() override; - int debuggerId() override; - blink::WebDevToolsAgentClient::WebKitClientMessageLoop* + virtual void sendMessageToInspectorFrontend(const blink::WebString& data); + + virtual long processId() override; + virtual int debuggerId() override; + virtual void saveAgentRuntimeState(const blink::WebString& state) override; + virtual blink::WebDevToolsAgentClient::WebKitClientMessageLoop* createClientMessageLoop() override; - void willEnterDebugLoop() override; - void didExitDebugLoop() override; + virtual void willEnterDebugLoop() override; + virtual void didExitDebugLoop() override; typedef void (*TraceEventCallback)( char phase, const unsigned char*, const char* name, unsigned long long id, int numArgs, const char* const* argNames, const unsigned char* argTypes, const unsigned long long* argValues, unsigned char flags, double timestamp); - void resetTraceEventCallback() override; - void setTraceEventCallback(const blink::WebString& category_filter, - TraceEventCallback cb) override; - void enableTracing(const blink::WebString& category_filter) override; - void disableTracing() override; - void startGPUEventsRecording() override; - void stopGPUEventsRecording() override; - - void enableDeviceEmulation( + virtual void resetTraceEventCallback() override; + virtual void setTraceEventCallback(const blink::WebString& category_filter, + TraceEventCallback cb) override; + virtual void enableTracing(const blink::WebString& category_filter) override; + virtual void disableTracing() override; + virtual void startGPUEventsRecording() override; + virtual void stopGPUEventsRecording() override; + + virtual void enableDeviceEmulation( const blink::WebDeviceEmulationParams& params) override; - void disableDeviceEmulation() override; + virtual void disableDeviceEmulation() override; void OnAttach(const std::string& host_id); void OnReattach(const std::string& host_id, diff --git a/content/renderer/service_worker/embedded_worker_context_client.cc b/content/renderer/service_worker/embedded_worker_context_client.cc index 98793fc..eef9919 100644 --- a/content/renderer/service_worker/embedded_worker_context_client.cc +++ b/content/renderer/service_worker/embedded_worker_context_client.cc @@ -23,7 +23,6 @@ #include "content/common/service_worker/embedded_worker_messages.h" #include "content/common/service_worker/service_worker_types.h" #include "content/public/renderer/document_state.h" -#include "content/renderer/devtools/devtools_agent.h" #include "content/renderer/render_thread_impl.h" #include "content/renderer/service_worker/embedded_worker_dispatcher.h" #include "content/renderer/service_worker/service_worker_script_context.h" @@ -37,6 +36,8 @@ namespace content { namespace { +const size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4; + // For now client must be a per-thread instance. // TODO(kinuko): This needs to be refactored when we start using thread pool // or having multiple clients per one thread. @@ -247,13 +248,28 @@ void EmbeddedWorkerContextClient::reportConsoleMessage( embedded_worker_id_, params)); } -void EmbeddedWorkerContextClient::sendDevToolsMessage( - int call_id, - const blink::WebString& message, - const blink::WebString& state_cookie) { - DevToolsAgent::SendChunkedProtocolMessage( - sender_.get(), worker_devtools_agent_route_id_, - call_id, message.utf8(), state_cookie.utf8()); +void EmbeddedWorkerContextClient::dispatchDevToolsMessage( + const blink::WebString& message) { + std::string msg(message.utf8()); + + if (msg.length() < kMaxMessageChunkSize) { + sender_->Send(new DevToolsClientMsg_DispatchOnInspectorFrontend( + worker_devtools_agent_route_id_, msg, msg.size())); + return; + } + + for (size_t pos = 0; pos < msg.length(); pos += kMaxMessageChunkSize) { + sender_->Send(new DevToolsClientMsg_DispatchOnInspectorFrontend( + worker_devtools_agent_route_id_, + msg.substr(pos, kMaxMessageChunkSize), + pos ? 0 : msg.size())); + } +} + +void EmbeddedWorkerContextClient::saveDevToolsAgentState( + const blink::WebString& state) { + sender_->Send(new DevToolsHostMsg_SaveAgentRuntimeState( + worker_devtools_agent_route_id_, state.utf8())); } void EmbeddedWorkerContextClient::didHandleActivateEvent( diff --git a/content/renderer/service_worker/embedded_worker_context_client.h b/content/renderer/service_worker/embedded_worker_context_client.h index 9a381c6..5e5f6014 100644 --- a/content/renderer/service_worker/embedded_worker_context_client.h +++ b/content/renderer/service_worker/embedded_worker_context_client.h @@ -83,9 +83,8 @@ class EmbeddedWorkerContextClient const blink::WebString& message, int line_number, const blink::WebString& source_url); - virtual void sendDevToolsMessage(int call_id, - const blink::WebString& message, - const blink::WebString& state); + virtual void dispatchDevToolsMessage(const blink::WebString&); + virtual void saveDevToolsAgentState(const blink::WebString&); virtual void didHandleActivateEvent(int request_id, blink::WebServiceWorkerEventResult); virtual void didHandleInstallEvent(int request_id, diff --git a/content/renderer/shared_worker/embedded_shared_worker_stub.cc b/content/renderer/shared_worker/embedded_shared_worker_stub.cc index d026cec..a2b6639 100644 --- a/content/renderer/shared_worker/embedded_shared_worker_stub.cc +++ b/content/renderer/shared_worker/embedded_shared_worker_stub.cc @@ -171,11 +171,14 @@ blink::WebWorkerPermissionClientProxy* ChildThread::current()->thread_safe_sender()); } -void EmbeddedSharedWorkerStub::sendDevToolsMessage( - int call_id, - const blink::WebString& message, - const blink::WebString& state) { - worker_devtools_agent_->SendDevToolsMessage(call_id, message, state); +void EmbeddedSharedWorkerStub::dispatchDevToolsMessage( + const blink::WebString& message) { + worker_devtools_agent_->SendDevToolsMessage(message); +} + +void EmbeddedSharedWorkerStub::saveDevToolsAgentState( + const blink::WebString& state) { + worker_devtools_agent_->SaveDevToolsAgentState(state); } void EmbeddedSharedWorkerStub::Shutdown() { diff --git a/content/renderer/shared_worker/embedded_shared_worker_stub.h b/content/renderer/shared_worker/embedded_shared_worker_stub.h index c698ef6..c710efa 100644 --- a/content/renderer/shared_worker/embedded_shared_worker_stub.h +++ b/content/renderer/shared_worker/embedded_shared_worker_stub.h @@ -58,10 +58,9 @@ class EmbeddedSharedWorkerStub : public IPC::Listener, virtual blink::WebWorkerPermissionClientProxy* createWorkerPermissionClientProxy( const blink::WebSecurityOrigin& origin) override; - virtual void sendDevToolsMessage( - int call_id, - const blink::WebString& message, - const blink::WebString& state) override; + virtual void dispatchDevToolsMessage( + const blink::WebString& message) override; + virtual void saveDevToolsAgentState(const blink::WebString& state) override; private: ~EmbeddedSharedWorkerStub() override; |