OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/process_util.h" | 6 #include "base/process_util.h" |
7 #include "media/base/filter_host.h" | 7 #include "media/base/filter_host.h" |
8 #include "net/base/load_flags.h" | 8 #include "net/base/load_flags.h" |
9 #include "net/http/http_response_headers.h" | 9 #include "net/http/http_response_headers.h" |
10 #include "net/url_request/url_request_status.h" | 10 #include "net/url_request/url_request_status.h" |
(...skipping 48 matching lines...) Loading... |
59 media::FilterCallback* callback) { | 59 media::FilterCallback* callback) { |
60 AutoLock auto_lock(lock_); | 60 AutoLock auto_lock(lock_); |
61 DCHECK_EQ(state_, UNINITIALIZED); | 61 DCHECK_EQ(state_, UNINITIALIZED); |
62 DCHECK(callback); | 62 DCHECK(callback); |
63 state_ = INITIALIZING; | 63 state_ = INITIALIZING; |
64 initialize_callback_.reset(callback); | 64 initialize_callback_.reset(callback); |
65 | 65 |
66 // Validate the URL. | 66 // Validate the URL. |
67 SetURL(GURL(url)); | 67 SetURL(GURL(url)); |
68 if (!url_.is_valid() || !IsSchemeSupported(url_)) { | 68 if (!url_.is_valid() || !IsSchemeSupported(url_)) { |
69 host()->Error(media::PIPELINE_ERROR_NETWORK); | 69 host()->SetError(media::PIPELINE_ERROR_NETWORK); |
70 initialize_callback_->Run(); | 70 initialize_callback_->Run(); |
71 initialize_callback_.reset(); | 71 initialize_callback_.reset(); |
72 return; | 72 return; |
73 } | 73 } |
74 | 74 |
75 // Post a task to the render thread to start loading the resource. | 75 // Post a task to the render thread to start loading the resource. |
76 render_loop_->PostTask(FROM_HERE, | 76 render_loop_->PostTask(FROM_HERE, |
77 NewRunnableMethod(this, &SimpleDataSource::StartTask)); | 77 NewRunnableMethod(this, &SimpleDataSource::StartTask)); |
78 } | 78 } |
79 | 79 |
(...skipping 68 matching lines...) Loading... |
148 if (size_ == -1) { | 148 if (size_ == -1) { |
149 size_ = data_.length(); | 149 size_ = data_.length(); |
150 } | 150 } |
151 | 151 |
152 // We're initialized! | 152 // We're initialized! |
153 if (status.is_success()) { | 153 if (status.is_success()) { |
154 state_ = INITIALIZED; | 154 state_ = INITIALIZED; |
155 host()->SetTotalBytes(size_); | 155 host()->SetTotalBytes(size_); |
156 host()->SetBufferedBytes(size_); | 156 host()->SetBufferedBytes(size_); |
157 } else { | 157 } else { |
158 host()->Error(media::PIPELINE_ERROR_NETWORK); | 158 host()->SetError(media::PIPELINE_ERROR_NETWORK); |
159 } | 159 } |
160 initialize_callback_->Run(); | 160 initialize_callback_->Run(); |
161 initialize_callback_.reset(); | 161 initialize_callback_.reset(); |
162 } | 162 } |
163 | 163 |
164 std::string SimpleDataSource::GetURLForDebugging() { | 164 std::string SimpleDataSource::GetURLForDebugging() { |
165 return url_.spec(); | 165 return url_.spec(); |
166 } | 166 } |
167 | 167 |
168 void SimpleDataSource::SetURL(const GURL& url) { | 168 void SimpleDataSource::SetURL(const GURL& url) { |
(...skipping 25 matching lines...) Loading... |
194 DCHECK_EQ(state_, STOPPED); | 194 DCHECK_EQ(state_, STOPPED); |
195 | 195 |
196 // Cancel any pending requests. | 196 // Cancel any pending requests. |
197 if (bridge_.get()) { | 197 if (bridge_.get()) { |
198 bridge_->Cancel(); | 198 bridge_->Cancel(); |
199 bridge_.reset(); | 199 bridge_.reset(); |
200 } | 200 } |
201 } | 201 } |
202 | 202 |
203 } // namespace webkit_glue | 203 } // namespace webkit_glue |
OLD | NEW |