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