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

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: Update comments 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
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"
21
22 namespace base {
23 class Value;
eroman 2012/06/06 21:27:11 nit: de-indent. Isn't value already declared in ne
mmenke 2012/06/07 19:20:46 Yea, it is. Removed.
24 }
20 25
21 namespace net { 26 namespace net {
22 27
23 class NET_EXPORT HttpRequestHeaders { 28 class NET_EXPORT HttpRequestHeaders {
24 public: 29 public:
25 struct HeaderKeyValuePair { 30 struct HeaderKeyValuePair {
26 HeaderKeyValuePair(); 31 HeaderKeyValuePair();
27 HeaderKeyValuePair(const base::StringPiece& key, 32 HeaderKeyValuePair(const base::StringPiece& key,
28 const base::StringPiece& value); 33 const base::StringPiece& value);
29 34
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 143
139 void Swap(HttpRequestHeaders* other) { 144 void Swap(HttpRequestHeaders* other) {
140 headers_.swap(other->headers_); 145 headers_.swap(other->headers_);
141 } 146 }
142 147
143 // Serializes HttpRequestHeaders to a string representation. Joins all the 148 // Serializes HttpRequestHeaders to a string representation. Joins all the
144 // header keys and values with ": ", and inserts "\r\n" between each header 149 // header keys and values with ": ", and inserts "\r\n" between each header
145 // line, and adds the trailing "\r\n". 150 // line, and adds the trailing "\r\n".
146 std::string ToString() const; 151 std::string ToString() const;
147 152
153 // Takes in the request line and returns a Value for use with the NetLog
154 // containing both the request line and all headers fields.
155 base::Value* NetLogCallback(const std::string* request_line,
156 NetLog::LogLevel log_level) const;
157
158 // Takes in a Value created by the above function, and attempts to extract the
159 // request line and create a copy of the original headers. Returns true on
160 // success. On failure, clears |headers| and |request_line|.
161 // TODO(mmenke): Long term, we want to remove this, and migrate external
162 // consumers to be NetworkDelegates.
163 static bool FromNetLogParam(const base::Value* event_param,
164 HttpRequestHeaders* headers,
165 std::string* request_line);
166
148 private: 167 private:
149 HeaderVector::iterator FindHeader(const base::StringPiece& key); 168 HeaderVector::iterator FindHeader(const base::StringPiece& key);
150 HeaderVector::const_iterator FindHeader(const base::StringPiece& key) const; 169 HeaderVector::const_iterator FindHeader(const base::StringPiece& key) const;
151 170
152 HeaderVector headers_; 171 HeaderVector headers_;
153 172
154 // Allow the copy construction and operator= to facilitate copying in 173 // Allow the copy construction and operator= to facilitate copying in
155 // HttpRequestInfo. 174 // HttpRequestHeaders.
156 // TODO(willchan): Investigate to see if we can remove the need to copy 175 // TODO(willchan): Investigate to see if we can remove the need to copy
157 // HttpRequestInfo. 176 // HttpRequestHeaders.
158 // DISALLOW_COPY_AND_ASSIGN(HttpRequestHeaders); 177 // DISALLOW_COPY_AND_ASSIGN(HttpRequestHeaders);
159 }; 178 };
160 179
161 } // namespace net 180 } // namespace net
162 181
163 #endif // NET_HTTP_HTTP_REQUEST_HEADERS_H_ 182 #endif // NET_HTTP_HTTP_REQUEST_HEADERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698