OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 // A delegate class of WebURLLoaderImpl that handles multipart/x-mixed-replace | 5 // A delegate class of WebURLLoaderImpl that handles multipart/x-mixed-replace |
6 // data. We special case multipart/x-mixed-replace because WebCore expects a | 6 // data. We special case multipart/x-mixed-replace because WebCore expects a |
7 // separate didReceiveResponse for each new message part. | 7 // separate didReceiveResponse for each new message part. |
8 // | 8 // |
9 // Most of the logic and edge case handling are based on the Mozilla's | 9 // Most of the logic and edge case handling are based on the Mozilla's |
10 // implementation in netwerk/streamconv/converters/nsMultiMixedConv.cpp. | 10 // implementation in netwerk/streamconv/converters/nsMultiMixedConv.cpp. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 class MultipartResponseDelegateTester; | 65 class MultipartResponseDelegateTester; |
66 | 66 |
67 class MultipartResponseDelegate { | 67 class MultipartResponseDelegate { |
68 public: | 68 public: |
69 MultipartResponseDelegate(WebKit::WebURLLoaderClient* client, | 69 MultipartResponseDelegate(WebKit::WebURLLoaderClient* client, |
70 WebKit::WebURLLoader* loader, | 70 WebKit::WebURLLoader* loader, |
71 const WebKit::WebURLResponse& response, | 71 const WebKit::WebURLResponse& response, |
72 const std::string& boundary); | 72 const std::string& boundary); |
73 | 73 |
74 // Passed through from ResourceHandleInternal | 74 // Passed through from ResourceHandleInternal |
75 void OnReceivedData(const char* data, int data_len); | 75 void OnReceivedData(const char* data, int data_len, int raw_data_length); |
76 void OnCompletedRequest(); | 76 void OnCompletedRequest(); |
77 | 77 |
78 // The request has been canceled, so stop making calls to the client. | 78 // The request has been canceled, so stop making calls to the client. |
79 void Cancel() { | 79 void Cancel() { |
80 client_ = NULL; | 80 client_ = NULL; |
81 loader_ = NULL; | 81 loader_ = NULL; |
82 } | 82 } |
83 | 83 |
84 // Returns the multi part boundary string from the Content-type header | 84 // Returns the multi part boundary string from the Content-type header |
85 // in the response. | 85 // in the response. |
(...skipping 27 matching lines...) Expand all Loading... |
113 | 113 |
114 // Tries to parse http headers from the start of data_. Returns true if it | 114 // Tries to parse http headers from the start of data_. Returns true if it |
115 // succeeds and sends a didReceiveResponse to m_client. Returns false if | 115 // succeeds and sends a didReceiveResponse to m_client. Returns false if |
116 // the header is incomplete (in which case we just wait for more data). | 116 // the header is incomplete (in which case we just wait for more data). |
117 bool ParseHeaders(); | 117 bool ParseHeaders(); |
118 | 118 |
119 // Find the next boundary in data_. Returns std::string::npos if there's no | 119 // Find the next boundary in data_. Returns std::string::npos if there's no |
120 // full token. | 120 // full token. |
121 size_t FindBoundary(); | 121 size_t FindBoundary(); |
122 | 122 |
| 123 // Transferred data size accumulated between client callbacks. |
| 124 int raw_data_length_; |
| 125 |
123 // A temporary buffer to hold data between reads for multipart data that | 126 // A temporary buffer to hold data between reads for multipart data that |
124 // gets split in the middle of a header. | 127 // gets split in the middle of a header. |
125 std::string data_; | 128 std::string data_; |
126 | 129 |
127 // Multipart boundary token | 130 // Multipart boundary token |
128 std::string boundary_; | 131 std::string boundary_; |
129 | 132 |
130 // true until we get our first on received data call | 133 // true until we get our first on received data call |
131 bool first_received_data_; | 134 bool first_received_data_; |
132 | 135 |
133 // true if we're truncated in the middle of a header | 136 // true if we're truncated in the middle of a header |
134 bool processing_headers_; | 137 bool processing_headers_; |
135 | 138 |
136 // true when we're done sending information. At that point, we stop | 139 // true when we're done sending information. At that point, we stop |
137 // processing AddData requests. | 140 // processing AddData requests. |
138 bool stop_sending_; | 141 bool stop_sending_; |
139 | 142 |
140 // true after we've sent our first response to the WebURLLoaderClient. | 143 // true after we've sent our first response to the WebURLLoaderClient. |
141 bool has_sent_first_response_; | 144 bool has_sent_first_response_; |
142 | 145 |
143 DISALLOW_COPY_AND_ASSIGN(MultipartResponseDelegate); | 146 DISALLOW_COPY_AND_ASSIGN(MultipartResponseDelegate); |
144 }; | 147 }; |
145 | 148 |
146 } // namespace webkit_glue | 149 } // namespace webkit_glue |
147 | 150 |
148 #endif | 151 #endif |
OLD | NEW |