| 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" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 96 |
| 97 // Gets the content length in bytes of the instance after this loader has been | 97 // Gets the content length in bytes of the instance after this loader has been |
| 98 // started. If this value is |kPositionNotSpecified|, then content length is | 98 // started. If this value is |kPositionNotSpecified|, then content length is |
| 99 // unknown. | 99 // unknown. |
| 100 virtual int64 content_length(); | 100 virtual int64 content_length(); |
| 101 | 101 |
| 102 // Gets the original size of the file requested. If this value is | 102 // Gets the original size of the file requested. If this value is |
| 103 // |kPositionNotSpecified|, then the size is unknown. | 103 // |kPositionNotSpecified|, then the size is unknown. |
| 104 virtual int64 instance_size(); | 104 virtual int64 instance_size(); |
| 105 | 105 |
| 106 // Returns true if the response for this loader is a partial response. | 106 // Returns true if the server supports byte range requests. |
| 107 // It means a 206 response in HTTP/HTTPS protocol. | 107 virtual bool range_supported(); |
| 108 virtual bool partial_response(); | |
| 109 | 108 |
| 110 // Returns true if network is currently active. | 109 // Returns true if network is currently active. |
| 111 virtual bool network_activity(); | 110 virtual bool network_activity(); |
| 112 | 111 |
| 113 // Returns resulting URL. | 112 // Returns resulting URL. |
| 114 virtual const GURL& url(); | 113 virtual const GURL& url(); |
| 115 | 114 |
| 116 // Used to inject a mock used for unittests. | 115 // Used to inject a mock used for unittests. |
| 117 virtual void SetURLLoaderForTest(WebKit::WebURLLoader* mock_loader); | 116 virtual void SetURLLoaderForTest(WebKit::WebURLLoader* mock_loader); |
| 118 | 117 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 void DoneRead(int error); | 200 void DoneRead(int error); |
| 202 | 201 |
| 203 // Done with start. Invokes the start callback and reset it. | 202 // Done with start. Invokes the start callback and reset it. |
| 204 void DoneStart(int error); | 203 void DoneStart(int error); |
| 205 | 204 |
| 206 // Calls |event_callback_| in terms of a network event. | 205 // Calls |event_callback_| in terms of a network event. |
| 207 void NotifyNetworkEvent(); | 206 void NotifyNetworkEvent(); |
| 208 | 207 |
| 209 bool HasPendingRead() { return read_callback_.get() != NULL; } | 208 bool HasPendingRead() { return read_callback_.get() != NULL; } |
| 210 | 209 |
| 210 // Helper function that returns true if a range is not provided |
| 211 // or a 0- range is specified. |
| 212 bool IsWholeFileRange() const; |
| 213 |
| 211 // A sliding window of buffer. | 214 // A sliding window of buffer. |
| 212 scoped_ptr<media::SeekableBuffer> buffer_; | 215 scoped_ptr<media::SeekableBuffer> buffer_; |
| 213 | 216 |
| 214 // True if resource loading was deferred. | 217 // True if resource loading was deferred. |
| 215 bool deferred_; | 218 bool deferred_; |
| 216 | 219 |
| 217 // Current buffering algorithm in place for resource loading. | 220 // Current buffering algorithm in place for resource loading. |
| 218 DeferStrategy defer_strategy_; | 221 DeferStrategy defer_strategy_; |
| 219 | 222 |
| 220 // True if resource loading has completed. | 223 // True if resource loading has completed. |
| 221 bool completed_; | 224 bool completed_; |
| 222 | 225 |
| 223 // True if a range request was made. | 226 // True if a range request was made. |
| 224 bool range_requested_; | 227 bool range_requested_; |
| 225 | 228 |
| 226 // True if response data received is a partial range. | 229 // True if Range header is supported. |
| 227 bool partial_response_; | 230 bool range_supported_; |
| 228 | 231 |
| 229 // Does the work of loading and sends data back to this client. | 232 // Does the work of loading and sends data back to this client. |
| 230 scoped_ptr<WebKit::WebURLLoader> url_loader_; | 233 scoped_ptr<WebKit::WebURLLoader> url_loader_; |
| 231 | 234 |
| 232 GURL url_; | 235 GURL url_; |
| 233 int64 first_byte_position_; | 236 int64 first_byte_position_; |
| 234 int64 last_byte_position_; | 237 int64 last_byte_position_; |
| 235 bool single_origin_; | 238 bool single_origin_; |
| 236 | 239 |
| 237 // Callback method that listens to network events. | 240 // Callback method that listens to network events. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 257 | 260 |
| 258 // Used to ensure mocks for unittests are used instead of reset in Start(). | 261 // Used to ensure mocks for unittests are used instead of reset in Start(). |
| 259 bool keep_test_loader_; | 262 bool keep_test_loader_; |
| 260 | 263 |
| 261 DISALLOW_COPY_AND_ASSIGN(BufferedResourceLoader); | 264 DISALLOW_COPY_AND_ASSIGN(BufferedResourceLoader); |
| 262 }; | 265 }; |
| 263 | 266 |
| 264 } // namespace webkit_glue | 267 } // namespace webkit_glue |
| 265 | 268 |
| 266 #endif // WEBKIT_GLUE_MEDIA_BUFFERED_RESOURCE_LOADER_H_ | 269 #endif // WEBKIT_GLUE_MEDIA_BUFFERED_RESOURCE_LOADER_H_ |
| OLD | NEW |