| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CHROME_UTILITY_MEDIA_GALLERIES_IPC_DATA_SOURCE_H_ | 5 #ifndef CHROME_UTILITY_MEDIA_GALLERIES_IPC_DATA_SOURCE_H_ |
| 6 #define CHROME_UTILITY_MEDIA_GALLERIES_IPC_DATA_SOURCE_H_ | 6 #define CHROME_UTILITY_MEDIA_GALLERIES_IPC_DATA_SOURCE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 // Provides the metadata parser with bytes from the browser process via IPC. | 22 // Provides the metadata parser with bytes from the browser process via IPC. |
| 23 // Class must be created and destroyed on the utility thread. Class may be used | 23 // Class must be created and destroyed on the utility thread. Class may be used |
| 24 // as a DataSource on a different thread. The utility thread must not be blocked | 24 // as a DataSource on a different thread. The utility thread must not be blocked |
| 25 // for read operations to succeed. | 25 // for read operations to succeed. |
| 26 class IPCDataSource: public media::DataSource, | 26 class IPCDataSource: public media::DataSource, |
| 27 public UtilityMessageHandler { | 27 public UtilityMessageHandler { |
| 28 public: | 28 public: |
| 29 // May only be called on the utility thread. | 29 // May only be called on the utility thread. |
| 30 explicit IPCDataSource(int64 total_size); | 30 explicit IPCDataSource(int64 total_size); |
| 31 virtual ~IPCDataSource(); | 31 ~IPCDataSource() override; |
| 32 | 32 |
| 33 // Implementation of DataSource. These methods may be called on any single | 33 // Implementation of DataSource. These methods may be called on any single |
| 34 // thread. First usage of these methods attaches a thread checker. | 34 // thread. First usage of these methods attaches a thread checker. |
| 35 virtual void Stop() override; | 35 void Stop() override; |
| 36 virtual void Read(int64 position, int size, uint8* data, | 36 void Read(int64 position, |
| 37 const ReadCB& read_cb) override; | 37 int size, |
| 38 virtual bool GetSize(int64* size_out) override; | 38 uint8* data, |
| 39 virtual bool IsStreaming() override; | 39 const ReadCB& read_cb) override; |
| 40 virtual void SetBitrate(int bitrate) override; | 40 bool GetSize(int64* size_out) override; |
| 41 bool IsStreaming() override; |
| 42 void SetBitrate(int bitrate) override; |
| 41 | 43 |
| 42 // Implementation of UtilityMessageHandler. May only be called on the utility | 44 // Implementation of UtilityMessageHandler. May only be called on the utility |
| 43 // thread. | 45 // thread. |
| 44 virtual bool OnMessageReceived(const IPC::Message& message) override; | 46 bool OnMessageReceived(const IPC::Message& message) override; |
| 45 | 47 |
| 46 private: | 48 private: |
| 47 struct Request { | 49 struct Request { |
| 48 Request(); | 50 Request(); |
| 49 ~Request(); | 51 ~Request(); |
| 50 uint8* destination; | 52 uint8* destination; |
| 51 ReadCB callback; | 53 ReadCB callback; |
| 52 }; | 54 }; |
| 53 | 55 |
| 54 void ReadOnUtilityThread(int64 position, int size, uint8* data, | 56 void ReadOnUtilityThread(int64 position, int size, uint8* data, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 65 | 67 |
| 66 base::ThreadChecker utility_thread_checker_; | 68 base::ThreadChecker utility_thread_checker_; |
| 67 | 69 |
| 68 // Enforces that the DataSource methods are called on one other thread only. | 70 // Enforces that the DataSource methods are called on one other thread only. |
| 69 base::ThreadChecker data_source_thread_checker_; | 71 base::ThreadChecker data_source_thread_checker_; |
| 70 }; | 72 }; |
| 71 | 73 |
| 72 } // namespace metadata | 74 } // namespace metadata |
| 73 | 75 |
| 74 #endif // CHROME_UTILITY_MEDIA_GALLERIES_IPC_DATA_SOURCE_H_ | 76 #endif // CHROME_UTILITY_MEDIA_GALLERIES_IPC_DATA_SOURCE_H_ |
| OLD | NEW |