| OLD | NEW |
| 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 // 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 #include "base/basictypes.h" | 54 #include "base/basictypes.h" |
| 55 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 55 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 56 #include "webkit/child/webkit_child_export.h" | 56 #include "webkit/child/webkit_child_export.h" |
| 57 | 57 |
| 58 namespace blink { | 58 namespace blink { |
| 59 class WebURLLoader; | 59 class WebURLLoader; |
| 60 class WebURLLoaderClient; | 60 class WebURLLoaderClient; |
| 61 } | 61 } |
| 62 | 62 |
| 63 namespace content { |
| 64 // Used by unit tests to access private members. |
| 65 class MultipartResponseDelegateTester; |
| 66 } |
| 67 |
| 63 namespace webkit_glue { | 68 namespace webkit_glue { |
| 64 | 69 |
| 65 // Used by unit tests to access private members. | |
| 66 class MultipartResponseDelegateTester; | |
| 67 | |
| 68 class WEBKIT_CHILD_EXPORT MultipartResponseDelegate { | 70 class WEBKIT_CHILD_EXPORT MultipartResponseDelegate { |
| 69 public: | 71 public: |
| 70 MultipartResponseDelegate(blink::WebURLLoaderClient* client, | 72 MultipartResponseDelegate(blink::WebURLLoaderClient* client, |
| 71 blink::WebURLLoader* loader, | 73 blink::WebURLLoader* loader, |
| 72 const blink::WebURLResponse& response, | 74 const blink::WebURLResponse& response, |
| 73 const std::string& boundary); | 75 const std::string& boundary); |
| 74 | 76 |
| 75 // Passed through from ResourceHandleInternal | 77 // Passed through from ResourceHandleInternal |
| 76 void OnReceivedData(const char* data, int data_len, int encoded_data_length); | 78 void OnReceivedData(const char* data, int data_len, int encoded_data_length); |
| 77 void OnCompletedRequest(); | 79 void OnCompletedRequest(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 91 // Returns the lower and higher content ranges from an individual multipart | 93 // Returns the lower and higher content ranges from an individual multipart |
| 92 // in a multipart response. | 94 // in a multipart response. |
| 93 // Returns true on success. | 95 // Returns true on success. |
| 94 static bool ReadContentRanges( | 96 static bool ReadContentRanges( |
| 95 const blink::WebURLResponse& response, | 97 const blink::WebURLResponse& response, |
| 96 int64* content_range_lower_bound, | 98 int64* content_range_lower_bound, |
| 97 int64* content_range_upper_bound, | 99 int64* content_range_upper_bound, |
| 98 int64* content_range_instance_size); | 100 int64* content_range_instance_size); |
| 99 | 101 |
| 100 private: | 102 private: |
| 101 friend class MultipartResponseDelegateTester; // For unittests. | 103 friend class content::MultipartResponseDelegateTester; // For unittests. |
| 102 | 104 |
| 103 // Pointers to the client and associated loader so we can make callbacks as | 105 // Pointers to the client and associated loader so we can make callbacks as |
| 104 // we parse pieces of data. | 106 // we parse pieces of data. |
| 105 blink::WebURLLoaderClient* client_; | 107 blink::WebURLLoaderClient* client_; |
| 106 blink::WebURLLoader* loader_; | 108 blink::WebURLLoader* loader_; |
| 107 | 109 |
| 108 // The original resource response for this request. We use this as a | 110 // The original resource response for this request. We use this as a |
| 109 // starting point for each parts response. | 111 // starting point for each parts response. |
| 110 blink::WebURLResponse original_response_; | 112 blink::WebURLResponse original_response_; |
| 111 | 113 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 146 |
| 145 // true after we've sent our first response to the WebURLLoaderClient. | 147 // true after we've sent our first response to the WebURLLoaderClient. |
| 146 bool has_sent_first_response_; | 148 bool has_sent_first_response_; |
| 147 | 149 |
| 148 DISALLOW_COPY_AND_ASSIGN(MultipartResponseDelegate); | 150 DISALLOW_COPY_AND_ASSIGN(MultipartResponseDelegate); |
| 149 }; | 151 }; |
| 150 | 152 |
| 151 } // namespace webkit_glue | 153 } // namespace webkit_glue |
| 152 | 154 |
| 153 #endif // WEBKIT_CHILD_MULTIPART_RESPONSE_DELEGATE_H_ | 155 #endif // WEBKIT_CHILD_MULTIPART_RESPONSE_DELEGATE_H_ |
| OLD | NEW |