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

Side by Side Diff: net/http/http_request_headers.h

Issue 10399083: Make NetLog take in callbacks that return Values (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix merge error Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_proxy_client_socket.cc ('k') | net/http/http_request_headers.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // HttpRequestHeaders manages the request headers. 5 // HttpRequestHeaders manages the request headers.
6 // It maintains these in a vector of header key/value pairs, thereby maintaining 6 // It maintains these in a vector of header key/value pairs, thereby maintaining
7 // the order of the headers. This means that any lookups are linear time 7 // the order of the headers. This means that any lookups are linear time
8 // operations. 8 // operations.
9 9
10 #ifndef NET_HTTP_HTTP_REQUEST_HEADERS_H_ 10 #ifndef NET_HTTP_HTTP_REQUEST_HEADERS_H_
11 #define NET_HTTP_HTTP_REQUEST_HEADERS_H_ 11 #define NET_HTTP_HTTP_REQUEST_HEADERS_H_
12 #pragma once 12 #pragma once
13 13
14 #include <string> 14 #include <string>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/basictypes.h" 17 #include "base/basictypes.h"
18 #include "base/string_piece.h" 18 #include "base/string_piece.h"
19 #include "net/base/net_export.h" 19 #include "net/base/net_export.h"
20 #include "net/base/net_log.h"
20 21
21 namespace net { 22 namespace net {
22 23
23 class NET_EXPORT HttpRequestHeaders { 24 class NET_EXPORT HttpRequestHeaders {
24 public: 25 public:
25 struct HeaderKeyValuePair { 26 struct HeaderKeyValuePair {
26 HeaderKeyValuePair(); 27 HeaderKeyValuePair();
27 HeaderKeyValuePair(const base::StringPiece& key, 28 HeaderKeyValuePair(const base::StringPiece& key,
28 const base::StringPiece& value); 29 const base::StringPiece& value);
29 30
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 139
139 void Swap(HttpRequestHeaders* other) { 140 void Swap(HttpRequestHeaders* other) {
140 headers_.swap(other->headers_); 141 headers_.swap(other->headers_);
141 } 142 }
142 143
143 // Serializes HttpRequestHeaders to a string representation. Joins all the 144 // Serializes HttpRequestHeaders to a string representation. Joins all the
144 // header keys and values with ": ", and inserts "\r\n" between each header 145 // header keys and values with ": ", and inserts "\r\n" between each header
145 // line, and adds the trailing "\r\n". 146 // line, and adds the trailing "\r\n".
146 std::string ToString() const; 147 std::string ToString() const;
147 148
149 // Takes in the request line and returns a Value for use with the NetLog
150 // containing both the request line and all headers fields.
151 base::Value* NetLogCallback(const std::string* request_line,
152 NetLog::LogLevel log_level) const;
153
154 // Takes in a Value created by the above function, and attempts to extract the
155 // request line and create a copy of the original headers. Returns true on
156 // success. On failure, clears |headers| and |request_line|.
157 // TODO(mmenke): Long term, we want to remove this, and migrate external
158 // consumers to be NetworkDelegates.
159 static bool FromNetLogParam(const base::Value* event_param,
160 HttpRequestHeaders* headers,
161 std::string* request_line);
162
148 private: 163 private:
149 HeaderVector::iterator FindHeader(const base::StringPiece& key); 164 HeaderVector::iterator FindHeader(const base::StringPiece& key);
150 HeaderVector::const_iterator FindHeader(const base::StringPiece& key) const; 165 HeaderVector::const_iterator FindHeader(const base::StringPiece& key) const;
151 166
152 HeaderVector headers_; 167 HeaderVector headers_;
153 168
154 // Allow the copy construction and operator= to facilitate copying in 169 // Allow the copy construction and operator= to facilitate copying in
155 // HttpRequestInfo. 170 // HttpRequestHeaders.
156 // TODO(willchan): Investigate to see if we can remove the need to copy 171 // TODO(willchan): Investigate to see if we can remove the need to copy
157 // HttpRequestInfo. 172 // HttpRequestHeaders.
158 // DISALLOW_COPY_AND_ASSIGN(HttpRequestHeaders); 173 // DISALLOW_COPY_AND_ASSIGN(HttpRequestHeaders);
159 }; 174 };
160 175
161 } // namespace net 176 } // namespace net
162 177
163 #endif // NET_HTTP_HTTP_REQUEST_HEADERS_H_ 178 #endif // NET_HTTP_HTTP_REQUEST_HEADERS_H_
OLDNEW
« no previous file with comments | « net/http/http_proxy_client_socket.cc ('k') | net/http/http_request_headers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698