OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_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/callback.h" | 10 #include "base/callback.h" |
11 #include "base/lock.h" | |
12 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| 12 #include "base/synchronization/lock.h" |
13 #include "webkit/glue/media/buffered_resource_loader.h" | 13 #include "webkit/glue/media/buffered_resource_loader.h" |
14 | 14 |
15 namespace webkit_glue { | 15 namespace webkit_glue { |
16 | 16 |
17 class BufferedDataSource : public WebDataSource { | 17 class BufferedDataSource : public WebDataSource { |
18 public: | 18 public: |
19 BufferedDataSource(MessageLoop* render_loop, | 19 BufferedDataSource(MessageLoop* render_loop, |
20 WebKit::WebFrame* frame); | 20 WebKit::WebFrame* frame); |
21 | 21 |
22 virtual ~BufferedDataSource(); | 22 virtual ~BufferedDataSource(); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 // because we want buffer to be passed into BufferedResourceLoader to be | 168 // because we want buffer to be passed into BufferedResourceLoader to be |
169 // always non-null. And by initializing this member with a default size we can | 169 // always non-null. And by initializing this member with a default size we can |
170 // avoid creating zero-sized buffered if the first read has zero size. | 170 // avoid creating zero-sized buffered if the first read has zero size. |
171 scoped_array<uint8> intermediate_read_buffer_; | 171 scoped_array<uint8> intermediate_read_buffer_; |
172 int intermediate_read_buffer_size_; | 172 int intermediate_read_buffer_size_; |
173 | 173 |
174 // The message loop of the render thread. | 174 // The message loop of the render thread. |
175 MessageLoop* render_loop_; | 175 MessageLoop* render_loop_; |
176 | 176 |
177 // Protects |stopped_|. | 177 // Protects |stopped_|. |
178 Lock lock_; | 178 base::Lock lock_; |
179 | 179 |
180 // Stop signal to suppressing activities. This variable is set on the pipeline | 180 // Stop signal to suppressing activities. This variable is set on the pipeline |
181 // thread and read from the render thread. | 181 // thread and read from the render thread. |
182 bool stop_signal_received_; | 182 bool stop_signal_received_; |
183 | 183 |
184 // This variable is set by CleanupTask() that indicates this object is stopped | 184 // This variable is set by CleanupTask() that indicates this object is stopped |
185 // on the render thread and work should no longer progress. | 185 // on the render thread and work should no longer progress. |
186 bool stopped_on_render_loop_; | 186 bool stopped_on_render_loop_; |
187 | 187 |
188 // This variable is true when we are in a paused state and false when we | 188 // This variable is true when we are in a paused state and false when we |
189 // are in a playing state. | 189 // are in a playing state. |
190 bool media_is_paused_; | 190 bool media_is_paused_; |
191 | 191 |
192 // This timer is to run the WatchDogTask repeatedly. We use a timer instead | 192 // This timer is to run the WatchDogTask repeatedly. We use a timer instead |
193 // of doing PostDelayedTask() reduce the extra reference held by the message | 193 // of doing PostDelayedTask() reduce the extra reference held by the message |
194 // loop. The RepeatingTimer does PostDelayedTask() internally, by using it | 194 // loop. The RepeatingTimer does PostDelayedTask() internally, by using it |
195 // the message loop doesn't hold a reference for the watch dog task. | 195 // the message loop doesn't hold a reference for the watch dog task. |
196 base::RepeatingTimer<BufferedDataSource> watch_dog_timer_; | 196 base::RepeatingTimer<BufferedDataSource> watch_dog_timer_; |
197 | 197 |
198 // Keeps track of whether we used a Range header in the initialization | 198 // Keeps track of whether we used a Range header in the initialization |
199 // request. | 199 // request. |
200 bool using_range_request_; | 200 bool using_range_request_; |
201 | 201 |
202 DISALLOW_COPY_AND_ASSIGN(BufferedDataSource); | 202 DISALLOW_COPY_AND_ASSIGN(BufferedDataSource); |
203 }; | 203 }; |
204 | 204 |
205 } // namespace webkit_glue | 205 } // namespace webkit_glue |
206 | 206 |
207 #endif // WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_H_ | 207 #endif // WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_H_ |
OLD | NEW |