| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 #include "update_engine/download_action.h" | 5 #include "update_engine/download_action.h" |
| 6 #include <errno.h> | 6 #include <errno.h> |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 #include <glib.h> | 10 #include <glib.h> |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 if (writer_) { | 100 if (writer_) { |
| 101 LOG_IF(WARNING, writer_->Close() != 0) << "Error closing the writer."; | 101 LOG_IF(WARNING, writer_->Close() != 0) << "Error closing the writer."; |
| 102 writer_ = NULL; | 102 writer_ = NULL; |
| 103 } | 103 } |
| 104 http_fetcher_->TerminateTransfer(); | 104 http_fetcher_->TerminateTransfer(); |
| 105 if (delegate_) { | 105 if (delegate_) { |
| 106 delegate_->SetDownloadStatus(false); // Set to inactive. | 106 delegate_->SetDownloadStatus(false); // Set to inactive. |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 | 109 |
| 110 void DownloadAction::SeekToOffset(off_t offset) { |
| 111 bytes_received_ = offset; |
| 112 } |
| 113 |
| 110 void DownloadAction::ReceivedBytes(HttpFetcher *fetcher, | 114 void DownloadAction::ReceivedBytes(HttpFetcher *fetcher, |
| 111 const char* bytes, | 115 const char* bytes, |
| 112 int length) { | 116 int length) { |
| 113 bytes_received_ += length; | 117 bytes_received_ += length; |
| 114 if (delegate_) | 118 if (delegate_) |
| 115 delegate_->BytesReceived(bytes_received_, install_plan_.size); | 119 delegate_->BytesReceived(bytes_received_, install_plan_.size); |
| 116 if (writer_ && writer_->Write(bytes, length) < 0) { | 120 if (writer_ && writer_->Write(bytes, length) < 0) { |
| 117 LOG(ERROR) << "Write error -- terminating processing."; | 121 LOG(ERROR) << "Write error -- terminating processing."; |
| 118 TerminateProcessing(); | 122 TerminateProcessing(); |
| 119 processor_->ActionComplete(this, kActionCodeDownloadWriteError); | 123 processor_->ActionComplete(this, kActionCodeDownloadWriteError); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 185 |
| 182 FlushLinuxCaches(); | 186 FlushLinuxCaches(); |
| 183 | 187 |
| 184 // Write the path to the output pipe if we're successful. | 188 // Write the path to the output pipe if we're successful. |
| 185 if (code == kActionCodeSuccess && HasOutputPipe()) | 189 if (code == kActionCodeSuccess && HasOutputPipe()) |
| 186 SetOutputObject(GetInputObject()); | 190 SetOutputObject(GetInputObject()); |
| 187 processor_->ActionComplete(this, code); | 191 processor_->ActionComplete(this, code); |
| 188 } | 192 } |
| 189 | 193 |
| 190 }; // namespace {} | 194 }; // namespace {} |
| OLD | NEW |