blob: eb6300959c26d2385acfb426432ac9959c7c26a8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// Copyright (c) 2010 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 "chrome/browser/debugger/devtools_remote_message.h"
#include "base/string_number_conversions.h"
const char DevToolsRemoteMessageHeaders::kContentLength[] = "Content-Length";
const char DevToolsRemoteMessageHeaders::kTool[] = "Tool";
const char DevToolsRemoteMessageHeaders::kDestination[] = "Destination";
const char DevToolsRemoteMessage::kEmptyValue[] = "";
DevToolsRemoteMessageBuilder& DevToolsRemoteMessageBuilder::instance() {
static DevToolsRemoteMessageBuilder instance_;
return instance_;
}
const std::string DevToolsRemoteMessage::GetHeader(
const std::string& header_name,
const std::string& default_value) const {
HeaderMap::const_iterator it = header_map_.find(header_name);
if (it == header_map_.end()) {
return default_value;
}
return it->second;
}
const std::string DevToolsRemoteMessage::GetHeaderWithEmptyDefault(
const std::string& header_name) const {
return GetHeader(header_name, DevToolsRemoteMessage::kEmptyValue);
}
const std::string DevToolsRemoteMessage::ToString() const {
std::string result;
for (HeaderMap::const_iterator it = header_map_.begin(),
end = header_map_.end(); it != end; ++it) {
result.append(it->first).append(":").append(it->second).append("\r\n");
}
result.append("\r\n").append(content_);
return result;
}
DevToolsRemoteMessage* DevToolsRemoteMessageBuilder::Create(
const std::string& tool,
const std::string& destination,
const std::string& content) {
DevToolsRemoteMessage::HeaderMap headers;
headers[DevToolsRemoteMessageHeaders::kContentLength] =
base::IntToString(content.size());
headers[DevToolsRemoteMessageHeaders::kTool] = tool;
headers[DevToolsRemoteMessageHeaders::kDestination] = destination;
return new DevToolsRemoteMessage(headers, content);
}
|