Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: net/websockets/websocket_net_log_params.h

Issue 3390026: net: Append base:: in the StringPrintf calls. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: fix include order Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/websockets/websocket_handshake_unittest.cc ('k') | net/websockets/websocket_throttle.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_split.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "base/stringprintf.h"
16 #include "base/values.h" 17 #include "base/values.h"
17 #include "net/base/net_log.h" 18 #include "net/base/net_log.h"
18 19
19 namespace net { 20 namespace net {
20 21
21 class NetLogWebSocketHandshakeParameter : public NetLog::EventParameters { 22 class NetLogWebSocketHandshakeParameter : public NetLog::EventParameters {
22 public: 23 public:
23 explicit NetLogWebSocketHandshakeParameter(const std::string& headers) 24 explicit NetLogWebSocketHandshakeParameter(const std::string& headers)
24 : headers_(headers) { 25 : headers_(headers) {
25 } 26 }
26 27
27 Value* ToValue() const { 28 Value* ToValue() const {
28 DictionaryValue* dict = new DictionaryValue(); 29 DictionaryValue* dict = new DictionaryValue();
29 ListValue* headers = new ListValue(); 30 ListValue* headers = new ListValue();
30 std::vector<std::string> lines; 31 std::vector<std::string> lines;
31 base::SplitStringDontTrim(headers_, '\n', &lines); 32 base::SplitStringDontTrim(headers_, '\n', &lines);
32 for (size_t i = 0; i < lines.size(); ++i) { 33 for (size_t i = 0; i < lines.size(); ++i) {
33 if (lines[i] == "\r") { 34 if (lines[i] == "\r") {
34 headers->Append(new StringValue("")); 35 headers->Append(new StringValue(""));
35 // Dump WebSocket key3 36 // Dump WebSocket key3
36 std::string key; 37 std::string key;
37 i = i + 1; 38 i = i + 1;
38 for (; i < lines.size(); ++i) { 39 for (; i < lines.size(); ++i) {
39 for (size_t j = 0; j < lines[i].length(); ++j) { 40 for (size_t j = 0; j < lines[i].length(); ++j) {
40 key += StringPrintf("\\x%02x", lines[i][j] & 0xff); 41 key += base::StringPrintf("\\x%02x", lines[i][j] & 0xff);
41 } 42 }
42 key += "\\x0a"; 43 key += "\\x0a";
43 } 44 }
44 headers->Append(new StringValue(key)); 45 headers->Append(new StringValue(key));
45 break; 46 break;
46 } 47 }
47 std::string line = lines[i]; 48 std::string line = lines[i];
48 if (line.length() > 0 && line[line.length() - 1] == '\r') 49 if (line.length() > 0 && line[line.length() - 1] == '\r')
49 line = line.substr(0, line.length() - 1); 50 line = line.substr(0, line.length() - 1);
50 headers->Append(new StringValue(line)); 51 headers->Append(new StringValue(line));
51 } 52 }
52 dict->Set("headers", headers); 53 dict->Set("headers", headers);
53 return dict; 54 return dict;
54 } 55 }
55 56
56 private: 57 private:
57 ~NetLogWebSocketHandshakeParameter() {} 58 ~NetLogWebSocketHandshakeParameter() {}
58 59
59 const std::string headers_; 60 const std::string headers_;
60 61
61 DISALLOW_COPY_AND_ASSIGN(NetLogWebSocketHandshakeParameter); 62 DISALLOW_COPY_AND_ASSIGN(NetLogWebSocketHandshakeParameter);
62 }; 63 };
63 64
64 } // namespace net 65 } // namespace net
65 66
66 #endif // NET_WEBSOCKETS_WEBSOCKET_NET_LOG_PARAMS_H_ 67 #endif // NET_WEBSOCKETS_WEBSOCKET_NET_LOG_PARAMS_H_
OLDNEW
« no previous file with comments | « net/websockets/websocket_handshake_unittest.cc ('k') | net/websockets/websocket_throttle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698