| Index: components/html_viewer/devtools_agent_impl.cc
|
| diff --git a/components/html_viewer/devtools_agent_impl.cc b/components/html_viewer/devtools_agent_impl.cc
|
| deleted file mode 100644
|
| index 2cf2e8942db94b7cb7294ba7f84f5151be91171b..0000000000000000000000000000000000000000
|
| --- a/components/html_viewer/devtools_agent_impl.cc
|
| +++ /dev/null
|
| @@ -1,93 +0,0 @@
|
| -// Copyright 2015 The Chromium Authors. All rights reserved.
|
| -// Use of this source code is governed by a BSD-style license that can be
|
| -// found in the LICENSE file.
|
| -
|
| -#include "components/html_viewer/devtools_agent_impl.h"
|
| -
|
| -#include <utility>
|
| -
|
| -#include "base/bind.h"
|
| -#include "base/logging.h"
|
| -#include "third_party/WebKit/public/platform/WebString.h"
|
| -#include "third_party/WebKit/public/web/WebDevToolsAgent.h"
|
| -#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
| -
|
| -namespace html_viewer {
|
| -
|
| -DevToolsAgentImpl::DevToolsAgentImpl(blink::WebLocalFrame* frame,
|
| - const std::string& id,
|
| - const std::string* state)
|
| - : frame_(frame), id_(id), binding_(this), cache_until_client_ready_(false) {
|
| - DCHECK(frame);
|
| - frame_->setDevToolsAgentClient(this);
|
| -
|
| - if (state) {
|
| - cache_until_client_ready_ = true;
|
| - frame_->devToolsAgent()->reattach(blink::WebString::fromUTF8(id_), 0,
|
| - blink::WebString::fromUTF8(*state));
|
| - }
|
| -}
|
| -
|
| -DevToolsAgentImpl::~DevToolsAgentImpl() {
|
| - if (cache_until_client_ready_ || client_)
|
| - frame_->devToolsAgent()->detach();
|
| -}
|
| -
|
| -void DevToolsAgentImpl::BindToRequest(
|
| - mojo::InterfaceRequest<DevToolsAgent> request) {
|
| - binding_.Bind(std::move(request));
|
| -}
|
| -
|
| -void DevToolsAgentImpl::SetClient(
|
| - devtools_service::DevToolsAgentClientPtr client) {
|
| - if (client_)
|
| - frame_->devToolsAgent()->detach();
|
| -
|
| - client_ = std::move(client);
|
| - client_.set_connection_error_handler(base::Bind(
|
| - &DevToolsAgentImpl::OnConnectionError, base::Unretained(this)));
|
| -
|
| - if (cache_until_client_ready_) {
|
| - cache_until_client_ready_ = false;
|
| - for (const auto& message : cached_client_messages_)
|
| - client_->DispatchProtocolMessage(message.call_id, message.response,
|
| - message.state);
|
| - cached_client_messages_.clear();
|
| - } else {
|
| - frame_->devToolsAgent()->attach(blink::WebString::fromUTF8(id_), 0);
|
| - }
|
| -}
|
| -
|
| -void DevToolsAgentImpl::DispatchProtocolMessage(const mojo::String& message) {
|
| - frame_->devToolsAgent()->dispatchOnInspectorBackend(
|
| - 0, blink::WebString::fromUTF8(message));
|
| -}
|
| -
|
| -void DevToolsAgentImpl::sendProtocolMessage(int session_id,
|
| - int call_id,
|
| - const blink::WebString& response,
|
| - const blink::WebString& state) {
|
| - DCHECK(!response.isNull());
|
| -
|
| - mojo::String response_str = response.utf8();
|
| - mojo::String state_str;
|
| - if (!state.isNull())
|
| - state_str = state.utf8();
|
| -
|
| - if (client_) {
|
| - client_->DispatchProtocolMessage(call_id, response_str, state_str);
|
| - } else if (cache_until_client_ready_) {
|
| - cached_client_messages_.resize(cached_client_messages_.size() + 1);
|
| - CachedClientMessage& message = cached_client_messages_.back();
|
| - message.call_id = call_id;
|
| - message.response.Swap(&response_str);
|
| - message.state.Swap(&state_str);
|
| - }
|
| -}
|
| -
|
| -void DevToolsAgentImpl::OnConnectionError() {
|
| - client_.reset();
|
| - frame_->devToolsAgent()->detach();
|
| -}
|
| -
|
| -} // namespace html_viewer
|
|
|