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