| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 | 195 |
| 196 // A valid partial response should always result in this being true. | 196 // A valid partial response should always result in this being true. |
| 197 EXPECT_TRUE(loader_->range_supported()); | 197 EXPECT_TRUE(loader_->range_supported()); |
| 198 } | 198 } |
| 199 | 199 |
| 200 void Redirect(const char* url) { | 200 void Redirect(const char* url) { |
| 201 GURL redirectUrl(url); | 201 GURL redirectUrl(url); |
| 202 blink::WebURLRequest newRequest(redirectUrl); | 202 blink::WebURLRequest newRequest(redirectUrl); |
| 203 blink::WebURLResponse redirectResponse(gurl_); | 203 blink::WebURLResponse redirectResponse(gurl_); |
| 204 | 204 |
| 205 loader_->willFollowRedirect(url_loader_, newRequest, redirectResponse); | 205 loader_->willFollowRedirect(url_loader_, newRequest, redirectResponse, 0); |
| 206 | 206 |
| 207 base::RunLoop().RunUntilIdle(); | 207 base::RunLoop().RunUntilIdle(); |
| 208 } | 208 } |
| 209 | 209 |
| 210 void StopWhenLoad() { | 210 void StopWhenLoad() { |
| 211 InSequence s; | 211 InSequence s; |
| 212 EXPECT_CALL(*url_loader_, cancel()); | 212 EXPECT_CALL(*url_loader_, cancel()); |
| 213 loader_->Stop(); | 213 loader_->Stop(); |
| 214 loader_.reset(); | 214 loader_.reset(); |
| 215 } | 215 } |
| 216 | 216 |
| 217 // Helper method to write to |loader_| from |data_|. | 217 // Helper method to write to |loader_| from |data_|. |
| 218 void WriteLoader(int position, int size) { | 218 void WriteLoader(int position, int size) { |
| 219 EXPECT_CALL(*this, ProgressCallback(position + size - 1)); | 219 EXPECT_CALL(*this, ProgressCallback(position + size - 1)); |
| 220 loader_->didReceiveData(url_loader_, | 220 loader_->didReceiveData(url_loader_, |
| 221 reinterpret_cast<char*>(data_ + position), | 221 reinterpret_cast<char*>(data_ + position), size, |
| 222 size, | 222 size, size); |
| 223 size); | |
| 224 } | 223 } |
| 225 | 224 |
| 226 void WriteData(int size) { | 225 void WriteData(int size) { |
| 227 EXPECT_CALL(*this, ProgressCallback(_)); | 226 EXPECT_CALL(*this, ProgressCallback(_)); |
| 228 | 227 |
| 229 std::unique_ptr<char[]> data(new char[size]); | 228 std::unique_ptr<char[]> data(new char[size]); |
| 230 loader_->didReceiveData(url_loader_, data.get(), size, size); | 229 loader_->didReceiveData(url_loader_, data.get(), size, size, size); |
| 231 } | 230 } |
| 232 | 231 |
| 233 void WriteUntilThreshold() { | 232 void WriteUntilThreshold() { |
| 234 int buffered = loader_->buffer_.forward_bytes(); | 233 int buffered = loader_->buffer_.forward_bytes(); |
| 235 int capacity = loader_->buffer_.forward_capacity(); | 234 int capacity = loader_->buffer_.forward_capacity(); |
| 236 CHECK_LT(buffered, capacity); | 235 CHECK_LT(buffered, capacity); |
| 237 | 236 |
| 238 EXPECT_CALL(*this, LoadingCallback( | 237 EXPECT_CALL(*this, LoadingCallback( |
| 239 BufferedResourceLoader::kLoadingDeferred)); | 238 BufferedResourceLoader::kLoadingDeferred)); |
| 240 WriteData(capacity - buffered); | 239 WriteData(capacity - buffered); |
| (...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1164 | 1163 |
| 1165 // As soon as we have received enough data to fulfill the read, defer. | 1164 // As soon as we have received enough data to fulfill the read, defer. |
| 1166 EXPECT_CALL(*this, LoadingCallback(BufferedResourceLoader::kLoadingDeferred)); | 1165 EXPECT_CALL(*this, LoadingCallback(BufferedResourceLoader::kLoadingDeferred)); |
| 1167 EXPECT_CALL(*this, ReadCallback(BufferedResourceLoader::kOk, 10)); | 1166 EXPECT_CALL(*this, ReadCallback(BufferedResourceLoader::kOk, 10)); |
| 1168 WriteLoader(19, 1); | 1167 WriteLoader(19, 1); |
| 1169 VerifyBuffer(buffer, 10, 10); | 1168 VerifyBuffer(buffer, 10, 10); |
| 1170 EXPECT_FALSE(HasActiveLoader()); | 1169 EXPECT_FALSE(HasActiveLoader()); |
| 1171 } | 1170 } |
| 1172 | 1171 |
| 1173 } // namespace media | 1172 } // namespace media |
| OLD | NEW |