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

Unified Diff: webkit/glue/media/buffered_data_source.h

Issue 159382: Retry requests that has timed out in BufferedDataSource (Closed)
Patch Set: done again Created 11 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webkit/glue/media/buffered_data_source.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/media/buffered_data_source.h
diff --git a/webkit/glue/media/buffered_data_source.h b/webkit/glue/media/buffered_data_source.h
index 5d6f1c321ec314d4d4804ac913846e828eccb471..0e1df1ca373a4feda16586f283cea9c848b217b6 100644
--- a/webkit/glue/media/buffered_data_source.h
+++ b/webkit/glue/media/buffered_data_source.h
@@ -9,6 +9,7 @@
#include "base/lock.h"
#include "base/scoped_ptr.h"
+#include "base/timer.h"
#include "base/condition_variable.h"
#include "googleurl/src/gurl.h"
#include "media/base/factory.h"
@@ -183,6 +184,11 @@ class BufferedDataSource : public media::DataSource {
virtual BufferedResourceLoader* CreateLoader(int64 first_byte_position,
int64 last_byte_position);
+ // Gets the number of milliseconds to declare a request timeout since
+ // the request was made. This method is made virtual so as to inject a
+ // different number for testing purpose.
+ virtual base::TimeDelta GetTimeoutMilliseconds();
+
private:
friend class media::FilterFactoryImpl2<
BufferedDataSource,
@@ -205,6 +211,11 @@ class BufferedDataSource : public media::DataSource {
// callback method from the current buffered resource loader.
void SwapLoaderTask(BufferedResourceLoader* loader);
+ // This task monitors the current active read request. If the current read
+ // request has timed out, this task will destroy the current loader and
+ // creates a new to accomodate the read request.
+ void WatchDogTask();
+
// The method that performs actual read. This method can only be executed on
// the render thread.
void ReadInternal();
@@ -252,6 +263,8 @@ class BufferedDataSource : public media::DataSource {
int64 read_position_;
int read_size_;
uint8* read_buffer_;
+ base::Time read_submitted_time_;
+ int read_attempts_;
// This buffer is intermediate, we use it for BufferedResourceLoader to write
// to. And when read in BufferedResourceLoader is done, we copy data from
@@ -278,6 +291,12 @@ class BufferedDataSource : public media::DataSource {
// Stop signal to suppressing activities.
bool stopped_;
+ // This timer is to run the WatchDogTask repeatedly. We use a timer instead
+ // of doing PostDelayedTask() reduce the extra reference held by the message
+ // loop. The RepeatingTimer does PostDelayedTask() internally, by using it
+ // the message loop doesn't hold a reference for the watch dog task.
+ base::RepeatingTimer<BufferedDataSource> watch_dog_timer_;
+
DISALLOW_COPY_AND_ASSIGN(BufferedDataSource);
};
« 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