Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: media/blink/multibuffer_data_source_unittest.cc

Issue 1729223003: Fix a bug where an unsigned calculation goes negative and causes very large memcpy() call. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile fix Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | media/blink/multibuffer_reader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 data_source_->OnBufferingHaveEnough(); 1208 data_source_->OnBufferingHaveEnough();
1209 ASSERT_TRUE(active_loader()); 1209 ASSERT_TRUE(active_loader());
1210 1210
1211 EXPECT_CALL(*this, ReadCallback(kDataSize)); 1211 EXPECT_CALL(*this, ReadCallback(kDataSize));
1212 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2)); 1212 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2));
1213 ReceiveData(kDataSize); 1213 ReceiveData(kDataSize);
1214 1214
1215 EXPECT_FALSE(active_loader_allownull()); 1215 EXPECT_FALSE(active_loader_allownull());
1216 } 1216 }
1217 1217
1218 TEST_F(MultibufferDataSourceTest, SeekPastEOF) {
1219 GURL gurl(kHttpUrl);
1220 data_source_.reset(new MockMultibufferDataSource(
1221 gurl, message_loop_.task_runner(), url_index_,
1222 view_->mainFrame()->toWebLocalFrame(), &host_));
1223 data_source_->SetPreload(preload_);
1224
1225 response_generator_.reset(new TestResponseGenerator(gurl, kDataSize + 1));
1226 EXPECT_CALL(*this, OnInitialize(true));
1227 data_source_->Initialize(base::Bind(&MultibufferDataSourceTest::OnInitialize,
1228 base::Unretained(this)));
1229 message_loop_.RunUntilIdle();
1230
1231 // Not really loading until after OnInitialize is called.
1232 EXPECT_EQ(data_source_->downloading(), false);
1233
1234 EXPECT_CALL(host_, SetTotalBytes(response_generator_->content_length()));
1235 Respond(response_generator_->Generate206(0));
1236 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize));
1237 ReceiveData(kDataSize);
1238
1239 // Read a bit from the beginning.
1240 EXPECT_CALL(*this, ReadCallback(kDataSize));
1241 ReadAt(0);
1242
1243 ReceiveData(1);
1244 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 3));
1245 FinishLoading();
1246 EXPECT_CALL(*this, ReadCallback(0));
1247
1248 ReadAt(kDataSize + 5, kDataSize * 2);
1249 Stop();
1250 }
1251
1218 } // namespace media 1252 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/blink/multibuffer_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698