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

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

Issue 1220963004: Check the response URL origin in BufferedDataSource to avoid mixing cross-origin responses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
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 "media/blink/buffered_data_source.h" 5 #include "media/blink/buffered_data_source.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 349
350 bool init_cb_is_null = false; 350 bool init_cb_is_null = false;
351 { 351 {
352 base::AutoLock auto_lock(lock_); 352 base::AutoLock auto_lock(lock_);
353 init_cb_is_null = init_cb_.is_null(); 353 init_cb_is_null = init_cb_.is_null();
354 } 354 }
355 if (init_cb_is_null) { 355 if (init_cb_is_null) {
356 loader_->Stop(); 356 loader_->Stop();
357 return; 357 return;
358 } 358 }
359 response_original_url_ = loader_->response_original_url();
359 360
360 // All responses must be successful. Resources that are assumed to be fully 361 // All responses must be successful. Resources that are assumed to be fully
361 // buffered must have a known content length. 362 // buffered must have a known content length.
362 bool success = status == BufferedResourceLoader::kOk && 363 bool success = status == BufferedResourceLoader::kOk &&
363 (!assume_fully_buffered() || 364 (!assume_fully_buffered() ||
364 loader_->instance_size() != kPositionNotSpecified); 365 loader_->instance_size() != kPositionNotSpecified);
365 366
366 if (success) { 367 if (success) {
367 total_bytes_ = loader_->instance_size(); 368 total_bytes_ = loader_->instance_size();
368 streaming_ = 369 streaming_ =
(...skipping 27 matching lines...) Expand all
396 loader_->range_supported()); 397 loader_->range_supported());
397 } 398 }
398 399
399 base::ResetAndReturn(&init_cb_).Run(success); 400 base::ResetAndReturn(&init_cb_).Run(success);
400 } 401 }
401 402
402 void BufferedDataSource::PartialReadStartCallback( 403 void BufferedDataSource::PartialReadStartCallback(
403 BufferedResourceLoader::Status status) { 404 BufferedResourceLoader::Status status) {
404 DCHECK(render_task_runner_->BelongsToCurrentThread()); 405 DCHECK(render_task_runner_->BelongsToCurrentThread());
405 DCHECK(loader_.get()); 406 DCHECK(loader_.get());
406 407 if (status == BufferedResourceLoader::kOk &&
407 if (status == BufferedResourceLoader::kOk) { 408 response_original_url_ == loader_->response_original_url()) {
408 // Once the request has started successfully, we can proceed with 409 // Once the request has started successfully, we can proceed with
409 // reading from it. 410 // reading from it.
410 ReadInternal(); 411 ReadInternal();
411 return; 412 return;
412 } 413 }
413 414
414 // Stop the resource loader since we have received an error. 415 // Stop the resource loader since we have received an error.
415 loader_->Stop(); 416 loader_->Stop();
416 417
417 // TODO(scherkus): we shouldn't have to lock to signal host(), see 418 // TODO(scherkus): we shouldn't have to lock to signal host(), see
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 } 552 }
552 553
553 // If media is currently playing or the page indicated preload=auto or the 554 // If media is currently playing or the page indicated preload=auto or the
554 // the server does not support the byte range request or we do not want to go 555 // the server does not support the byte range request or we do not want to go
555 // too far ahead of the read head, use threshold strategy to enable/disable 556 // too far ahead of the read head, use threshold strategy to enable/disable
556 // deferring when the buffer is full/depleted. 557 // deferring when the buffer is full/depleted.
557 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); 558 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer);
558 } 559 }
559 560
560 } // namespace media 561 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698