| 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 // An extremely simple implementation of DataSource that downloads the entire | 5 // An extremely simple implementation of DataSource that downloads the entire |
| 6 // media resource into memory before signaling that initialization has finished. | 6 // media resource into memory before signaling that initialization has finished. |
| 7 // Primarily used to test <audio> and <video> with buffering/caching removed | 7 // Primarily used to test <audio> and <video> with buffering/caching removed |
| 8 // from the equation. | 8 // from the equation. |
| 9 | 9 |
| 10 #ifndef WEBKIT_MEDIA_SIMPLE_DATA_SOURCE_H_ | 10 #ifndef WEBKIT_MEDIA_SIMPLE_DATA_SOURCE_H_ |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 // media::DataSource implementation. | 53 // media::DataSource implementation. |
| 54 virtual void Read(int64 position, | 54 virtual void Read(int64 position, |
| 55 size_t size, | 55 size_t size, |
| 56 uint8* data, | 56 uint8* data, |
| 57 const DataSource::ReadCallback& read_callback) OVERRIDE; | 57 const DataSource::ReadCallback& read_callback) OVERRIDE; |
| 58 virtual bool GetSize(int64* size_out) OVERRIDE; | 58 virtual bool GetSize(int64* size_out) OVERRIDE; |
| 59 virtual bool IsStreaming() OVERRIDE; | 59 virtual bool IsStreaming() OVERRIDE; |
| 60 virtual void SetPreload(media::Preload preload) OVERRIDE; | 60 virtual void SetPreload(media::Preload preload) OVERRIDE; |
| 61 virtual void SetBitrate(int bitrate) OVERRIDE; | 61 virtual void SetBitrate(int bitrate) OVERRIDE; |
| 62 virtual bool IsLocalSource() OVERRIDE; |
| 62 | 63 |
| 63 // Used to inject a mock used for unittests. | 64 // Used to inject a mock used for unittests. |
| 64 virtual void SetURLLoaderForTest(WebKit::WebURLLoader* mock_loader); | 65 virtual void SetURLLoaderForTest(WebKit::WebURLLoader* mock_loader); |
| 65 | 66 |
| 66 // WebKit::WebURLLoaderClient implementations. | 67 // WebKit::WebURLLoaderClient implementations. |
| 67 virtual void willSendRequest( | 68 virtual void willSendRequest( |
| 68 WebKit::WebURLLoader* loader, | 69 WebKit::WebURLLoader* loader, |
| 69 WebKit::WebURLRequest& newRequest, | 70 WebKit::WebURLRequest& newRequest, |
| 70 const WebKit::WebURLResponse& redirectResponse); | 71 const WebKit::WebURLResponse& redirectResponse); |
| 71 virtual void didSendData( | 72 virtual void didSendData( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 // A webframe for loading. | 120 // A webframe for loading. |
| 120 WebKit::WebFrame* frame_; | 121 WebKit::WebFrame* frame_; |
| 121 | 122 |
| 122 // Does the work of loading and sends data back to this client. | 123 // Does the work of loading and sends data back to this client. |
| 123 scoped_ptr<WebKit::WebURLLoader> url_loader_; | 124 scoped_ptr<WebKit::WebURLLoader> url_loader_; |
| 124 | 125 |
| 125 GURL url_; | 126 GURL url_; |
| 126 std::string data_; | 127 std::string data_; |
| 127 int64 size_; | 128 int64 size_; |
| 128 bool single_origin_; | 129 bool single_origin_; |
| 130 bool local_source_; |
| 129 | 131 |
| 130 // Simple state tracking variable. | 132 // Simple state tracking variable. |
| 131 enum State { | 133 enum State { |
| 132 UNINITIALIZED, | 134 UNINITIALIZED, |
| 133 INITIALIZING, | 135 INITIALIZING, |
| 134 INITIALIZED, | 136 INITIALIZED, |
| 135 STOPPED, | 137 STOPPED, |
| 136 }; | 138 }; |
| 137 State state_; | 139 State state_; |
| 138 | 140 |
| 139 // Used for accessing |state_|. | 141 // Used for accessing |state_|. |
| 140 base::Lock lock_; | 142 base::Lock lock_; |
| 141 | 143 |
| 142 // Filter callbacks. | 144 // Filter callbacks. |
| 143 media::PipelineStatusCB initialize_cb_; | 145 media::PipelineStatusCB initialize_cb_; |
| 144 | 146 |
| 145 // Used to ensure mocks for unittests are used instead of reset in Start(). | 147 // Used to ensure mocks for unittests are used instead of reset in Start(). |
| 146 bool keep_test_loader_; | 148 bool keep_test_loader_; |
| 147 | 149 |
| 148 DISALLOW_COPY_AND_ASSIGN(SimpleDataSource); | 150 DISALLOW_COPY_AND_ASSIGN(SimpleDataSource); |
| 149 }; | 151 }; |
| 150 | 152 |
| 151 } // namespace webkit_media | 153 } // namespace webkit_media |
| 152 | 154 |
| 153 #endif // WEBKIT_MEDIA_SIMPLE_DATA_SOURCE_H_ | 155 #endif // WEBKIT_MEDIA_SIMPLE_DATA_SOURCE_H_ |
| OLD | NEW |