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 #ifndef WEBKIT_GLUE_MEDIA_BUFFERED_RESOURCE_LOADER_H_ | 5 #ifndef WEBKIT_GLUE_MEDIA_BUFFERED_RESOURCE_LOADER_H_ |
6 #define WEBKIT_GLUE_MEDIA_BUFFERED_RESOURCE_LOADER_H_ | 6 #define WEBKIT_GLUE_MEDIA_BUFFERED_RESOURCE_LOADER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/timer.h" | 12 #include "base/timer.h" |
13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
14 #include "media/base/seekable_buffer.h" | 14 #include "media/base/seekable_buffer.h" |
15 #include "net/base/file_stream.h" | 15 #include "net/base/file_stream.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoader.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoader.h" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoaderClient.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoaderClient.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" |
20 #include "webkit/glue/media/web_data_source.h" | 20 #include "webkit/glue/media/web_data_source.h" |
21 #include "webkit/glue/webmediaplayer_impl.h" | 21 #include "webkit/glue/webmediaplayer_impl.h" |
22 | 22 |
| 23 namespace media { |
| 24 class MediaLog; |
| 25 } |
| 26 |
23 namespace webkit_glue { | 27 namespace webkit_glue { |
24 | 28 |
25 const int64 kPositionNotSpecified = -1; | 29 const int64 kPositionNotSpecified = -1; |
26 | 30 |
27 const char kHttpScheme[] = "http"; | 31 const char kHttpScheme[] = "http"; |
28 const char kHttpsScheme[] = "https"; | 32 const char kHttpsScheme[] = "https"; |
29 const char kDataScheme[] = "data"; | 33 const char kDataScheme[] = "data"; |
30 | 34 |
31 // This class works inside demuxer thread and render thread. It contains a | 35 // This class works inside demuxer thread and render thread. It contains a |
32 // WebURLLoader and does the actual resource loading. This object does | 36 // WebURLLoader and does the actual resource loading. This object does |
(...skipping 14 matching lines...) Expand all Loading... |
47 | 51 |
48 typedef Callback0::Type NetworkEventCallback; | 52 typedef Callback0::Type NetworkEventCallback; |
49 | 53 |
50 // |url| - URL for the resource to be loaded. | 54 // |url| - URL for the resource to be loaded. |
51 // |first_byte_position| - First byte to start loading from, | 55 // |first_byte_position| - First byte to start loading from, |
52 // |kPositionNotSpecified| for not specified. | 56 // |kPositionNotSpecified| for not specified. |
53 // |last_byte_position| - Last byte to be loaded, | 57 // |last_byte_position| - Last byte to be loaded, |
54 // |kPositionNotSpecified| for not specified. | 58 // |kPositionNotSpecified| for not specified. |
55 BufferedResourceLoader(const GURL& url, | 59 BufferedResourceLoader(const GURL& url, |
56 int64 first_byte_position, | 60 int64 first_byte_position, |
57 int64 last_byte_position); | 61 int64 last_byte_position, |
| 62 media::MediaLog* media_log); |
58 | 63 |
59 // Start the resource loading with the specified URL and range. | 64 // Start the resource loading with the specified URL and range. |
60 // This method operates in asynchronous mode. Once there's a response from the | 65 // This method operates in asynchronous mode. Once there's a response from the |
61 // server, success or fail |callback| is called with the result. | 66 // server, success or fail |callback| is called with the result. |
62 // |callback| is called with the following values: | 67 // |callback| is called with the following values: |
63 // - net::OK | 68 // - net::OK |
64 // The request has started successfully. | 69 // The request has started successfully. |
65 // - net::ERR_FAILED | 70 // - net::ERR_FAILED |
66 // The request has failed because of an error with the network. | 71 // The request has failed because of an error with the network. |
67 // - net::ERR_INVALID_RESPONSE | 72 // - net::ERR_INVALID_RESPONSE |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 void DoneStart(int error); | 209 void DoneStart(int error); |
205 | 210 |
206 // Calls |event_callback_| in terms of a network event. | 211 // Calls |event_callback_| in terms of a network event. |
207 void NotifyNetworkEvent(); | 212 void NotifyNetworkEvent(); |
208 | 213 |
209 bool HasPendingRead() { return read_callback_.get() != NULL; } | 214 bool HasPendingRead() { return read_callback_.get() != NULL; } |
210 | 215 |
211 // Helper function that returns true if a range request was specified. | 216 // Helper function that returns true if a range request was specified. |
212 bool IsRangeRequest() const; | 217 bool IsRangeRequest() const; |
213 | 218 |
| 219 // Log everything interesting to |media_log_|. |
| 220 void Log(); |
| 221 |
214 // A sliding window of buffer. | 222 // A sliding window of buffer. |
215 scoped_ptr<media::SeekableBuffer> buffer_; | 223 scoped_ptr<media::SeekableBuffer> buffer_; |
216 | 224 |
217 // True if resource loading was deferred. | 225 // True if resource loading was deferred. |
218 bool deferred_; | 226 bool deferred_; |
219 | 227 |
220 // Current buffering algorithm in place for resource loading. | 228 // Current buffering algorithm in place for resource loading. |
221 DeferStrategy defer_strategy_; | 229 DeferStrategy defer_strategy_; |
222 | 230 |
223 // True if resource loading has completed. | 231 // True if resource loading has completed. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 uint8* read_buffer_; | 265 uint8* read_buffer_; |
258 | 266 |
259 // Offsets of the requested first byte and last byte in |buffer_|. They are | 267 // Offsets of the requested first byte and last byte in |buffer_|. They are |
260 // written by Read(). | 268 // written by Read(). |
261 int first_offset_; | 269 int first_offset_; |
262 int last_offset_; | 270 int last_offset_; |
263 | 271 |
264 // Used to ensure mocks for unittests are used instead of reset in Start(). | 272 // Used to ensure mocks for unittests are used instead of reset in Start(). |
265 bool keep_test_loader_; | 273 bool keep_test_loader_; |
266 | 274 |
| 275 scoped_refptr<media::MediaLog> media_log_; |
| 276 |
267 DISALLOW_COPY_AND_ASSIGN(BufferedResourceLoader); | 277 DISALLOW_COPY_AND_ASSIGN(BufferedResourceLoader); |
268 }; | 278 }; |
269 | 279 |
270 } // namespace webkit_glue | 280 } // namespace webkit_glue |
271 | 281 |
272 #endif // WEBKIT_GLUE_MEDIA_BUFFERED_RESOURCE_LOADER_H_ | 282 #endif // WEBKIT_GLUE_MEDIA_BUFFERED_RESOURCE_LOADER_H_ |
OLD | NEW |