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

Unified Diff: content/renderer/media/buffered_data_source.cc

Issue 306953005: Changing constructor of BufferedDataSource to accept GURL and CORSMode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removing inline Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/buffered_data_source.cc
diff --git a/content/renderer/media/buffered_data_source.cc b/content/renderer/media/buffered_data_source.cc
index d0461785f5e5b6e9b79eccee19f4e752da684b31..19e9f00383155275250e23ab68c881d5f5c77ae5 100644
--- a/content/renderer/media/buffered_data_source.cc
+++ b/content/renderer/media/buffered_data_source.cc
@@ -79,14 +79,16 @@ void BufferedDataSource::ReadOperation::Run(
}
BufferedDataSource::BufferedDataSource(
+ const GURL& url,
+ BufferedResourceLoader::CORSMode cors_mode,
const scoped_refptr<base::MessageLoopProxy>& render_loop,
WebFrame* frame,
media::MediaLog* media_log,
BufferedDataSourceHost* host,
const DownloadingCB& downloading_cb)
- : cors_mode_(BufferedResourceLoader::kUnspecified),
+ : url_(url),
+ cors_mode_(cors_mode),
total_bytes_(kPositionNotSpecified),
- assume_fully_buffered_(false),
streaming_(false),
frame_(frame),
intermediate_read_buffer_(new uint8[kInitialReadBufferSize]),
@@ -128,19 +130,14 @@ BufferedResourceLoader* BufferedDataSource::CreateResourceLoader(
media_log_.get());
}
-void BufferedDataSource::Initialize(
- const GURL& url,
- BufferedResourceLoader::CORSMode cors_mode,
- const InitializeCB& init_cb) {
+void BufferedDataSource::Initialize(const InitializeCB& init_cb) {
DCHECK(render_loop_->BelongsToCurrentThread());
DCHECK(!init_cb.is_null());
DCHECK(!loader_.get());
- url_ = url;
- cors_mode_ = cors_mode;
init_cb_ = init_cb;
- if (url_.SchemeIs(url::kHttpScheme) || url_.SchemeIs(url::kHttpsScheme)) {
+ if (url_.SchemeIsHTTPOrHTTPS()) {
// Do an unbounded range request starting at the beginning. If the server
// responds with 200 instead of 206 we'll fall back into a streaming mode.
loader_.reset(CreateResourceLoader(0, kPositionNotSpecified));
@@ -150,7 +147,6 @@ void BufferedDataSource::Initialize(
// we won't be served HTTP headers.
loader_.reset(CreateResourceLoader(kPositionNotSpecified,
kPositionNotSpecified));
- assume_fully_buffered_ = true;
}
base::WeakPtr<BufferedDataSource> weak_this = weak_factory_.GetWeakPtr();
@@ -353,12 +349,13 @@ void BufferedDataSource::StartCallback(
// All responses must be successful. Resources that are assumed to be fully
// buffered must have a known content length.
bool success = status == BufferedResourceLoader::kOk &&
- (!assume_fully_buffered_ ||
- loader_->instance_size() != kPositionNotSpecified);
+ (!assume_fully_buffered() ||
+ loader_->instance_size() != kPositionNotSpecified);
if (success) {
total_bytes_ = loader_->instance_size();
- streaming_ = !assume_fully_buffered_ &&
+ streaming_ =
+ !assume_fully_buffered() &&
(total_bytes_ == kPositionNotSpecified || !loader_->range_supported());
media_log_->SetDoubleProperty("total_bytes",
@@ -377,7 +374,7 @@ void BufferedDataSource::StartCallback(
if (success) {
if (total_bytes_ != kPositionNotSpecified) {
host_->SetTotalBytes(total_bytes_);
- if (assume_fully_buffered_)
+ if (assume_fully_buffered())
host_->AddBufferedByteRange(0, total_bytes_);
}
@@ -473,7 +470,7 @@ void BufferedDataSource::LoadingStateChangedCallback(
BufferedResourceLoader::LoadingState state) {
DCHECK(render_loop_->BelongsToCurrentThread());
- if (assume_fully_buffered_)
+ if (assume_fully_buffered())
return;
bool is_downloading_data;
@@ -501,7 +498,7 @@ void BufferedDataSource::LoadingStateChangedCallback(
void BufferedDataSource::ProgressCallback(int64 position) {
DCHECK(render_loop_->BelongsToCurrentThread());
- if (assume_fully_buffered_)
+ if (assume_fully_buffered())
return;
// TODO(scherkus): we shouldn't have to lock to signal host(), see
« no previous file with comments | « content/renderer/media/buffered_data_source.h ('k') | content/renderer/media/buffered_data_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698