| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 temp_buffer_.Allocate(file_size); | 162 temp_buffer_.Allocate(file_size); |
| 163 file_memory_stream_.Assign(static_cast<uint8*>(temp_buffer_), | 163 file_memory_stream_.Assign(static_cast<uint8*>(temp_buffer_), |
| 164 file_size); | 164 file_size); |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 | 167 |
| 168 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 168 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 169 bool ArchiveRequest::ReceiveFileData(MemoryReadStream *input_stream, | 169 bool ArchiveRequest::ReceiveFileData(MemoryReadStream *input_stream, |
| 170 size_t nbytes) { | 170 size_t nbytes) { |
| 171 // hold on to ourselves in case we are freed in the callback. | 171 // hold on to ourselves in case we are freed in the callback. |
| 172 ArchiveRequest::Ref temp(this); | 172 ArchiveRequest::Ref temp(this); |
| 173 assert(input_stream->GetRemainingByteCount() >= nbytes); | 173 assert(input_stream->GetRemainingByteCount() >= nbytes); |
| 174 assert(file_memory_stream_.GetRemainingByteCount() >= nbytes); | 174 assert(file_memory_stream_.GetRemainingByteCount() >= nbytes); |
| 175 | 175 |
| 176 // Buffer file bytes from |input_stream| to |file_memory_stream_| | 176 // Buffer file bytes from |input_stream| to |file_memory_stream_| |
| 177 file_memory_stream_.Write(input_stream->GetDirectMemoryPointer(), nbytes); | 177 file_memory_stream_.Write(input_stream->GetDirectMemoryPointer(), nbytes); |
| 178 input_stream->Skip(nbytes); | 178 input_stream->Skip(nbytes); |
| 179 | 179 |
| 180 // If we've just filled our file temp buffer then callback | 180 // If we've just filled our file temp buffer then callback |
| 181 if (file_memory_stream_.GetRemainingByteCount() == 0) { | 181 if (file_memory_stream_.GetRemainingByteCount() == 0) { |
| 182 // We've reached the end of file | 182 // We've reached the end of file |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 // so let's check. | 246 // so let's check. |
| 247 if (error().empty()) { | 247 if (error().empty()) { |
| 248 set_error(String("Could not download archive: ") + uri()); | 248 set_error(String("Could not download archive: ") + uri()); |
| 249 } | 249 } |
| 250 } | 250 } |
| 251 if (onreadystatechange()) | 251 if (onreadystatechange()) |
| 252 onreadystatechange()->Run(); | 252 onreadystatechange()->Run(); |
| 253 } | 253 } |
| 254 | 254 |
| 255 } // namespace o3d | 255 } // namespace o3d |
| OLD | NEW |