| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_FILTERS_BLOCKING_URL_PROTOCOL_H_ | 5 #ifndef MEDIA_FILTERS_BLOCKING_URL_PROTOCOL_H_ |
| 6 #define MEDIA_FILTERS_BLOCKING_URL_PROTOCOL_H_ | 6 #define MEDIA_FILTERS_BLOCKING_URL_PROTOCOL_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // TODO(scherkus): After all blocking operations are isolated on a separate | 24 // TODO(scherkus): After all blocking operations are isolated on a separate |
| 25 // thread we should be able to eliminate |error_cb|. | 25 // thread we should be able to eliminate |error_cb|. |
| 26 BlockingUrlProtocol(DataSource* data_source, const base::Closure& error_cb); | 26 BlockingUrlProtocol(DataSource* data_source, const base::Closure& error_cb); |
| 27 virtual ~BlockingUrlProtocol(); | 27 virtual ~BlockingUrlProtocol(); |
| 28 | 28 |
| 29 // Aborts any pending reads by returning a read error. After this method | 29 // Aborts any pending reads by returning a read error. After this method |
| 30 // returns all subsequent calls to Read() will immediately fail. | 30 // returns all subsequent calls to Read() will immediately fail. |
| 31 void Abort(); | 31 void Abort(); |
| 32 | 32 |
| 33 // FFmpegURLProtocol implementation. | 33 // FFmpegURLProtocol implementation. |
| 34 virtual int Read(int size, uint8* data) OVERRIDE; | 34 virtual int Read(int size, uint8* data) override; |
| 35 virtual bool GetPosition(int64* position_out) OVERRIDE; | 35 virtual bool GetPosition(int64* position_out) override; |
| 36 virtual bool SetPosition(int64 position) OVERRIDE; | 36 virtual bool SetPosition(int64 position) override; |
| 37 virtual bool GetSize(int64* size_out) OVERRIDE; | 37 virtual bool GetSize(int64* size_out) override; |
| 38 virtual bool IsStreaming() OVERRIDE; | 38 virtual bool IsStreaming() override; |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 // Sets |last_read_bytes_| and signals the blocked thread that the read | 41 // Sets |last_read_bytes_| and signals the blocked thread that the read |
| 42 // has completed. | 42 // has completed. |
| 43 void SignalReadCompleted(int size); | 43 void SignalReadCompleted(int size); |
| 44 | 44 |
| 45 DataSource* data_source_; | 45 DataSource* data_source_; |
| 46 base::Closure error_cb_; | 46 base::Closure error_cb_; |
| 47 | 47 |
| 48 // Used to unblock the thread during shutdown and when reads complete. | 48 // Used to unblock the thread during shutdown and when reads complete. |
| 49 base::WaitableEvent aborted_; | 49 base::WaitableEvent aborted_; |
| 50 base::WaitableEvent read_complete_; | 50 base::WaitableEvent read_complete_; |
| 51 | 51 |
| 52 // Cached number of bytes last read from the data source. | 52 // Cached number of bytes last read from the data source. |
| 53 int last_read_bytes_; | 53 int last_read_bytes_; |
| 54 | 54 |
| 55 // Cached position within the data source. | 55 // Cached position within the data source. |
| 56 int64 read_position_; | 56 int64 read_position_; |
| 57 | 57 |
| 58 DISALLOW_IMPLICIT_CONSTRUCTORS(BlockingUrlProtocol); | 58 DISALLOW_IMPLICIT_CONSTRUCTORS(BlockingUrlProtocol); |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 } // namespace media | 61 } // namespace media |
| 62 | 62 |
| 63 #endif // MEDIA_FILTERS_BLOCKING_URL_PROTOCOL_H_ | 63 #endif // MEDIA_FILTERS_BLOCKING_URL_PROTOCOL_H_ |
| OLD | NEW |