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

Side by Side Diff: webkit/glue/media/buffered_data_source.h

Issue 164361: Refcounting BufferedResourceLoader (Closed)
Patch Set: done Created 11 years, 4 months 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
« no previous file with comments | « no previous file | webkit/glue/media/buffered_data_source.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #ifndef WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_H_ 5 #ifndef WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_H_
6 #define WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_H_ 6 #define WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/lock.h" 10 #include "base/lock.h"
(...skipping 11 matching lines...) Expand all
22 #include "webkit/glue/media/media_resource_loader_bridge_factory.h" 22 #include "webkit/glue/media/media_resource_loader_bridge_factory.h"
23 23
24 namespace webkit_glue { 24 namespace webkit_glue {
25 25
26 ///////////////////////////////////////////////////////////////////////////// 26 /////////////////////////////////////////////////////////////////////////////
27 // BufferedResourceLoader 27 // BufferedResourceLoader
28 // This class works inside demuxer thread and render thread. It contains a 28 // This class works inside demuxer thread and render thread. It contains a
29 // resource loader bridge and does the actual resource loading. This object 29 // resource loader bridge and does the actual resource loading. This object
30 // does buffering internally, it defers the resource loading if buffer is 30 // does buffering internally, it defers the resource loading if buffer is
31 // full and un-defers the resource loading if it is under buffered. 31 // full and un-defers the resource loading if it is under buffered.
32 class BufferedResourceLoader : public webkit_glue::ResourceLoaderBridge::Peer { 32 class BufferedResourceLoader :
33 public base::RefCountedThreadSafe<BufferedResourceLoader>,
34 public webkit_glue::ResourceLoaderBridge::Peer {
33 public: 35 public:
34 // |bridge_factory| - Factory to create a ResourceLoaderBridge. 36 // |bridge_factory| - Factory to create a ResourceLoaderBridge.
35 // |url| - URL for the resource to be loaded. 37 // |url| - URL for the resource to be loaded.
36 // |first_byte_position| - First byte to start loading from, -1 for not 38 // |first_byte_position| - First byte to start loading from, -1 for not
37 // specified. 39 // specified.
38 // |last_byte_position| - Last byte to be loaded, -1 for not specified. 40 // |last_byte_position| - Last byte to be loaded, -1 for not specified.
39 BufferedResourceLoader( 41 BufferedResourceLoader(
40 webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory, 42 webkit_glue::MediaResourceLoaderBridgeFactory* bridge_factory,
41 const GURL& url, 43 const GURL& url,
42 int64 first_byte_position, 44 int64 first_byte_position,
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 // thread. 229 // thread.
228 void ReadTask(int64 position, int read_size, 230 void ReadTask(int64 position, int read_size,
229 uint8* read_buffer, 231 uint8* read_buffer,
230 media::DataSource::ReadCallback* read_callback); 232 media::DataSource::ReadCallback* read_callback);
231 233
232 // Task posted when Stop() is called. 234 // Task posted when Stop() is called.
233 void StopTask(); 235 void StopTask();
234 236
235 // Reset |loader_| with |loader| and starts it. This task is posted from 237 // Reset |loader_| with |loader| and starts it. This task is posted from
236 // callback method from the current buffered resource loader. 238 // callback method from the current buffered resource loader.
237 void SwapLoaderTask(BufferedResourceLoader* loader); 239 void SwapLoaderTask(scoped_refptr<BufferedResourceLoader> loader);
238 240
239 // This task monitors the current active read request. If the current read 241 // This task monitors the current active read request. If the current read
240 // request has timed out, this task will destroy the current loader and 242 // request has timed out, this task will destroy the current loader and
241 // creates a new to accomodate the read request. 243 // creates a new to accomodate the read request.
242 void WatchDogTask(); 244 void WatchDogTask();
243 245
244 // The method that performs actual read. This method can only be executed on 246 // The method that performs actual read. This method can only be executed on
245 // the render thread. 247 // the render thread.
246 void ReadInternal(); 248 void ReadInternal();
247 249
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 int64 total_bytes_; 284 int64 total_bytes_;
283 285
284 // This value will be true if this data source can only support streaming. 286 // This value will be true if this data source can only support streaming.
285 // i.e. range request is not supported. 287 // i.e. range request is not supported.
286 bool streaming_; 288 bool streaming_;
287 289
288 // A factory object to produce ResourceLoaderBridge. 290 // A factory object to produce ResourceLoaderBridge.
289 scoped_ptr<webkit_glue::MediaResourceLoaderBridgeFactory> bridge_factory_; 291 scoped_ptr<webkit_glue::MediaResourceLoaderBridgeFactory> bridge_factory_;
290 292
291 // A resource loader for the media resource. 293 // A resource loader for the media resource.
292 scoped_ptr<BufferedResourceLoader> loader_; 294 scoped_refptr<BufferedResourceLoader> loader_;
293 295
294 // A resource loader that probes the server's ability to serve range requests. 296 // A resource loader that probes the server's ability to serve range requests.
295 scoped_ptr<BufferedResourceLoader> probe_loader_; 297 scoped_refptr<BufferedResourceLoader> probe_loader_;
296 298
297 // Callback method from the pipeline for initialization. 299 // Callback method from the pipeline for initialization.
298 scoped_ptr<media::FilterCallback> initialize_callback_; 300 scoped_ptr<media::FilterCallback> initialize_callback_;
299 301
300 // Read parameters received from the Read() method call. 302 // Read parameters received from the Read() method call.
301 scoped_ptr<media::DataSource::ReadCallback> read_callback_; 303 scoped_ptr<media::DataSource::ReadCallback> read_callback_;
302 int64 read_position_; 304 int64 read_position_;
303 int read_size_; 305 int read_size_;
304 uint8* read_buffer_; 306 uint8* read_buffer_;
305 base::Time read_submitted_time_; 307 base::Time read_submitted_time_;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 // loop. The RepeatingTimer does PostDelayedTask() internally, by using it 345 // loop. The RepeatingTimer does PostDelayedTask() internally, by using it
344 // the message loop doesn't hold a reference for the watch dog task. 346 // the message loop doesn't hold a reference for the watch dog task.
345 base::RepeatingTimer<BufferedDataSource> watch_dog_timer_; 347 base::RepeatingTimer<BufferedDataSource> watch_dog_timer_;
346 348
347 DISALLOW_COPY_AND_ASSIGN(BufferedDataSource); 349 DISALLOW_COPY_AND_ASSIGN(BufferedDataSource);
348 }; 350 };
349 351
350 } // namespace webkit_glue 352 } // namespace webkit_glue
351 353
352 #endif // WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_H_ 354 #endif // WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_H_
OLDNEW
« no previous file with comments | « no previous file | webkit/glue/media/buffered_data_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698