Chromium Code Reviews| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1196 InitializeWith206Response(); | 1196 InitializeWith206Response(); |
| 1197 | 1197 |
| 1198 EXPECT_EQ(MultibufferDataSource::METADATA, preload()); | 1198 EXPECT_EQ(MultibufferDataSource::METADATA, preload()); |
| 1199 EXPECT_FALSE(is_local_source()); | 1199 EXPECT_FALSE(is_local_source()); |
| 1200 | 1200 |
| 1201 EXPECT_TRUE(data_source_->range_supported()); | 1201 EXPECT_TRUE(data_source_->range_supported()); |
| 1202 CheckReadThenDefer(); | 1202 CheckReadThenDefer(); |
| 1203 | 1203 |
| 1204 ReadAt(kDataSize); | 1204 ReadAt(kDataSize); |
| 1205 | 1205 |
| 1206 data_source_->OnBufferingHaveEnough(); | 1206 data_source_->OnBufferingHaveEnough(false); |
| 1207 ASSERT_TRUE(active_loader()); | 1207 ASSERT_TRUE(active_loader()); |
| 1208 | 1208 |
| 1209 EXPECT_CALL(*this, ReadCallback(kDataSize)); | 1209 EXPECT_CALL(*this, ReadCallback(kDataSize)); |
| 1210 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2)); | 1210 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2)); |
| 1211 ReceiveData(kDataSize); | 1211 ReceiveData(kDataSize); |
| 1212 | 1212 |
| 1213 EXPECT_FALSE(active_loader_allownull()); | 1213 EXPECT_FALSE(active_loader_allownull()); |
| 1214 } | 1214 } |
| 1215 | 1215 |
| 1216 TEST_F(MultibufferDataSourceTest, | |
| 1217 ExternalResource_Response206_CancelAfterPlay) { | |
| 1218 set_preload(BufferedDataSource::METADATA); | |
| 1219 InitializeWith206Response(); | |
| 1220 | |
| 1221 EXPECT_EQ(MultibufferDataSource::METADATA, preload()); | |
| 1222 EXPECT_FALSE(is_local_source()); | |
| 1223 | |
| 1224 EXPECT_TRUE(data_source_->range_supported()); | |
| 1225 CheckReadThenDefer(); | |
| 1226 | |
| 1227 ReadAt(kDataSize); | |
| 1228 | |
| 1229 // Marking the media as playing should prevent deferral. It also tells the | |
| 1230 // data source to start buffering beyond the initial load. | |
| 1231 data_source_->MediaIsPlaying(); | |
| 1232 data_source_->OnBufferingHaveEnough(false); | |
| 1233 CheckCapacityDefer(); | |
| 1234 ASSERT_TRUE(active_loader()); | |
| 1235 | |
| 1236 // Read a bit from the beginning and ensure deferral hasn't happened yet. | |
| 1237 EXPECT_CALL(*this, ReadCallback(kDataSize)); | |
| 1238 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2)); | |
| 1239 ReceiveData(kDataSize); | |
| 1240 ASSERT_TRUE(active_loader()); | |
| 1241 data_source_->OnBufferingHaveEnough(true); | |
| 1242 ASSERT_TRUE(active_loader()); | |
| 1243 ASSERT_FALSE(active_loader()->deferred()); | |
| 1244 | |
| 1245 // Deliver data until capacity is reached and verify deferral. | |
| 1246 int bytes_received = 0; | |
| 1247 EXPECT_CALL(host_, AddBufferedByteRange(_, _)).Times(testing::AtLeast(1)); | |
| 1248 while (active_loader() && !active_loader()->deferred()) { | |
|
hubbe
2016/03/14 23:16:05
You probably want active_loader_allownull() here.
DaleCurtis
2016/03/14 23:24:38
Thanks! That was the issue. True, unfortunately CH
| |
| 1249 ReceiveData(kDataSize); | |
| 1250 bytes_received += kDataSize; | |
| 1251 } | |
| 1252 EXPECT_GT(bytes_received, 0); | |
| 1253 EXPECT_LT(bytes_received + kDataSize, kFileSize); | |
| 1254 EXPECT_FALSE(active_loader_allownull()); | |
| 1255 } | |
| 1256 | |
| 1216 TEST_F(MultibufferDataSourceTest, SeekPastEOF) { | 1257 TEST_F(MultibufferDataSourceTest, SeekPastEOF) { |
| 1217 GURL gurl(kHttpUrl); | 1258 GURL gurl(kHttpUrl); |
| 1218 data_source_.reset(new MockMultibufferDataSource( | 1259 data_source_.reset(new MockMultibufferDataSource( |
| 1219 gurl, message_loop_.task_runner(), url_index_, | 1260 gurl, message_loop_.task_runner(), url_index_, |
| 1220 view_->mainFrame()->toWebLocalFrame(), &host_)); | 1261 view_->mainFrame()->toWebLocalFrame(), &host_)); |
| 1221 data_source_->SetPreload(preload_); | 1262 data_source_->SetPreload(preload_); |
| 1222 | 1263 |
| 1223 response_generator_.reset(new TestResponseGenerator(gurl, kDataSize + 1)); | 1264 response_generator_.reset(new TestResponseGenerator(gurl, kDataSize + 1)); |
| 1224 EXPECT_CALL(*this, OnInitialize(true)); | 1265 EXPECT_CALL(*this, OnInitialize(true)); |
| 1225 data_source_->Initialize(base::Bind(&MultibufferDataSourceTest::OnInitialize, | 1266 data_source_->Initialize(base::Bind(&MultibufferDataSourceTest::OnInitialize, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1270 data_provider()->willFollowRedirect(url_loader(), request, response); | 1311 data_provider()->willFollowRedirect(url_loader(), request, response); |
| 1271 Respond(response_generator_->Generate206(kDataSize)); | 1312 Respond(response_generator_->Generate206(kDataSize)); |
| 1272 ReceiveData(kDataSize); | 1313 ReceiveData(kDataSize); |
| 1273 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 3)); | 1314 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 3)); |
| 1274 FinishLoading(); | 1315 FinishLoading(); |
| 1275 EXPECT_FALSE(loading()); | 1316 EXPECT_FALSE(loading()); |
| 1276 Stop(); | 1317 Stop(); |
| 1277 } | 1318 } |
| 1278 | 1319 |
| 1279 } // namespace media | 1320 } // namespace media |
| OLD | NEW |