| 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_MEDIA_ACTIVE_LOADER_H_ | 5 #ifndef WEBKIT_MEDIA_ACTIVE_LOADER_H_ |
| 6 #define WEBKIT_MEDIA_ACTIVE_LOADER_H_ | 6 #define WEBKIT_MEDIA_ACTIVE_LOADER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 | 10 |
| 11 namespace WebKit { | 11 namespace WebKit { |
| 12 class WebURLLoader; | 12 class WebURLLoader; |
| 13 } | 13 } |
| 14 | 14 |
| 15 namespace webkit_media { | 15 namespace webkit_media { |
| 16 | 16 |
| 17 // Wraps an active WebURLLoader with some additional state. | 17 // Wraps an active WebURLLoader with some additional state. |
| 18 // | 18 // |
| 19 // Handles deferring and deletion of loaders. | 19 // Handles deferring and deletion of loaders. |
| 20 class ActiveLoader { | 20 class ActiveLoader { |
| 21 public: | 21 public: |
| 22 // Creates an ActiveLoader with the given loader. It is assumed that the | 22 // Creates an ActiveLoader with the given loader. It is assumed that the |
| 23 // initial state of |loader| is loading and not deferred. | 23 // initial state of |loader| is loading and not deferred. |
| 24 // | 24 explicit ActiveLoader(scoped_ptr<WebKit::WebURLLoader> loader); |
| 25 // ActiveLoader takes ownership of |loader|. | |
| 26 explicit ActiveLoader(WebKit::WebURLLoader* loader); | |
| 27 ~ActiveLoader(); | 25 ~ActiveLoader(); |
| 28 | 26 |
| 29 // Starts or stops deferring the resource load. | 27 // Starts or stops deferring the resource load. |
| 30 void SetDeferred(bool deferred); | 28 void SetDeferred(bool deferred); |
| 31 bool deferred() { return deferred_; } | 29 bool deferred() { return deferred_; } |
| 32 | 30 |
| 33 // Cancels the URL loader associated with this object. | 31 // Cancels the URL loader associated with this object. |
| 34 void Cancel(); | 32 void Cancel(); |
| 35 | 33 |
| 36 private: | 34 private: |
| 37 friend class BufferedDataSourceTest; | 35 friend class BufferedDataSourceTest; |
| 38 | 36 |
| 39 scoped_ptr<WebKit::WebURLLoader> loader_; | 37 scoped_ptr<WebKit::WebURLLoader> loader_; |
| 40 bool deferred_; | 38 bool deferred_; |
| 41 | 39 |
| 42 DISALLOW_IMPLICIT_CONSTRUCTORS(ActiveLoader); | 40 DISALLOW_IMPLICIT_CONSTRUCTORS(ActiveLoader); |
| 43 }; | 41 }; |
| 44 | 42 |
| 45 } // namespace webkit_media | 43 } // namespace webkit_media |
| 46 | 44 |
| 47 #endif // WEBKIT_MEDIA_ACTIVE_LOADER_H_ | 45 #endif // WEBKIT_MEDIA_ACTIVE_LOADER_H_ |
| OLD | NEW |