| 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_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" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 // Called from demuxer thread. | 38 // Called from demuxer thread. |
| 39 virtual void Read(int64 position, size_t size, | 39 virtual void Read(int64 position, size_t size, |
| 40 uint8* data, | 40 uint8* data, |
| 41 media::DataSource::ReadCallback* read_callback); | 41 media::DataSource::ReadCallback* read_callback); |
| 42 virtual bool GetSize(int64* size_out); | 42 virtual bool GetSize(int64* size_out); |
| 43 virtual bool IsStreaming(); | 43 virtual bool IsStreaming(); |
| 44 virtual void SetPreload(media::Preload preload); | 44 virtual void SetPreload(media::Preload preload); |
| 45 | 45 |
| 46 // webkit_glue::WebDataSource implementation. | 46 // webkit_glue::WebDataSource implementation. |
| 47 virtual void Initialize(const std::string& url, | 47 virtual void Initialize(const std::string& url, |
| 48 media::PipelineStatusCallback* callback); | 48 const media::PipelineStatusCB& callback); |
| 49 virtual void CancelInitialize(); | 49 virtual void CancelInitialize(); |
| 50 virtual bool HasSingleOrigin(); | 50 virtual bool HasSingleOrigin(); |
| 51 virtual void Abort(); | 51 virtual void Abort(); |
| 52 | 52 |
| 53 protected: | 53 protected: |
| 54 // A factory method to create a BufferedResourceLoader based on the read | 54 // A factory method to create a BufferedResourceLoader based on the read |
| 55 // parameters. We can override this file to object a mock | 55 // parameters. We can override this file to object a mock |
| 56 // BufferedResourceLoader for testing. | 56 // BufferedResourceLoader for testing. |
| 57 virtual BufferedResourceLoader* CreateResourceLoader( | 57 virtual BufferedResourceLoader* CreateResourceLoader( |
| 58 int64 first_byte_position, int64 last_byte_position); | 58 int64 first_byte_position, int64 last_byte_position); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 85 // BufferedDataSource. | 85 // BufferedDataSource. |
| 86 BufferedResourceLoader::DeferStrategy ChooseDeferStrategy(); | 86 BufferedResourceLoader::DeferStrategy ChooseDeferStrategy(); |
| 87 | 87 |
| 88 // The method that performs actual read. This method can only be executed on | 88 // The method that performs actual read. This method can only be executed on |
| 89 // the render thread. | 89 // the render thread. |
| 90 void ReadInternal(); | 90 void ReadInternal(); |
| 91 | 91 |
| 92 // Calls |read_callback_| and reset all read parameters. | 92 // Calls |read_callback_| and reset all read parameters. |
| 93 void DoneRead_Locked(int error); | 93 void DoneRead_Locked(int error); |
| 94 | 94 |
| 95 // Calls |initialize_callback_| and reset it. | 95 // Calls |initialize_cb_| and reset it. |
| 96 void DoneInitialization_Locked(media::PipelineStatus status); | 96 void DoneInitialization_Locked(media::PipelineStatus status); |
| 97 | 97 |
| 98 // Callback method for |loader_| if URL for the resource requested is using | 98 // Callback method for |loader_| if URL for the resource requested is using |
| 99 // HTTP protocol. This method is called when response for initial request is | 99 // HTTP protocol. This method is called when response for initial request is |
| 100 // received. | 100 // received. |
| 101 void HttpInitialStartCallback(int error); | 101 void HttpInitialStartCallback(int error); |
| 102 | 102 |
| 103 // Callback method for |loader_| if URL for the resource requested is using | 103 // Callback method for |loader_| if URL for the resource requested is using |
| 104 // a non-HTTP protocol, e.g. local files. This method is called when response | 104 // a non-HTTP protocol, e.g. local files. This method is called when response |
| 105 // for initial request is received. | 105 // for initial request is received. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // A webframe for loading. | 141 // A webframe for loading. |
| 142 WebKit::WebFrame* frame_; | 142 WebKit::WebFrame* frame_; |
| 143 | 143 |
| 144 // A resource loader for the media resource. | 144 // A resource loader for the media resource. |
| 145 scoped_refptr<BufferedResourceLoader> loader_; | 145 scoped_refptr<BufferedResourceLoader> loader_; |
| 146 | 146 |
| 147 // True if network is active. | 147 // True if network is active. |
| 148 bool network_activity_; | 148 bool network_activity_; |
| 149 | 149 |
| 150 // Callback method from the pipeline for initialization. | 150 // Callback method from the pipeline for initialization. |
| 151 scoped_ptr<media::PipelineStatusCallback> initialize_callback_; | 151 media::PipelineStatusCB initialize_cb_; |
| 152 | 152 |
| 153 // Read parameters received from the Read() method call. | 153 // Read parameters received from the Read() method call. |
| 154 scoped_ptr<media::DataSource::ReadCallback> read_callback_; | 154 scoped_ptr<media::DataSource::ReadCallback> read_callback_; |
| 155 int64 read_position_; | 155 int64 read_position_; |
| 156 int read_size_; | 156 int read_size_; |
| 157 uint8* read_buffer_; | 157 uint8* read_buffer_; |
| 158 | 158 |
| 159 // This buffer is intermediate, we use it for BufferedResourceLoader to write | 159 // This buffer is intermediate, we use it for BufferedResourceLoader to write |
| 160 // to. And when read in BufferedResourceLoader is done, we copy data from | 160 // to. And when read in BufferedResourceLoader is done, we copy data from |
| 161 // this buffer to |read_buffer_|. The reason for an additional copy is that | 161 // this buffer to |read_buffer_|. The reason for an additional copy is that |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 201 |
| 202 // Number of cache miss retries left. | 202 // Number of cache miss retries left. |
| 203 int cache_miss_retries_left_; | 203 int cache_miss_retries_left_; |
| 204 | 204 |
| 205 DISALLOW_COPY_AND_ASSIGN(BufferedDataSource); | 205 DISALLOW_COPY_AND_ASSIGN(BufferedDataSource); |
| 206 }; | 206 }; |
| 207 | 207 |
| 208 } // namespace webkit_glue | 208 } // namespace webkit_glue |
| 209 | 209 |
| 210 #endif // WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_H_ | 210 #endif // WEBKIT_GLUE_MEDIA_BUFFERED_DATA_SOURCE_H_ |
| OLD | NEW |