| Index: third_party/WebKit/Source/core/inspector/WorkerInspectorController.cpp
|
| diff --git a/third_party/WebKit/Source/core/inspector/WorkerInspectorController.cpp b/third_party/WebKit/Source/core/inspector/WorkerInspectorController.cpp
|
| index bb020d7f8abfe5f67149d78f76cc2b885655c7e3..08f91c4c75a2de53150a52a22727fd85669d38fd 100644
|
| --- a/third_party/WebKit/Source/core/inspector/WorkerInspectorController.cpp
|
| +++ b/third_party/WebKit/Source/core/inspector/WorkerInspectorController.cpp
|
| @@ -61,46 +61,53 @@ WorkerInspectorController::~WorkerInspectorController() {
|
| DCHECK(!thread_);
|
| }
|
|
|
| -void WorkerInspectorController::ConnectFrontend() {
|
| - if (session_)
|
| +void WorkerInspectorController::ConnectFrontend(int session_id) {
|
| + if (sessions_.find(session_id) != sessions_.end())
|
| return;
|
|
|
| - // sessionId will be overwritten by WebDevToolsAgent::sendProtocolNotification
|
| - // call.
|
| - session_ = new InspectorSession(this, probe_sink_.Get(), 0,
|
| - debugger_->GetV8Inspector(),
|
| - debugger_->ContextGroupId(thread_), nullptr);
|
| - session_->Append(
|
| + InspectorSession* session = new InspectorSession(
|
| + this, probe_sink_.Get(), session_id, debugger_->GetV8Inspector(),
|
| + debugger_->ContextGroupId(thread_), nullptr);
|
| + session->Append(
|
| new InspectorLogAgent(thread_->GetConsoleMessageStorage(), nullptr));
|
| - thread_->GetWorkerBackingThread().BackingThread().AddTaskObserver(this);
|
| + if (sessions_.IsEmpty())
|
| + thread_->GetWorkerBackingThread().BackingThread().AddTaskObserver(this);
|
| + sessions_.insert(session_id, session);
|
| }
|
|
|
| -void WorkerInspectorController::DisconnectFrontend() {
|
| - if (!session_)
|
| +void WorkerInspectorController::DisconnectFrontend(int session_id) {
|
| + auto it = sessions_.find(session_id);
|
| + if (it == sessions_.end())
|
| return;
|
| - session_->Dispose();
|
| - session_.Clear();
|
| - thread_->GetWorkerBackingThread().BackingThread().RemoveTaskObserver(this);
|
| + it->value->Dispose();
|
| + sessions_.erase(it);
|
| + if (sessions_.IsEmpty())
|
| + thread_->GetWorkerBackingThread().BackingThread().RemoveTaskObserver(this);
|
| }
|
|
|
| void WorkerInspectorController::DispatchMessageFromFrontend(
|
| + int session_id,
|
| const String& message) {
|
| - if (!session_)
|
| + auto it = sessions_.find(session_id);
|
| + if (it == sessions_.end())
|
| return;
|
| String method;
|
| if (!protocol::DispatcherBase::getCommandName(message, &method))
|
| return;
|
| - session_->DispatchProtocolMessage(method, message);
|
| + it->value->DispatchProtocolMessage(method, message);
|
| }
|
|
|
| void WorkerInspectorController::Dispose() {
|
| - DisconnectFrontend();
|
| + Vector<int> ids;
|
| + CopyKeysToVector(sessions_, ids);
|
| + for (int session_id : ids)
|
| + DisconnectFrontend(session_id);
|
| thread_ = nullptr;
|
| }
|
|
|
| void WorkerInspectorController::FlushProtocolNotifications() {
|
| - if (session_)
|
| - session_->flushProtocolNotifications();
|
| + for (auto& it : sessions_)
|
| + it.value->flushProtocolNotifications();
|
| }
|
|
|
| void WorkerInspectorController::SendProtocolMessage(int session_id,
|
| @@ -108,19 +115,20 @@ void WorkerInspectorController::SendProtocolMessage(int session_id,
|
| const String& response,
|
| const String& state) {
|
| // Worker messages are wrapped, no need to handle callId or state.
|
| - thread_->GetWorkerReportingProxy().PostMessageToPageInspector(response);
|
| + thread_->GetWorkerReportingProxy().PostMessageToPageInspector(session_id,
|
| + response);
|
| }
|
|
|
| void WorkerInspectorController::WillProcessTask() {}
|
|
|
| void WorkerInspectorController::DidProcessTask() {
|
| - if (session_)
|
| - session_->flushProtocolNotifications();
|
| + for (auto& it : sessions_)
|
| + it.value->flushProtocolNotifications();
|
| }
|
|
|
| DEFINE_TRACE(WorkerInspectorController) {
|
| visitor->Trace(probe_sink_);
|
| - visitor->Trace(session_);
|
| + visitor->Trace(sessions_);
|
| }
|
|
|
| } // namespace blink
|
|
|