summaryrefslogtreecommitdiffstats
path: root/net/http/http_basic_state.h
diff options
context:
space:
mode:
authorricea@chromium.org <ricea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-27 09:38:58 +0000
committerricea@chromium.org <ricea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-27 09:38:58 +0000
commitf7c2173e10439fe52d505e25794fb87307b6ea20 (patch)
treeaebc01ed01e144a6bb18552e4d3299b7c50fc831 /net/http/http_basic_state.h
parentc9bbcb43fed0e3937d30f256db673b37e1133e7c (diff)
downloadchromium_src-f7c2173e10439fe52d505e25794fb87307b6ea20.zip
chromium_src-f7c2173e10439fe52d505e25794fb87307b6ea20.tar.gz
chromium_src-f7c2173e10439fe52d505e25794fb87307b6ea20.tar.bz2
Refactor HttpBasicStream to store data in HttpBasicState
In preparation for WebSocketBasicHandshakeStream, factor out common member variables and functionality to a new HttpBasicState class. See design doc at https://docs.google.com/a/google.com/document/d/1AH2lRR2i2Wf4yODgckgdsvZeuGwpbvsvMGLnAMUXUbM/edit and the WebSocketBasicHandshakeStream implementation CL at https://codereview.chromium.org/25417005/ BUG=303568 TEST=net_unittests --gtest_filter=HttpBasicState* Review URL: https://codereview.chromium.org/44253002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231255 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_basic_state.h')
-rw-r--r--net/http/http_basic_state.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/net/http/http_basic_state.h b/net/http/http_basic_state.h
new file mode 100644
index 0000000..f9bf650
--- /dev/null
+++ b/net/http/http_basic_state.h
@@ -0,0 +1,70 @@
+// Copyright 2013 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.
+//
+// A class that stores the common state between HttpBasicStream and
+// WebSocketBasicHandshakeStream.
+
+#ifndef NET_HTTP_HTTP_BASIC_STATE_H_
+#define NET_HTTP_HTTP_BASIC_STATE_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "net/base/completion_callback.h"
+#include "net/base/net_export.h"
+#include "net/base/request_priority.h"
+
+namespace net {
+
+class BoundNetLog;
+class ClientSocketHandle;
+class GrowableIOBuffer;
+class HttpStreamParser;
+struct HttpRequestInfo;
+
+class NET_EXPORT_PRIVATE HttpBasicState {
+ public:
+ HttpBasicState(ClientSocketHandle* connection, bool using_proxy);
+ ~HttpBasicState();
+
+ // Initialize() must be called before using any of the other methods.
+ int Initialize(const HttpRequestInfo* request_info,
+ RequestPriority priority,
+ const BoundNetLog& net_log,
+ const CompletionCallback& callback);
+
+ HttpStreamParser* parser() const { return parser_.get(); }
+
+ bool using_proxy() const { return using_proxy_; }
+
+ // Deletes |parser_| and sets it to NULL.
+ void DeleteParser();
+
+ ClientSocketHandle* connection() const { return connection_.get(); }
+
+ scoped_ptr<ClientSocketHandle> ReleaseConnection();
+
+ // Generates a string of the form "METHOD PATH HTTP/1.1\r\n", based on the
+ // values of request_info_ and using_proxy_.
+ std::string GenerateRequestLine() const;
+
+ private:
+ scoped_refptr<GrowableIOBuffer> read_buf_;
+
+ scoped_ptr<HttpStreamParser> parser_;
+
+ scoped_ptr<ClientSocketHandle> connection_;
+
+ const bool using_proxy_;
+
+ const HttpRequestInfo* request_info_;
+
+ DISALLOW_COPY_AND_ASSIGN(HttpBasicState);
+};
+
+} // namespace net
+
+#endif // NET_HTTP_HTTP_BASIC_STATE_H_