Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / net / http / http_stream_parser.h
index e369032..afaf6c0 100644 (file)
@@ -110,17 +110,16 @@ class NET_EXPORT_PRIVATE HttpStreamParser {
   // FOO_COMPLETE states implement the second half of potentially asynchronous
   // operations and don't necessarily mean that FOO is complete.
   enum State {
+    // STATE_NONE indicates that this is waiting on an external call before
+    // continuing.
     STATE_NONE,
-    STATE_SENDING_HEADERS,
-    // If the request comes with a body, either of the following two
-    // states will be executed, depending on whether the body is chunked
-    // or not.
-    STATE_SENDING_BODY,
-    STATE_SEND_REQUEST_READING_BODY,
-    STATE_REQUEST_SENT,
+    STATE_SEND_HEADERS,
+    STATE_SEND_HEADERS_COMPLETE,
+    STATE_SEND_BODY,
+    STATE_SEND_BODY_COMPLETE,
+    STATE_SEND_REQUEST_READ_BODY_COMPLETE,
     STATE_READ_HEADERS,
     STATE_READ_HEADERS_COMPLETE,
-    STATE_BODY_PENDING,
     STATE_READ_BODY,
     STATE_READ_BODY_COMPLETE,
     STATE_DONE
@@ -146,14 +145,19 @@ class NET_EXPORT_PRIVATE HttpStreamParser {
   int DoLoop(int result);
 
   // The implementations of each state of the state machine.
-  int DoSendHeaders(int result);
-  int DoSendBody(int result);
-  int DoSendRequestReadingBody(int result);
+  int DoSendHeaders();
+  int DoSendHeadersComplete(int result);
+  int DoSendBody();
+  int DoSendBodyComplete(int result);
+  int DoSendRequestReadBodyComplete(int result);
   int DoReadHeaders();
   int DoReadHeadersComplete(int result);
   int DoReadBody();
   int DoReadBodyComplete(int result);
 
+  // This handles most of the logic for DoReadHeadersComplete.
+  int HandleReadHeaderResult(int result);
+
   // Examines |read_buf_| to find the start and end of the headers. If they are
   // found, parse them with DoParseResponseHeaders().  Return the offset for
   // the end of the headers, or -1 if the complete headers were not found, or
@@ -167,15 +171,19 @@ class NET_EXPORT_PRIVATE HttpStreamParser {
   // Examine the parsed headers to try to determine the response body size.
   void CalculateResponseBodySize();
 
-  // Current state of the request.
+  // Next state of the request, when the current one completes.
   State io_state_;
 
   // The request to send.
   const HttpRequestInfo* request_;
 
-  // The request header data.
+  // The request header data.  May include a merged request body.
   scoped_refptr<DrainableIOBuffer> request_headers_;
 
+  // Size of just the request headers.  May be less than the length of
+  // |request_headers_| if the body was merged with the headers.
+  int request_headers_length_;
+
   // Temporary buffer for reading.
   scoped_refptr<GrowableIOBuffer> read_buf_;
 
@@ -235,6 +243,9 @@ class NET_EXPORT_PRIVATE HttpStreamParser {
   scoped_refptr<SeekableIOBuffer> request_body_send_buf_;
   bool sent_last_chunk_;
 
+  // Error received when uploading the body, if any.
+  int upload_error_;
+
   base::WeakPtrFactory<HttpStreamParser> weak_ptr_factory_;
 
   DISALLOW_COPY_AND_ASSIGN(HttpStreamParser);