| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/media/simple_data_source.h" | 5 #include "webkit/media/simple_data_source.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "media/base/filter_host.h" | 10 #include "media/base/filter_host.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 &NewSimpleDataSource, build_observer); | 42 &NewSimpleDataSource, build_observer); |
| 43 } | 43 } |
| 44 | 44 |
| 45 SimpleDataSource::SimpleDataSource( | 45 SimpleDataSource::SimpleDataSource( |
| 46 MessageLoop* render_loop, | 46 MessageLoop* render_loop, |
| 47 WebKit::WebFrame* frame) | 47 WebKit::WebFrame* frame) |
| 48 : render_loop_(render_loop), | 48 : render_loop_(render_loop), |
| 49 frame_(frame), | 49 frame_(frame), |
| 50 size_(-1), | 50 size_(-1), |
| 51 single_origin_(true), | 51 single_origin_(true), |
| 52 local_source_(false), |
| 52 state_(UNINITIALIZED), | 53 state_(UNINITIALIZED), |
| 53 keep_test_loader_(false) { | 54 keep_test_loader_(false) { |
| 54 DCHECK(render_loop); | 55 DCHECK(render_loop); |
| 55 } | 56 } |
| 56 | 57 |
| 57 SimpleDataSource::~SimpleDataSource() { | 58 SimpleDataSource::~SimpleDataSource() { |
| 58 base::AutoLock auto_lock(lock_); | 59 base::AutoLock auto_lock(lock_); |
| 59 DCHECK(state_ == UNINITIALIZED || state_ == STOPPED); | 60 DCHECK(state_ == UNINITIALIZED || state_ == STOPPED); |
| 60 } | 61 } |
| 61 | 62 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 state_ = INITIALIZING; | 94 state_ = INITIALIZING; |
| 94 initialize_cb_ = callback; | 95 initialize_cb_ = callback; |
| 95 | 96 |
| 96 // Validate the URL. | 97 // Validate the URL. |
| 97 url_ = GURL(url); | 98 url_ = GURL(url); |
| 98 if (!url_.is_valid()) { | 99 if (!url_.is_valid()) { |
| 99 DoneInitialization_Locked(false); | 100 DoneInitialization_Locked(false); |
| 100 return; | 101 return; |
| 101 } | 102 } |
| 102 | 103 |
| 104 // If scheme is file or data, it is a local source. |
| 105 local_source_ = url_.SchemeIsFile() || url_.SchemeIs(kDataScheme); |
| 106 |
| 103 // Post a task to the render thread to start loading the resource. | 107 // Post a task to the render thread to start loading the resource. |
| 104 render_loop_->PostTask(FROM_HERE, | 108 render_loop_->PostTask(FROM_HERE, |
| 105 base::Bind(&SimpleDataSource::StartTask, this)); | 109 base::Bind(&SimpleDataSource::StartTask, this)); |
| 106 } | 110 } |
| 107 } | 111 } |
| 108 | 112 |
| 109 void SimpleDataSource::CancelInitialize() { | 113 void SimpleDataSource::CancelInitialize() { |
| 110 base::AutoLock auto_lock(lock_); | 114 base::AutoLock auto_lock(lock_); |
| 111 DCHECK(!initialize_cb_.is_null()); | 115 DCHECK(!initialize_cb_.is_null()); |
| 112 state_ = STOPPED; | 116 state_ = STOPPED; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 139 bool SimpleDataSource::IsStreaming() { | 143 bool SimpleDataSource::IsStreaming() { |
| 140 return false; | 144 return false; |
| 141 } | 145 } |
| 142 | 146 |
| 143 void SimpleDataSource::SetPreload(media::Preload preload) { | 147 void SimpleDataSource::SetPreload(media::Preload preload) { |
| 144 } | 148 } |
| 145 | 149 |
| 146 void SimpleDataSource::SetBitrate(int bitrate) { | 150 void SimpleDataSource::SetBitrate(int bitrate) { |
| 147 } | 151 } |
| 148 | 152 |
| 153 bool SimpleDataSource::IsLocalSource() { |
| 154 return local_source_; |
| 155 } |
| 156 |
| 149 void SimpleDataSource::SetURLLoaderForTest(WebKit::WebURLLoader* mock_loader) { | 157 void SimpleDataSource::SetURLLoaderForTest(WebKit::WebURLLoader* mock_loader) { |
| 150 url_loader_.reset(mock_loader); | 158 url_loader_.reset(mock_loader); |
| 151 keep_test_loader_ = true; | 159 keep_test_loader_ = true; |
| 152 } | 160 } |
| 153 | 161 |
| 154 void SimpleDataSource::willSendRequest( | 162 void SimpleDataSource::willSendRequest( |
| 155 WebKit::WebURLLoader* loader, | 163 WebKit::WebURLLoader* loader, |
| 156 WebKit::WebURLRequest& newRequest, | 164 WebKit::WebURLRequest& newRequest, |
| 157 const WebKit::WebURLResponse& redirectResponse) { | 165 const WebKit::WebURLResponse& redirectResponse) { |
| 158 DCHECK(MessageLoop::current() == render_loop_); | 166 DCHECK(MessageLoop::current() == render_loop_); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 } | 353 } |
| 346 | 354 |
| 347 initialize_cb_.Run(status); | 355 initialize_cb_.Run(status); |
| 348 initialize_cb_.Reset(); | 356 initialize_cb_.Reset(); |
| 349 } | 357 } |
| 350 | 358 |
| 351 void SimpleDataSource::UpdateHostState() { | 359 void SimpleDataSource::UpdateHostState() { |
| 352 if (host()) { | 360 if (host()) { |
| 353 host()->SetTotalBytes(size_); | 361 host()->SetTotalBytes(size_); |
| 354 host()->SetBufferedBytes(size_); | 362 host()->SetBufferedBytes(size_); |
| 355 // If scheme is file or data, say we are loaded. | |
| 356 host()->SetLoaded(url_.SchemeIsFile() || url_.SchemeIs(kDataScheme)); | |
| 357 } | 363 } |
| 358 } | 364 } |
| 359 | 365 |
| 360 } // namespace webkit_media | 366 } // namespace webkit_media |
| OLD | NEW |