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

Unified Diff: webkit/media/active_loader.h

Issue 8667002: Split a portion of BufferedResourceLoader into a separate class ActiveLoader. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: ntis Created 9 years, 1 month 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
Index: webkit/media/active_loader.h
diff --git a/webkit/media/active_loader.h b/webkit/media/active_loader.h
new file mode 100644
index 0000000000000000000000000000000000000000..51881c37b3fb2cfe6567407b2ebeb834032acde0
--- /dev/null
+++ b/webkit/media/active_loader.h
@@ -0,0 +1,51 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_MEDIA_ACTIVE_LOADER_H_
+#define WEBKIT_MEDIA_ACTIVE_LOADER_H_
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+
+namespace WebKit {
+class WebURLLoader;
+}
+
+namespace webkit_media {
+
+class BufferedResourceLoader;
+
+// Wraps an active WebURLLoader with some additional state and maintains a
+// reference to its parent.
+//
+// Handles deferring and cancellation of loaders upon deletion.
+class ActiveLoader {
+ public:
+ // Creates an ActiveLoader with a reference to its parent. The initial state
+ // assumes that the loader has started loading and has not been deferred.
+ //
+ // ActiveLoader takes ownership of |loader|.
+ ActiveLoader(const scoped_refptr<BufferedResourceLoader>& parent,
+ WebKit::WebURLLoader* loader);
+ ~ActiveLoader();
+
+ // Starts or stops deferring the resource load.
+ void SetDeferred(bool deferred);
+
+ bool deferred() { return deferred_; }
+
+ private:
+ friend class BufferedDataSourceTest;
+
+ scoped_refptr<BufferedResourceLoader> parent_;
+ scoped_ptr<WebKit::WebURLLoader> loader_;
+ bool deferred_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(ActiveLoader);
+};
+
+} // namespace webkit_media
+
+#endif // WEBKIT_MEDIA_ACTIVE_LOADER_H_

Powered by Google App Engine
This is Rietveld 408576698