| 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/glue/media/simple_data_source.h" | 5 #include "webkit/glue/media/simple_data_source.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/process_util.h" | 8 #include "base/process_util.h" |
| 9 #include "media/base/filter_host.h" | 9 #include "media/base/filter_host.h" |
| 10 #include "net/base/data_url.h" | 10 #include "net/base/data_url.h" |
| 11 #include "net/base/load_flags.h" | 11 #include "net/base/load_flags.h" |
| 12 #include "net/http/http_request_headers.h" | |
| 13 #include "net/url_request/url_request_status.h" | 12 #include "net/url_request/url_request_status.h" |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitClient.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitClient.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | |
| 17 #include "webkit/glue/media/web_data_source_factory.h" | 15 #include "webkit/glue/media/web_data_source_factory.h" |
| 18 #include "webkit/glue/webkit_glue.h" | 16 #include "webkit/glue/webkit_glue.h" |
| 19 | 17 |
| 20 using WebKit::WebString; | |
| 21 | |
| 22 namespace webkit_glue { | 18 namespace webkit_glue { |
| 23 | 19 |
| 24 static const char kDataScheme[] = "data"; | 20 static const char kDataScheme[] = "data"; |
| 25 | 21 |
| 26 static WebDataSource* NewSimpleDataSource(MessageLoop* render_loop, | 22 static WebDataSource* NewSimpleDataSource(MessageLoop* render_loop, |
| 27 WebKit::WebFrame* frame) { | 23 WebKit::WebFrame* frame) { |
| 28 return new SimpleDataSource(render_loop, frame); | 24 return new SimpleDataSource(render_loop, frame); |
| 29 } | 25 } |
| 30 | 26 |
| 31 // static | 27 // static |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 // Don't care about the mime-type just proceed if decoding was successful. | 293 // Don't care about the mime-type just proceed if decoding was successful. |
| 298 size_ = data_.length(); | 294 size_ = data_.length(); |
| 299 DoneInitialization_Locked(success); | 295 DoneInitialization_Locked(success); |
| 300 } else { | 296 } else { |
| 301 // Prepare the request. | 297 // Prepare the request. |
| 302 WebKit::WebURLRequest request(url_); | 298 WebKit::WebURLRequest request(url_); |
| 303 request.setTargetType(WebKit::WebURLRequest::TargetIsMedia); | 299 request.setTargetType(WebKit::WebURLRequest::TargetIsMedia); |
| 304 | 300 |
| 305 frame_->setReferrerForRequest(request, WebKit::WebURL()); | 301 frame_->setReferrerForRequest(request, WebKit::WebURL()); |
| 306 | 302 |
| 307 // Disable compression, compression for audio/video doesn't make sense... | |
| 308 request.setHTTPHeaderField( | |
| 309 WebString::fromUTF8(net::HttpRequestHeaders::kAcceptEncoding), | |
| 310 WebString::fromUTF8("identity;q=1, *;q=0")); | |
| 311 | |
| 312 // This flag is for unittests as we don't want to reset |url_loader| | 303 // This flag is for unittests as we don't want to reset |url_loader| |
| 313 if (!keep_test_loader_) | 304 if (!keep_test_loader_) |
| 314 url_loader_.reset(frame_->createAssociatedURLLoader()); | 305 url_loader_.reset(frame_->createAssociatedURLLoader()); |
| 315 | 306 |
| 316 // Start the resource loading. | 307 // Start the resource loading. |
| 317 url_loader_->loadAsynchronously(request, this); | 308 url_loader_->loadAsynchronously(request, this); |
| 318 } | 309 } |
| 319 } | 310 } |
| 320 } | 311 } |
| 321 | 312 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 352 void SimpleDataSource::UpdateHostState() { | 343 void SimpleDataSource::UpdateHostState() { |
| 353 if (host()) { | 344 if (host()) { |
| 354 host()->SetTotalBytes(size_); | 345 host()->SetTotalBytes(size_); |
| 355 host()->SetBufferedBytes(size_); | 346 host()->SetBufferedBytes(size_); |
| 356 // If scheme is file or data, say we are loaded. | 347 // If scheme is file or data, say we are loaded. |
| 357 host()->SetLoaded(url_.SchemeIsFile() || url_.SchemeIs(kDataScheme)); | 348 host()->SetLoaded(url_.SchemeIsFile() || url_.SchemeIs(kDataScheme)); |
| 358 } | 349 } |
| 359 } | 350 } |
| 360 | 351 |
| 361 } // namespace webkit_glue | 352 } // namespace webkit_glue |
| OLD | NEW |