OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 MEDIA_BLINK_BUFFERED_DATA_SOURCE_H_ | 5 #ifndef MEDIA_BLINK_BUFFERED_DATA_SOURCE_H_ |
6 #define MEDIA_BLINK_BUFFERED_DATA_SOURCE_H_ | 6 #define MEDIA_BLINK_BUFFERED_DATA_SOURCE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
| 9 #include <vector> |
9 | 10 |
10 #include "base/callback.h" | 11 #include "base/callback.h" |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
13 #include "media/base/data_source.h" | 14 #include "media/base/data_source.h" |
14 #include "media/base/media_export.h" | 15 #include "media/base/media_export.h" |
15 #include "media/base/ranges.h" | 16 #include "media/base/ranges.h" |
16 #include "media/blink/buffered_resource_loader.h" | 17 #include "media/blink/buffered_resource_loader.h" |
17 #include "url/gurl.h" | 18 #include "url/gurl.h" |
18 | 19 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // This buffer is intermediate, we use it for BufferedResourceLoader to write | 190 // This buffer is intermediate, we use it for BufferedResourceLoader to write |
190 // to. And when read in BufferedResourceLoader is done, we copy data from | 191 // to. And when read in BufferedResourceLoader is done, we copy data from |
191 // this buffer to |read_buffer_|. The reason for an additional copy is that | 192 // this buffer to |read_buffer_|. The reason for an additional copy is that |
192 // we don't own |read_buffer_|. But since the read operation is asynchronous, | 193 // we don't own |read_buffer_|. But since the read operation is asynchronous, |
193 // |read_buffer| can be destroyed at any time, so we only copy into | 194 // |read_buffer| can be destroyed at any time, so we only copy into |
194 // |read_buffer| in the final step when it is safe. | 195 // |read_buffer| in the final step when it is safe. |
195 // Memory is allocated for this member during initialization of this object | 196 // Memory is allocated for this member during initialization of this object |
196 // because we want buffer to be passed into BufferedResourceLoader to be | 197 // because we want buffer to be passed into BufferedResourceLoader to be |
197 // always non-null. And by initializing this member with a default size we can | 198 // always non-null. And by initializing this member with a default size we can |
198 // avoid creating zero-sized buffered if the first read has zero size. | 199 // avoid creating zero-sized buffered if the first read has zero size. |
199 scoped_ptr<uint8[]> intermediate_read_buffer_; | 200 std::vector<uint8> intermediate_read_buffer_; |
200 int intermediate_read_buffer_size_; | |
201 | 201 |
202 // The task runner of the render thread. | 202 // The task runner of the render thread. |
203 const scoped_refptr<base::SingleThreadTaskRunner> render_task_runner_; | 203 const scoped_refptr<base::SingleThreadTaskRunner> render_task_runner_; |
204 | 204 |
205 // Protects |stop_signal_received_| and |read_op_|. | 205 // Protects |stop_signal_received_| and |read_op_|. |
206 base::Lock lock_; | 206 base::Lock lock_; |
207 | 207 |
208 // Whether we've been told to stop via Abort() or Stop(). | 208 // Whether we've been told to stop via Abort() or Stop(). |
209 bool stop_signal_received_; | 209 bool stop_signal_received_; |
210 | 210 |
(...skipping 20 matching lines...) Expand all Loading... |
231 | 231 |
232 // NOTE: Weak pointers must be invalidated before all other member variables. | 232 // NOTE: Weak pointers must be invalidated before all other member variables. |
233 base::WeakPtrFactory<BufferedDataSource> weak_factory_; | 233 base::WeakPtrFactory<BufferedDataSource> weak_factory_; |
234 | 234 |
235 DISALLOW_COPY_AND_ASSIGN(BufferedDataSource); | 235 DISALLOW_COPY_AND_ASSIGN(BufferedDataSource); |
236 }; | 236 }; |
237 | 237 |
238 } // namespace media | 238 } // namespace media |
239 | 239 |
240 #endif // MEDIA_BLINK_BUFFERED_DATA_SOURCE_H_ | 240 #endif // MEDIA_BLINK_BUFFERED_DATA_SOURCE_H_ |
OLD | NEW |