Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / content / browser / devtools / ipc_devtools_agent_host.cc
blobdc3eebe8b1d629a94ab01de9bab08abc0123c23a
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/browser/devtools/ipc_devtools_agent_host.h"
7 namespace content {
9 void IPCDevToolsAgentHost::Attach() {
10 SendMessageToAgent(new DevToolsAgentMsg_Attach(MSG_ROUTING_NONE, GetId()));
11 OnClientAttached(false);
14 void IPCDevToolsAgentHost::Detach() {
15 SendMessageToAgent(new DevToolsAgentMsg_Detach(MSG_ROUTING_NONE));
16 OnClientDetached();
19 bool IPCDevToolsAgentHost::DispatchProtocolMessage(
20 const std::string& message) {
21 if (DevToolsAgentHostImpl::DispatchProtocolMessage(message))
22 return true;
24 SendMessageToAgent(new DevToolsAgentMsg_DispatchOnInspectorBackend(
25 MSG_ROUTING_NONE, message));
26 return true;
29 void IPCDevToolsAgentHost::InspectElement(int x, int y) {
30 SendMessageToAgent(new DevToolsAgentMsg_InspectElement(MSG_ROUTING_NONE,
31 GetId(), x, y));
34 IPCDevToolsAgentHost::IPCDevToolsAgentHost()
35 : message_buffer_size_(0) {
38 IPCDevToolsAgentHost::~IPCDevToolsAgentHost() {
41 void IPCDevToolsAgentHost::Reattach() {
42 SendMessageToAgent(new DevToolsAgentMsg_Reattach(
43 MSG_ROUTING_NONE, GetId(), state_cookie_));
44 OnClientAttached(true);
47 void IPCDevToolsAgentHost::ProcessChunkedMessageFromAgent(
48 const DevToolsMessageChunk& chunk) {
49 if (chunk.is_last && !chunk.post_state.empty())
50 state_cookie_ = chunk.post_state;
52 if (chunk.is_first && chunk.is_last) {
53 CHECK(message_buffer_size_ == 0);
54 SendMessageToClient(chunk.data);
55 return;
58 if (chunk.is_first) {
59 message_buffer_ = std::string();
60 message_buffer_.reserve(chunk.message_size);
61 message_buffer_size_ = chunk.message_size;
64 CHECK(message_buffer_.size() + chunk.data.size() <=
65 message_buffer_size_);
66 message_buffer_.append(chunk.data);
68 if (chunk.is_last) {
69 CHECK(message_buffer_.size() == message_buffer_size_);
70 SendMessageToClient(message_buffer_);
71 message_buffer_ = std::string();
72 message_buffer_size_ = 0;
76 } // namespace content