Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: webkit/media/buffered_resource_loader.h

Issue 8764002: Finish the base::Bind migration for webkit/media. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_MEDIA_BUFFERED_RESOURCE_LOADER_H_ 5 #ifndef WEBKIT_MEDIA_BUFFERED_RESOURCE_LOADER_H_
6 #define WEBKIT_MEDIA_BUFFERED_RESOURCE_LOADER_H_ 6 #define WEBKIT_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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // - net::OK 72 // - net::OK
73 // The request has started successfully. 73 // The request has started successfully.
74 // - net::ERR_FAILED 74 // - net::ERR_FAILED
75 // The request has failed because of an error with the network. 75 // The request has failed because of an error with the network.
76 // - net::ERR_INVALID_RESPONSE 76 // - net::ERR_INVALID_RESPONSE
77 // An invalid response is received from the server. 77 // An invalid response is received from the server.
78 // - (Anything else) 78 // - (Anything else)
79 // An error code that indicates the request has failed. 79 // An error code that indicates the request has failed.
80 // |event_callback| is called when the response is completed, data is 80 // |event_callback| is called when the response is completed, data is
81 // received, the request is suspended or resumed. 81 // received, the request is suspended or resumed.
82 virtual void Start(net::OldCompletionCallback* callback, 82 virtual void Start(const net::CompletionCallback& callback,
83 const base::Closure& event_callback, 83 const base::Closure& event_callback,
84 WebKit::WebFrame* frame); 84 WebKit::WebFrame* frame);
85 85
86 // Stop this loader, cancels and request and release internal buffer. 86 // Stop this loader, cancels and request and release internal buffer.
87 virtual void Stop(); 87 virtual void Stop();
88 88
89 // Reads the specified |read_size| from |position| into |buffer| and when 89 // Reads the specified |read_size| from |position| into |buffer| and when
90 // the operation is done invoke |callback| with number of bytes read or an 90 // the operation is done invoke |callback| with number of bytes read or an
91 // error code. If necessary, will temporarily increase forward capacity of 91 // error code. If necessary, will temporarily increase forward capacity of
92 // buffer to accomodate an unusually large read. 92 // buffer to accomodate an unusually large read.
93 // |callback| is called with the following values: 93 // |callback| is called with the following values:
94 // - (Anything greater than or equal 0) 94 // - (Anything greater than or equal 0)
95 // Read was successful with the indicated number of bytes read. 95 // Read was successful with the indicated number of bytes read.
96 // - net::ERR_FAILED 96 // - net::ERR_FAILED
97 // The read has failed because of an error with the network. 97 // The read has failed because of an error with the network.
98 // - net::ERR_CACHE_MISS 98 // - net::ERR_CACHE_MISS
99 // The read was made too far away from the current buffered position. 99 // The read was made too far away from the current buffered position.
100 virtual void Read(int64 position, int read_size, 100 virtual void Read(int64 position, int read_size,
101 uint8* buffer, net::OldCompletionCallback* callback); 101 uint8* buffer, const net::CompletionCallback& callback);
102 102
103 // Returns the position of the last byte buffered. Returns 103 // Returns the position of the last byte buffered. Returns
104 // |kPositionNotSpecified| if such value is not available. 104 // |kPositionNotSpecified| if such value is not available.
105 virtual int64 GetBufferedPosition(); 105 virtual int64 GetBufferedPosition();
106 106
107 // Gets the content length in bytes of the instance after this loader has been 107 // Gets the content length in bytes of the instance after this loader has been
108 // started. If this value is |kPositionNotSpecified|, then content length is 108 // started. If this value is |kPositionNotSpecified|, then content length is
109 // unknown. 109 // unknown.
110 virtual int64 content_length(); 110 virtual int64 content_length();
111 111
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // Done with read. Invokes the read callback and reset parameters for the 220 // Done with read. Invokes the read callback and reset parameters for the
221 // read request. 221 // read request.
222 void DoneRead(int error); 222 void DoneRead(int error);
223 223
224 // Done with start. Invokes the start callback and reset it. 224 // Done with start. Invokes the start callback and reset it.
225 void DoneStart(int error); 225 void DoneStart(int error);
226 226
227 // Calls |event_callback_| in terms of a network event. 227 // Calls |event_callback_| in terms of a network event.
228 void NotifyNetworkEvent(); 228 void NotifyNetworkEvent();
229 229
230 bool HasPendingRead() { return read_callback_.get() != NULL; } 230 bool HasPendingRead() { return !read_callback_.is_null(); }
231 231
232 // Helper function that returns true if a range request was specified. 232 // Helper function that returns true if a range request was specified.
233 bool IsRangeRequest() const; 233 bool IsRangeRequest() const;
234 234
235 // Log everything interesting to |media_log_|. 235 // Log everything interesting to |media_log_|.
236 void Log(); 236 void Log();
237 237
238 // A sliding window of buffer. 238 // A sliding window of buffer.
239 scoped_ptr<media::SeekableBuffer> buffer_; 239 scoped_ptr<media::SeekableBuffer> buffer_;
240 240
(...skipping 20 matching lines...) Expand all
261 261
262 GURL url_; 262 GURL url_;
263 int64 first_byte_position_; 263 int64 first_byte_position_;
264 int64 last_byte_position_; 264 int64 last_byte_position_;
265 bool single_origin_; 265 bool single_origin_;
266 266
267 // Callback method that listens to network events. 267 // Callback method that listens to network events.
268 base::Closure event_callback_; 268 base::Closure event_callback_;
269 269
270 // Members used during request start. 270 // Members used during request start.
271 scoped_ptr<net::OldCompletionCallback> start_callback_; 271 net::CompletionCallback start_callback_;
272 int64 offset_; 272 int64 offset_;
273 int64 content_length_; 273 int64 content_length_;
274 int64 instance_size_; 274 int64 instance_size_;
275 275
276 // Members used during a read operation. They should be reset after each 276 // Members used during a read operation. They should be reset after each
277 // read has completed or failed. 277 // read has completed or failed.
278 scoped_ptr<net::OldCompletionCallback> read_callback_; 278 net::CompletionCallback read_callback_;
279 int64 read_position_; 279 int64 read_position_;
280 size_t read_size_; 280 size_t read_size_;
281 uint8* read_buffer_; 281 uint8* read_buffer_;
282 282
283 // Offsets of the requested first byte and last byte in |buffer_|. They are 283 // Offsets of the requested first byte and last byte in |buffer_|. They are
284 // written by Read(). 284 // written by Read().
285 int first_offset_; 285 int first_offset_;
286 int last_offset_; 286 int last_offset_;
287 287
288 // Used to ensure mocks for unittests are used instead of reset in Start(). 288 // Used to ensure mocks for unittests are used instead of reset in Start().
289 bool keep_test_loader_; 289 bool keep_test_loader_;
290 290
291 // Bitrate of the media. Set to 0 if unknown. 291 // Bitrate of the media. Set to 0 if unknown.
292 int bitrate_; 292 int bitrate_;
293 293
294 // Playback rate of the media. 294 // Playback rate of the media.
295 float playback_rate_; 295 float playback_rate_;
296 296
297 scoped_refptr<media::MediaLog> media_log_; 297 scoped_refptr<media::MediaLog> media_log_;
298 298
299 DISALLOW_COPY_AND_ASSIGN(BufferedResourceLoader); 299 DISALLOW_COPY_AND_ASSIGN(BufferedResourceLoader);
300 }; 300 };
301 301
302 } // namespace webkit_media 302 } // namespace webkit_media
303 303
304 #endif // WEBKIT_MEDIA_BUFFERED_RESOURCE_LOADER_H_ 304 #endif // WEBKIT_MEDIA_BUFFERED_RESOURCE_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698