| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include <memory> |
| 11 | 12 |
| 12 #if defined(WEBRTC_WIN) | 13 #if defined(WEBRTC_WIN) |
| 13 #include "webrtc/base/win32.h" | 14 #include "webrtc/base/win32.h" |
| 14 #else // !WEBRTC_WIN | 15 #else // !WEBRTC_WIN |
| 15 #define SEC_E_CERT_EXPIRED (-2146893016) | 16 #define SEC_E_CERT_EXPIRED (-2146893016) |
| 16 #endif // !WEBRTC_WIN | 17 #endif // !WEBRTC_WIN |
| 17 | 18 |
| 18 #include "webrtc/base/common.h" | 19 #include "webrtc/base/common.h" |
| 19 #include "webrtc/base/httpbase.h" | 20 #include "webrtc/base/httpbase.h" |
| 20 #include "webrtc/base/logging.h" | 21 #include "webrtc/base/logging.h" |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 return SR_BLOCK; | 265 return SR_BLOCK; |
| 265 } | 266 } |
| 266 | 267 |
| 267 // DoReceiveLoop writes http document data to the StreamInterface* document | 268 // DoReceiveLoop writes http document data to the StreamInterface* document |
| 268 // member of HttpData. In this case, we want this data to be written | 269 // member of HttpData. In this case, we want this data to be written |
| 269 // directly to our buffer. To accomplish this, we wrap our buffer with a | 270 // directly to our buffer. To accomplish this, we wrap our buffer with a |
| 270 // StreamInterface, and replace the existing document with our wrapper. | 271 // StreamInterface, and replace the existing document with our wrapper. |
| 271 // When the method returns, we restore the old document. Ideally, we would | 272 // When the method returns, we restore the old document. Ideally, we would |
| 272 // pass our StreamInterface* to DoReceiveLoop, but due to the callbacks | 273 // pass our StreamInterface* to DoReceiveLoop, but due to the callbacks |
| 273 // of HttpParser, we would still need to store the pointer temporarily. | 274 // of HttpParser, we would still need to store the pointer temporarily. |
| 274 scoped_ptr<StreamInterface> | 275 std::unique_ptr<StreamInterface> stream( |
| 275 stream(new BlockingMemoryStream(reinterpret_cast<char*>(buffer), | 276 new BlockingMemoryStream(reinterpret_cast<char*>(buffer), buffer_len)); |
| 276 buffer_len)); | |
| 277 | 277 |
| 278 // Replace the existing document with our wrapped buffer. | 278 // Replace the existing document with our wrapped buffer. |
| 279 base_->data_->document.swap(stream); | 279 base_->data_->document.swap(stream); |
| 280 | 280 |
| 281 // Pump the I/O loop. DoReceiveLoop is guaranteed not to attempt to | 281 // Pump the I/O loop. DoReceiveLoop is guaranteed not to attempt to |
| 282 // complete the I/O process, which means that our wrapper is not in danger | 282 // complete the I/O process, which means that our wrapper is not in danger |
| 283 // of being deleted. To ensure this, DoReceiveLoop returns true when it | 283 // of being deleted. To ensure this, DoReceiveLoop returns true when it |
| 284 // wants complete to be called. We make sure to uninstall our wrapper | 284 // wants complete to be called. We make sure to uninstall our wrapper |
| 285 // before calling complete(). | 285 // before calling complete(). |
| 286 HttpError http_error; | 286 HttpError http_error; |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 } | 873 } |
| 874 } | 874 } |
| 875 | 875 |
| 876 void | 876 void |
| 877 HttpBase::OnComplete(HttpError err) { | 877 HttpBase::OnComplete(HttpError err) { |
| 878 LOG_F(LS_VERBOSE); | 878 LOG_F(LS_VERBOSE); |
| 879 do_complete(err); | 879 do_complete(err); |
| 880 } | 880 } |
| 881 | 881 |
| 882 } // namespace rtc | 882 } // namespace rtc |
| OLD | NEW |