OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_WEBSOCKETS_WEBSOCKET_NET_LOG_PARAMS_H_ | 5 #ifndef NET_WEBSOCKETS_WEBSOCKET_NET_LOG_PARAMS_H_ |
6 #define NET_WEBSOCKETS_WEBSOCKET_NET_LOG_PARAMS_H_ | 6 #define NET_WEBSOCKETS_WEBSOCKET_NET_LOG_PARAMS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/ref_counted.h" | 13 #include "base/ref_counted.h" |
| 14 #include "base/string_split.h" |
14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
15 #include "base/values.h" | 16 #include "base/values.h" |
16 #include "net/base/net_log.h" | 17 #include "net/base/net_log.h" |
17 | 18 |
18 namespace net { | 19 namespace net { |
19 | 20 |
20 class NetLogWebSocketHandshakeParameter : public NetLog::EventParameters { | 21 class NetLogWebSocketHandshakeParameter : public NetLog::EventParameters { |
21 public: | 22 public: |
22 explicit NetLogWebSocketHandshakeParameter(const std::string& headers) | 23 explicit NetLogWebSocketHandshakeParameter(const std::string& headers) |
23 : headers_(headers) { | 24 : headers_(headers) { |
24 } | 25 } |
25 | 26 |
26 Value* ToValue() const { | 27 Value* ToValue() const { |
27 DictionaryValue* dict = new DictionaryValue(); | 28 DictionaryValue* dict = new DictionaryValue(); |
28 ListValue* headers = new ListValue(); | 29 ListValue* headers = new ListValue(); |
29 std::vector<std::string> lines; | 30 std::vector<std::string> lines; |
30 SplitStringDontTrim(headers_, '\n', &lines); | 31 base::SplitStringDontTrim(headers_, '\n', &lines); |
31 for (size_t i = 0; i < lines.size(); ++i) { | 32 for (size_t i = 0; i < lines.size(); ++i) { |
32 if (lines[i] == "\r") { | 33 if (lines[i] == "\r") { |
33 headers->Append(new StringValue("")); | 34 headers->Append(new StringValue("")); |
34 // Dump WebSocket key3 | 35 // Dump WebSocket key3 |
35 std::string key; | 36 std::string key; |
36 i = i + 1; | 37 i = i + 1; |
37 for (; i < lines.size(); ++i) { | 38 for (; i < lines.size(); ++i) { |
38 for (size_t j = 0; j < lines[i].length(); ++j) { | 39 for (size_t j = 0; j < lines[i].length(); ++j) { |
39 key += StringPrintf("\\x%02x", lines[i][j] & 0xff); | 40 key += StringPrintf("\\x%02x", lines[i][j] & 0xff); |
40 } | 41 } |
(...skipping 15 matching lines...) Expand all Loading... |
56 ~NetLogWebSocketHandshakeParameter() {} | 57 ~NetLogWebSocketHandshakeParameter() {} |
57 | 58 |
58 const std::string headers_; | 59 const std::string headers_; |
59 | 60 |
60 DISALLOW_COPY_AND_ASSIGN(NetLogWebSocketHandshakeParameter); | 61 DISALLOW_COPY_AND_ASSIGN(NetLogWebSocketHandshakeParameter); |
61 }; | 62 }; |
62 | 63 |
63 } // namespace net | 64 } // namespace net |
64 | 65 |
65 #endif // NET_WEBSOCKETS_WEBSOCKET_NET_LOG_PARAMS_H_ | 66 #endif // NET_WEBSOCKETS_WEBSOCKET_NET_LOG_PARAMS_H_ |
OLD | NEW |