Change next_proto member type.
[chromium-blink-merge.git] / content / browser / devtools / ipc_devtools_agent_host.cc
blob9218d5809bb465808fd20c1ce435664b6a2a3649
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 #include "content/common/devtools_messages.h"
9 namespace content {
11 void IPCDevToolsAgentHost::Attach() {
12 SendMessageToAgent(new DevToolsAgentMsg_Attach(MSG_ROUTING_NONE, GetId()));
13 OnClientAttached();
16 void IPCDevToolsAgentHost::Detach() {
17 SendMessageToAgent(new DevToolsAgentMsg_Detach(MSG_ROUTING_NONE));
18 OnClientDetached();
21 void IPCDevToolsAgentHost::DispatchProtocolMessage(
22 const std::string& message) {
23 SendMessageToAgent(new DevToolsAgentMsg_DispatchOnInspectorBackend(
24 MSG_ROUTING_NONE, message));
27 void IPCDevToolsAgentHost::InspectElement(int x, int y) {
28 SendMessageToAgent(new DevToolsAgentMsg_InspectElement(MSG_ROUTING_NONE,
29 GetId(), x, y));
32 IPCDevToolsAgentHost::IPCDevToolsAgentHost()
33 : message_buffer_size_(0) {
36 IPCDevToolsAgentHost::~IPCDevToolsAgentHost() {
39 void IPCDevToolsAgentHost::Reattach(const std::string& saved_agent_state) {
40 SendMessageToAgent(new DevToolsAgentMsg_Reattach(
41 MSG_ROUTING_NONE, GetId(), saved_agent_state));
42 OnClientAttached();
45 void IPCDevToolsAgentHost::ProcessChunkedMessageFromAgent(
46 const std::string& message, uint32 total_size) {
47 if (total_size && total_size == message.length()) {
48 DCHECK(message_buffer_size_ == 0);
49 SendMessageToClient(message);
50 return;
53 if (total_size) {
54 DCHECK(message_buffer_size_ == 0);
55 message_buffer_ = std::string();
56 message_buffer_.reserve(total_size);
57 message_buffer_size_ = total_size;
60 message_buffer_.append(message);
62 if (message_buffer_.size() >= message_buffer_size_) {
63 DCHECK(message_buffer_.size() == message_buffer_size_);
64 SendMessageToClient(message_buffer_);
65 message_buffer_ = std::string();
66 message_buffer_size_ = 0;
70 } // namespace content