| 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 MEDIA_BASE_MOCK_READER_H_ | 5 #ifndef MEDIA_BASE_MOCK_READER_H_ |
| 6 #define MEDIA_BASE_MOCK_READER_H_ | 6 #define MEDIA_BASE_MOCK_READER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 expecting_call_ = true; | 43 expecting_call_ = true; |
| 44 filter->Read(base::Bind(&MockReader::OnReadComplete, this)); | 44 filter->Read(base::Bind(&MockReader::OnReadComplete, this)); |
| 45 } | 45 } |
| 46 | 46 |
| 47 // Mock accessors. | 47 // Mock accessors. |
| 48 BufferType* buffer() { return buffer_; } | 48 BufferType* buffer() { return buffer_; } |
| 49 bool called() { return called_; } | 49 bool called() { return called_; } |
| 50 bool expecting_call() { return expecting_call_; } | 50 bool expecting_call() { return expecting_call_; } |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 void OnReadComplete(BufferType* buffer) { | 53 void OnReadComplete(const scoped_refptr<BufferType>& buffer) { |
| 54 DCHECK(!called_); | 54 DCHECK(!called_); |
| 55 DCHECK(expecting_call_); | 55 DCHECK(expecting_call_); |
| 56 expecting_call_ = false; | 56 expecting_call_ = false; |
| 57 called_ = true; | 57 called_ = true; |
| 58 buffer_ = buffer; | 58 buffer_ = buffer; |
| 59 } | 59 } |
| 60 | 60 |
| 61 // Reference to the buffer provided in the callback. | 61 // Reference to the buffer provided in the callback. |
| 62 scoped_refptr<BufferType> buffer_; | 62 scoped_refptr<BufferType> buffer_; |
| 63 | 63 |
| 64 // Whether or not the callback was executed. | 64 // Whether or not the callback was executed. |
| 65 bool called_; | 65 bool called_; |
| 66 | 66 |
| 67 // Whether or not this reader was expecting a callback. | 67 // Whether or not this reader was expecting a callback. |
| 68 bool expecting_call_; | 68 bool expecting_call_; |
| 69 | 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(MockReader); | 70 DISALLOW_COPY_AND_ASSIGN(MockReader); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 // Commonly used reader types. | 73 // Commonly used reader types. |
| 74 typedef MockReader<DemuxerStream, Buffer> DemuxerStreamReader; | 74 typedef MockReader<DemuxerStream, Buffer> DemuxerStreamReader; |
| 75 | 75 |
| 76 } // namespace media | 76 } // namespace media |
| 77 | 77 |
| 78 #endif // MEDIA_BASE_MOCK_READER_H_ | 78 #endif // MEDIA_BASE_MOCK_READER_H_ |
| OLD | NEW |