OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_CDM_PPAPI_CDM_FILE_IO_IMPL_H_ | 5 #ifndef MEDIA_CDM_PPAPI_CDM_FILE_IO_IMPL_H_ |
6 #define MEDIA_CDM_PPAPI_CDM_FILE_IO_IMPL_H_ | 6 #define MEDIA_CDM_PPAPI_CDM_FILE_IO_IMPL_H_ |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 17 matching lines...) Expand all Loading... |
28 // There should be only one instance of ResourceTracker in a process. Also, | 28 // There should be only one instance of ResourceTracker in a process. Also, |
29 // ResourceTracker should outlive all CdmFileIOImpl instances. | 29 // ResourceTracker should outlive all CdmFileIOImpl instances. |
30 class ResourceTracker { | 30 class ResourceTracker { |
31 public: | 31 public: |
32 ResourceTracker(); | 32 ResourceTracker(); |
33 ~ResourceTracker(); | 33 ~ResourceTracker(); |
34 private: | 34 private: |
35 DISALLOW_COPY_AND_ASSIGN(ResourceTracker); | 35 DISALLOW_COPY_AND_ASSIGN(ResourceTracker); |
36 }; | 36 }; |
37 | 37 |
38 CdmFileIOImpl(cdm::FileIOClient* client, PP_Instance pp_instance); | 38 // After the first successful file read, call |first_file_read_cb| to report |
| 39 // the file size. |first_file_read_cb| takes one parameter: the file size in |
| 40 // bytes. |
| 41 CdmFileIOImpl(cdm::FileIOClient* client, |
| 42 PP_Instance pp_instance, |
| 43 const pp::CompletionCallback& first_file_read_cb); |
39 | 44 |
40 // cdm::FileIO implementation. | 45 // cdm::FileIO implementation. |
41 virtual void Open(const char* file_name, uint32_t file_name_size) OVERRIDE; | 46 virtual void Open(const char* file_name, uint32_t file_name_size) OVERRIDE; |
42 virtual void Read() OVERRIDE; | 47 virtual void Read() OVERRIDE; |
43 virtual void Write(const uint8_t* data, uint32_t data_size) OVERRIDE; | 48 virtual void Write(const uint8_t* data, uint32_t data_size) OVERRIDE; |
44 virtual void Close() OVERRIDE; | 49 virtual void Close() OVERRIDE; |
45 | 50 |
46 private: | 51 private: |
47 enum State { | 52 enum State { |
48 FILE_UNOPENED, | 53 FILE_UNOPENED, |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 std::vector<char> io_buffer_; | 156 std::vector<char> io_buffer_; |
152 | 157 |
153 // Offset into the file for reading/writing data. When writing data to the | 158 // Offset into the file for reading/writing data. When writing data to the |
154 // file, this is also the offset to the |io_buffer_|. | 159 // file, this is also the offset to the |io_buffer_|. |
155 size_t io_offset_; | 160 size_t io_offset_; |
156 | 161 |
157 // Buffer to hold all read data requested. This buffer is passed to |client_| | 162 // Buffer to hold all read data requested. This buffer is passed to |client_| |
158 // when read completes. | 163 // when read completes. |
159 std::vector<char> cumulative_read_buffer_; | 164 std::vector<char> cumulative_read_buffer_; |
160 | 165 |
| 166 bool first_file_read_reported_; |
| 167 |
| 168 // Callback to report the file size in bytes after the first successful read. |
| 169 pp::CompletionCallback first_file_read_cb_; |
| 170 |
161 DISALLOW_COPY_AND_ASSIGN(CdmFileIOImpl); | 171 DISALLOW_COPY_AND_ASSIGN(CdmFileIOImpl); |
162 }; | 172 }; |
163 | 173 |
164 } // namespace media | 174 } // namespace media |
165 | 175 |
166 #endif // MEDIA_CDM_PPAPI_CDM_FILE_IO_IMPL_H_ | 176 #endif // MEDIA_CDM_PPAPI_CDM_FILE_IO_IMPL_H_ |
OLD | NEW |