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

Side by Side 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: Created 6 years, 6 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 "content/renderer/media/buffered_data_source.h" 5 #include "content/renderer/media/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/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "content/public/common/url_constants.h" 10 #include "content/public/common/url_constants.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 DCHECK(callback_.is_null()); 72 DCHECK(callback_.is_null());
73 } 73 }
74 74
75 // static 75 // static
76 void BufferedDataSource::ReadOperation::Run( 76 void BufferedDataSource::ReadOperation::Run(
77 scoped_ptr<ReadOperation> read_op, int result) { 77 scoped_ptr<ReadOperation> read_op, int result) {
78 base::ResetAndReturn(&read_op->callback_).Run(result); 78 base::ResetAndReturn(&read_op->callback_).Run(result);
79 } 79 }
80 80
81 BufferedDataSource::BufferedDataSource( 81 BufferedDataSource::BufferedDataSource(
82 const GURL& url,
83 BufferedResourceLoader::CORSMode cors_mode,
82 const scoped_refptr<base::MessageLoopProxy>& render_loop, 84 const scoped_refptr<base::MessageLoopProxy>& render_loop,
83 WebFrame* frame, 85 WebFrame* frame,
84 media::MediaLog* media_log, 86 media::MediaLog* media_log,
85 BufferedDataSourceHost* host, 87 BufferedDataSourceHost* host,
86 const DownloadingCB& downloading_cb) 88 const DownloadingCB& downloading_cb)
87 : cors_mode_(BufferedResourceLoader::kUnspecified), 89 : url_(url),
90 cors_mode_(cors_mode),
88 total_bytes_(kPositionNotSpecified), 91 total_bytes_(kPositionNotSpecified),
89 assume_fully_buffered_(false), 92 assume_fully_buffered_(false),
90 streaming_(false), 93 streaming_(false),
91 frame_(frame), 94 frame_(frame),
92 intermediate_read_buffer_(new uint8[kInitialReadBufferSize]), 95 intermediate_read_buffer_(new uint8[kInitialReadBufferSize]),
93 intermediate_read_buffer_size_(kInitialReadBufferSize), 96 intermediate_read_buffer_size_(kInitialReadBufferSize),
94 render_loop_(render_loop), 97 render_loop_(render_loop),
95 stop_signal_received_(false), 98 stop_signal_received_(false),
96 media_has_played_(false), 99 media_has_played_(false),
97 preload_(AUTO), 100 preload_(AUTO),
(...skipping 23 matching lines...) Expand all
121 return new BufferedResourceLoader(url_, 124 return new BufferedResourceLoader(url_,
122 cors_mode_, 125 cors_mode_,
123 first_byte_position, 126 first_byte_position,
124 last_byte_position, 127 last_byte_position,
125 strategy, 128 strategy,
126 bitrate_, 129 bitrate_,
127 playback_rate_, 130 playback_rate_,
128 media_log_.get()); 131 media_log_.get());
129 } 132 }
130 133
131 void BufferedDataSource::Initialize( 134 void BufferedDataSource::Initialize(const InitializeCB& init_cb) {
132 const GURL& url,
133 BufferedResourceLoader::CORSMode cors_mode,
134 const InitializeCB& init_cb) {
135 DCHECK(render_loop_->BelongsToCurrentThread()); 135 DCHECK(render_loop_->BelongsToCurrentThread());
136 DCHECK(!init_cb.is_null()); 136 DCHECK(!init_cb.is_null());
137 DCHECK(!loader_.get()); 137 DCHECK(!loader_.get());
138 url_ = url;
139 cors_mode_ = cors_mode;
140 138
141 init_cb_ = init_cb; 139 init_cb_ = init_cb;
142 140
143 if (url_.SchemeIs(url::kHttpScheme) || url_.SchemeIs(url::kHttpsScheme)) { 141 if (url_.SchemeIsHTTPOrHTTPS()) {
144 // Do an unbounded range request starting at the beginning. If the server 142 // Do an unbounded range request starting at the beginning. If the server
145 // responds with 200 instead of 206 we'll fall back into a streaming mode. 143 // responds with 200 instead of 206 we'll fall back into a streaming mode.
146 loader_.reset(CreateResourceLoader(0, kPositionNotSpecified)); 144 loader_.reset(CreateResourceLoader(0, kPositionNotSpecified));
147 } else { 145 } else {
148 // For all other protocols, assume they support range request. We fetch 146 // For all other protocols, assume they support range request. We fetch
149 // the full range of the resource to obtain the instance size because 147 // the full range of the resource to obtain the instance size because
150 // we won't be served HTTP headers. 148 // we won't be served HTTP headers.
151 loader_.reset(CreateResourceLoader(kPositionNotSpecified, 149 loader_.reset(CreateResourceLoader(kPositionNotSpecified,
152 kPositionNotSpecified)); 150 kPositionNotSpecified));
153 assume_fully_buffered_ = true; 151 assume_fully_buffered_ = true;
scherkus (not reviewing) 2014/05/30 20:45:14 this boolean isn't needed -- it's essentially a du
amogh.bihani 2014/06/02 06:11:01 Done.
154 } 152 }
155 153
156 base::WeakPtr<BufferedDataSource> weak_this = weak_factory_.GetWeakPtr(); 154 base::WeakPtr<BufferedDataSource> weak_this = weak_factory_.GetWeakPtr();
157 loader_->Start( 155 loader_->Start(
158 base::Bind(&BufferedDataSource::StartCallback, weak_this), 156 base::Bind(&BufferedDataSource::StartCallback, weak_this),
159 base::Bind(&BufferedDataSource::LoadingStateChangedCallback, weak_this), 157 base::Bind(&BufferedDataSource::LoadingStateChangedCallback, weak_this),
160 base::Bind(&BufferedDataSource::ProgressCallback, weak_this), 158 base::Bind(&BufferedDataSource::ProgressCallback, weak_this),
161 frame_); 159 frame_);
162 } 160 }
163 161
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 return; 529 return;
532 } 530 }
533 531
534 // If media is currently playing or the page indicated preload=auto, 532 // If media is currently playing or the page indicated preload=auto,
535 // use threshold strategy to enable/disable deferring when the buffer 533 // use threshold strategy to enable/disable deferring when the buffer
536 // is full/depleted. 534 // is full/depleted.
537 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); 535 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer);
538 } 536 }
539 537
540 } // namespace content 538 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698