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" |
11 #include "media/base/media_log.h" | 11 #include "media/base/media_log.h" |
12 #include "net/base/data_url.h" | 12 #include "net/base/data_url.h" |
13 #include "net/base/load_flags.h" | 13 #include "net/base/load_flags.h" |
14 #include "net/http/http_request_headers.h" | 14 #include "net/http/http_request_headers.h" |
15 #include "net/url_request/url_request_status.h" | 15 #include "net/url_request/url_request_status.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitPlatformSupport
.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitPlatformSupport
.h" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoaderOptions.h
" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoaderOptions.h
" |
20 #include "webkit/glue/webkit_glue.h" | |
21 #include "webkit/media/web_data_source_factory.h" | 20 #include "webkit/media/web_data_source_factory.h" |
22 | 21 |
23 using WebKit::WebString; | 22 using WebKit::WebString; |
24 using WebKit::WebURLLoaderOptions; | 23 using WebKit::WebURLLoaderOptions; |
25 | 24 |
26 namespace webkit_media { | 25 namespace webkit_media { |
27 | 26 |
28 static const char kDataScheme[] = "data"; | 27 static const char kDataScheme[] = "data"; |
29 | 28 |
30 static WebDataSource* NewSimpleDataSource(MessageLoop* render_loop, | 29 static WebDataSource* NewSimpleDataSource(MessageLoop* render_loop, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 scoped_refptr<SimpleDataSource> destruction_guard(this); | 88 scoped_refptr<SimpleDataSource> destruction_guard(this); |
90 { | 89 { |
91 base::AutoLock auto_lock(lock_); | 90 base::AutoLock auto_lock(lock_); |
92 DCHECK_EQ(state_, UNINITIALIZED); | 91 DCHECK_EQ(state_, UNINITIALIZED); |
93 DCHECK(!callback.is_null()); | 92 DCHECK(!callback.is_null()); |
94 state_ = INITIALIZING; | 93 state_ = INITIALIZING; |
95 initialize_cb_ = callback; | 94 initialize_cb_ = callback; |
96 | 95 |
97 // Validate the URL. | 96 // Validate the URL. |
98 url_ = GURL(url); | 97 url_ = GURL(url); |
99 if (!url_.is_valid() || !webkit_glue::IsProtocolSupportedForMedia(url_)) { | 98 if (!url_.is_valid()) { |
100 DoneInitialization_Locked(false); | 99 DoneInitialization_Locked(false); |
101 return; | 100 return; |
102 } | 101 } |
103 | 102 |
104 // Post a task to the render thread to start loading the resource. | 103 // Post a task to the render thread to start loading the resource. |
105 render_loop_->PostTask(FROM_HERE, | 104 render_loop_->PostTask(FROM_HERE, |
106 base::Bind(&SimpleDataSource::StartTask, this)); | 105 base::Bind(&SimpleDataSource::StartTask, this)); |
107 } | 106 } |
108 } | 107 } |
109 | 108 |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 void SimpleDataSource::UpdateHostState() { | 351 void SimpleDataSource::UpdateHostState() { |
353 if (host()) { | 352 if (host()) { |
354 host()->SetTotalBytes(size_); | 353 host()->SetTotalBytes(size_); |
355 host()->SetBufferedBytes(size_); | 354 host()->SetBufferedBytes(size_); |
356 // If scheme is file or data, say we are loaded. | 355 // If scheme is file or data, say we are loaded. |
357 host()->SetLoaded(url_.SchemeIsFile() || url_.SchemeIs(kDataScheme)); | 356 host()->SetLoaded(url_.SchemeIsFile() || url_.SchemeIs(kDataScheme)); |
358 } | 357 } |
359 } | 358 } |
360 | 359 |
361 } // namespace webkit_media | 360 } // namespace webkit_media |
OLD | NEW |