OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "media/blink/resource_multibuffer_data_provider.h" | 5 #include "media/blink/resource_multibuffer_data_provider.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 161 |
162 void ResourceMultiBufferDataProvider::SetDeferred(bool deferred) { | 162 void ResourceMultiBufferDataProvider::SetDeferred(bool deferred) { |
163 if (!active_loader_ || active_loader_->deferred() == deferred) | 163 if (!active_loader_ || active_loader_->deferred() == deferred) |
164 return; | 164 return; |
165 active_loader_->SetDeferred(deferred); | 165 active_loader_->SetDeferred(deferred); |
166 } | 166 } |
167 | 167 |
168 ///////////////////////////////////////////////////////////////////////////// | 168 ///////////////////////////////////////////////////////////////////////////// |
169 // WebURLLoaderClient implementation. | 169 // WebURLLoaderClient implementation. |
170 | 170 |
171 void ResourceMultiBufferDataProvider::willFollowRedirect( | 171 bool ResourceMultiBufferDataProvider::willFollowRedirect( |
172 WebURLLoader* loader, | 172 WebURLLoader* loader, |
173 WebURLRequest& newRequest, | 173 WebURLRequest& newRequest, |
174 const WebURLResponse& redirectResponse, | 174 const WebURLResponse& redirectResponse, |
175 int64_t encodedDataLength) { | 175 int64_t encodedDataLength) { |
176 redirects_to_ = newRequest.url(); | 176 redirects_to_ = newRequest.url(); |
177 url_data_->set_valid_until(base::Time::Now() + | 177 url_data_->set_valid_until(base::Time::Now() + |
178 GetCacheValidUntil(redirectResponse)); | 178 GetCacheValidUntil(redirectResponse)); |
179 | 179 |
180 // This test is vital for security! | 180 // This test is vital for security! |
181 if (cors_mode_ == UrlData::CORS_UNSPECIFIED) { | 181 if (cors_mode_ == UrlData::CORS_UNSPECIFIED) { |
182 // We allow the redirect if the origin is the same. | 182 // We allow the redirect if the origin is the same. |
183 if (origin_ != redirects_to_.GetOrigin()) { | 183 if (origin_ != redirects_to_.GetOrigin()) { |
184 // We also allow the redirect if we don't have any data in the | 184 // We also allow the redirect if we don't have any data in the |
185 // cache, as that means that no dangerous data mixing can occur. | 185 // cache, as that means that no dangerous data mixing can occur. |
186 if (url_data_->multibuffer()->map().empty() && fifo_.empty()) | 186 if (url_data_->multibuffer()->map().empty() && fifo_.empty()) |
187 return; | 187 return true; |
188 | 188 |
189 active_loader_ = nullptr; | 189 active_loader_ = nullptr; |
190 url_data_->Fail(); | 190 url_data_->Fail(); |
191 return; // "this" may be deleted now. | 191 return false; // "this" may be deleted now. |
192 } | 192 } |
193 } | 193 } |
| 194 return true; |
194 } | 195 } |
195 | 196 |
196 void ResourceMultiBufferDataProvider::didSendData( | 197 void ResourceMultiBufferDataProvider::didSendData( |
197 WebURLLoader* loader, | 198 WebURLLoader* loader, |
198 unsigned long long bytes_sent, | 199 unsigned long long bytes_sent, |
199 unsigned long long total_bytes_to_be_sent) { | 200 unsigned long long total_bytes_to_be_sent) { |
200 NOTIMPLEMENTED(); | 201 NOTIMPLEMENTED(); |
201 } | 202 } |
202 | 203 |
203 void ResourceMultiBufferDataProvider::didReceiveResponse( | 204 void ResourceMultiBufferDataProvider::didReceiveResponse( |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 } | 548 } |
548 | 549 |
549 if (byte_pos() != first_byte_position) { | 550 if (byte_pos() != first_byte_position) { |
550 return false; | 551 return false; |
551 } | 552 } |
552 | 553 |
553 return true; | 554 return true; |
554 } | 555 } |
555 | 556 |
556 } // namespace media | 557 } // namespace media |
OLD | NEW |