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

Side by Side Diff: webkit/glue/media/buffered_data_source.cc

Issue 212011: Remove whiltelist checks for protocol for <audio> and <video> (Closed)
Patch Set: Created 11 years, 3 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "base/compiler_specific.h" 5 #include "base/compiler_specific.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/process_util.h" 7 #include "base/process_util.h"
8 #include "base/stl_util-inl.h" 8 #include "base/stl_util-inl.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "chrome/common/extensions/url_pattern.h" 10 #include "chrome/common/extensions/url_pattern.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // before we declare a read error. After each failure of read from a buffered 49 // before we declare a read error. After each failure of read from a buffered
50 // resource loader, a new one is created to be read. 50 // resource loader, a new one is created to be read.
51 // TODO(hclam): Use this value when retry is implemented. 51 // TODO(hclam): Use this value when retry is implemented.
52 const int kReadTrials = 3; 52 const int kReadTrials = 3;
53 53
54 // BufferedDataSource has an intermediate buffer, this value governs the initial 54 // BufferedDataSource has an intermediate buffer, this value governs the initial
55 // size of that buffer. It is set to 32KB because this is a typical read size 55 // size of that buffer. It is set to 32KB because this is a typical read size
56 // of FFmpeg. 56 // of FFmpeg.
57 const int kInitialReadBufferSize = 32768; 57 const int kInitialReadBufferSize = 32768;
58 58
59 // A helper method that accepts only HTTP, HTTPS and FILE protocol.
60 // TODO(hclam): Support also FTP protocol.
61 bool IsSchemeSupported(const GURL& url) {
62 return url.SchemeIs(kHttpScheme) ||
63 url.SchemeIs(kHttpsScheme) ||
64 url.SchemeIsFile();
65 }
66
67 } // namespace 59 } // namespace
68 60
69 namespace webkit_glue { 61 namespace webkit_glue {
70 62
71 ///////////////////////////////////////////////////////////////////////////// 63 /////////////////////////////////////////////////////////////////////////////
72 // BufferedResourceLoader 64 // BufferedResourceLoader
73 BufferedResourceLoader::BufferedResourceLoader( 65 BufferedResourceLoader::BufferedResourceLoader(
74 webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory, 66 webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory,
75 const GURL& url, 67 const GURL& url,
76 int64 first_byte_position, 68 int64 first_byte_position,
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 const webkit_glue::ResourceLoaderBridge::ResponseInfo& info) { 198 const webkit_glue::ResourceLoaderBridge::ResponseInfo& info) {
207 DCHECK(bridge_.get()); 199 DCHECK(bridge_.get());
208 200
209 // Saves the new URL. 201 // Saves the new URL.
210 url_ = new_url; 202 url_ = new_url;
211 203
212 // The load may have been stopped and |start_callback| is destroyed. 204 // The load may have been stopped and |start_callback| is destroyed.
213 // In this case we shouldn't do anything. 205 // In this case we shouldn't do anything.
214 if (!start_callback_.get()) 206 if (!start_callback_.get())
215 return true; 207 return true;
216
217 // If we got redirected to an unsupported protocol then stop.
218 if (!IsSchemeSupported(new_url)) {
219 DoneStart(net::ERR_ADDRESS_INVALID);
220 Stop();
221 }
222
223 return true; 208 return true;
224 } 209 }
225 210
226 void BufferedResourceLoader::OnReceivedResponse( 211 void BufferedResourceLoader::OnReceivedResponse(
227 const webkit_glue::ResourceLoaderBridge::ResponseInfo& info, 212 const webkit_glue::ResourceLoaderBridge::ResponseInfo& info,
228 bool content_filtered) { 213 bool content_filtered) {
229 DCHECK(bridge_.get()); 214 DCHECK(bridge_.get());
230 215
231 // The loader may have been stopped and |start_callback| is destroyed. 216 // The loader may have been stopped and |start_callback| is destroyed.
232 // In this case we shouldn't do anything. 217 // In this case we shouldn't do anything.
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 ///////////////////////////////////////////////////////////////////////////// 490 /////////////////////////////////////////////////////////////////////////////
506 // BufferedDataSource, media::MediaFilter implementation 491 // BufferedDataSource, media::MediaFilter implementation
507 void BufferedDataSource::Initialize(const std::string& url, 492 void BufferedDataSource::Initialize(const std::string& url,
508 media::FilterCallback* callback) { 493 media::FilterCallback* callback) {
509 DCHECK(callback); 494 DCHECK(callback);
510 initialize_callback_.reset(callback); 495 initialize_callback_.reset(callback);
511 496
512 // Saves the url. 497 // Saves the url.
513 url_ = GURL(url); 498 url_ = GURL(url);
514 499
515 if (!IsSchemeSupported(url_)) {
516 host()->SetError(media::PIPELINE_ERROR_NETWORK);
517 DoneInitialization();
518 return;
519 }
520
521 media_format_.SetAsString(media::MediaFormat::kMimeType, 500 media_format_.SetAsString(media::MediaFormat::kMimeType,
522 media::mime_type::kApplicationOctetStream); 501 media::mime_type::kApplicationOctetStream);
523 media_format_.SetAsString(media::MediaFormat::kURL, url); 502 media_format_.SetAsString(media::MediaFormat::kURL, url);
524 503
525 // Post a task to complete the initialization task. 504 // Post a task to complete the initialization task.
526 render_loop_->PostTask(FROM_HERE, 505 render_loop_->PostTask(FROM_HERE,
527 NewRunnableMethod(this, &BufferedDataSource::InitializeTask)); 506 NewRunnableMethod(this, &BufferedDataSource::InitializeTask));
528 } 507 }
529 508
530 void BufferedDataSource::Stop() { 509 void BufferedDataSource::Stop() {
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 render_loop_->PostTask(FROM_HERE, 842 render_loop_->PostTask(FROM_HERE,
864 NewRunnableMethod(this, &BufferedDataSource::SwapLoaderTask, 843 NewRunnableMethod(this, &BufferedDataSource::SwapLoaderTask,
865 CreateLoader(read_position_, -1))); 844 CreateLoader(read_position_, -1)));
866 } else { 845 } else {
867 loader_->Stop(); 846 loader_->Stop();
868 DoneRead(error); 847 DoneRead(error);
869 } 848 }
870 } 849 }
871 850
872 } // namespace webkit_glue 851 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698