xref: /aosp_15_r20/system/update_engine/download_action.cc (revision 5a9231315b4521097b8dc3750bc806fcafe0c72f)
1*5a923131SAndroid Build Coastguard Worker //
2*5a923131SAndroid Build Coastguard Worker // Copyright (C) 2011 The Android Open Source Project
3*5a923131SAndroid Build Coastguard Worker //
4*5a923131SAndroid Build Coastguard Worker // Licensed under the Apache License, Version 2.0 (the "License");
5*5a923131SAndroid Build Coastguard Worker // you may not use this file except in compliance with the License.
6*5a923131SAndroid Build Coastguard Worker // You may obtain a copy of the License at
7*5a923131SAndroid Build Coastguard Worker //
8*5a923131SAndroid Build Coastguard Worker //      http://www.apache.org/licenses/LICENSE-2.0
9*5a923131SAndroid Build Coastguard Worker //
10*5a923131SAndroid Build Coastguard Worker // Unless required by applicable law or agreed to in writing, software
11*5a923131SAndroid Build Coastguard Worker // distributed under the License is distributed on an "AS IS" BASIS,
12*5a923131SAndroid Build Coastguard Worker // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*5a923131SAndroid Build Coastguard Worker // See the License for the specific language governing permissions and
14*5a923131SAndroid Build Coastguard Worker // limitations under the License.
15*5a923131SAndroid Build Coastguard Worker //
16*5a923131SAndroid Build Coastguard Worker 
17*5a923131SAndroid Build Coastguard Worker #include "update_engine/common/download_action.h"
18*5a923131SAndroid Build Coastguard Worker 
19*5a923131SAndroid Build Coastguard Worker #include <string>
20*5a923131SAndroid Build Coastguard Worker 
21*5a923131SAndroid Build Coastguard Worker #include <base/files/file_path.h>
22*5a923131SAndroid Build Coastguard Worker #include <base/metrics/statistics_recorder.h>
23*5a923131SAndroid Build Coastguard Worker #include <android-base/stringprintf.h>
24*5a923131SAndroid Build Coastguard Worker 
25*5a923131SAndroid Build Coastguard Worker #include "update_engine/common/boot_control_interface.h"
26*5a923131SAndroid Build Coastguard Worker #include "update_engine/common/error_code_utils.h"
27*5a923131SAndroid Build Coastguard Worker #include "update_engine/common/multi_range_http_fetcher.h"
28*5a923131SAndroid Build Coastguard Worker #include "update_engine/common/prefs_interface.h"
29*5a923131SAndroid Build Coastguard Worker #include "update_engine/common/utils.h"
30*5a923131SAndroid Build Coastguard Worker 
31*5a923131SAndroid Build Coastguard Worker using base::FilePath;
32*5a923131SAndroid Build Coastguard Worker using std::string;
33*5a923131SAndroid Build Coastguard Worker 
34*5a923131SAndroid Build Coastguard Worker namespace chromeos_update_engine {
35*5a923131SAndroid Build Coastguard Worker 
DownloadAction(PrefsInterface * prefs,BootControlInterface * boot_control,HardwareInterface * hardware,HttpFetcher * http_fetcher,bool interactive,std::string update_certificates_path)36*5a923131SAndroid Build Coastguard Worker DownloadAction::DownloadAction(PrefsInterface* prefs,
37*5a923131SAndroid Build Coastguard Worker                                BootControlInterface* boot_control,
38*5a923131SAndroid Build Coastguard Worker                                HardwareInterface* hardware,
39*5a923131SAndroid Build Coastguard Worker                                HttpFetcher* http_fetcher,
40*5a923131SAndroid Build Coastguard Worker                                bool interactive,
41*5a923131SAndroid Build Coastguard Worker                                std::string update_certificates_path)
42*5a923131SAndroid Build Coastguard Worker     : prefs_(prefs),
43*5a923131SAndroid Build Coastguard Worker       boot_control_(boot_control),
44*5a923131SAndroid Build Coastguard Worker       hardware_(hardware),
45*5a923131SAndroid Build Coastguard Worker       http_fetcher_(new MultiRangeHttpFetcher(http_fetcher)),
46*5a923131SAndroid Build Coastguard Worker       interactive_(interactive),
47*5a923131SAndroid Build Coastguard Worker       code_(ErrorCode::kSuccess),
48*5a923131SAndroid Build Coastguard Worker       delegate_(nullptr),
49*5a923131SAndroid Build Coastguard Worker       update_certificates_path_(std::move(update_certificates_path)) {}
50*5a923131SAndroid Build Coastguard Worker 
~DownloadAction()51*5a923131SAndroid Build Coastguard Worker DownloadAction::~DownloadAction() {}
52*5a923131SAndroid Build Coastguard Worker 
PerformAction()53*5a923131SAndroid Build Coastguard Worker void DownloadAction::PerformAction() {
54*5a923131SAndroid Build Coastguard Worker   http_fetcher_->set_delegate(this);
55*5a923131SAndroid Build Coastguard Worker 
56*5a923131SAndroid Build Coastguard Worker   // Get the InstallPlan and read it
57*5a923131SAndroid Build Coastguard Worker   CHECK(HasInputObject());
58*5a923131SAndroid Build Coastguard Worker   install_plan_ = GetInputObject();
59*5a923131SAndroid Build Coastguard Worker   install_plan_.Dump();
60*5a923131SAndroid Build Coastguard Worker 
61*5a923131SAndroid Build Coastguard Worker   bytes_received_ = 0;
62*5a923131SAndroid Build Coastguard Worker   bytes_received_previous_payloads_ = 0;
63*5a923131SAndroid Build Coastguard Worker   bytes_total_ = 0;
64*5a923131SAndroid Build Coastguard Worker   for (const auto& payload : install_plan_.payloads)
65*5a923131SAndroid Build Coastguard Worker     bytes_total_ += payload.size;
66*5a923131SAndroid Build Coastguard Worker 
67*5a923131SAndroid Build Coastguard Worker   if (install_plan_.is_resume) {
68*5a923131SAndroid Build Coastguard Worker     int64_t payload_index = 0;
69*5a923131SAndroid Build Coastguard Worker     if (prefs_->GetInt64(kPrefsUpdateStatePayloadIndex, &payload_index) &&
70*5a923131SAndroid Build Coastguard Worker         static_cast<size_t>(payload_index) < install_plan_.payloads.size()) {
71*5a923131SAndroid Build Coastguard Worker       // Save the index for the resume payload before downloading any previous
72*5a923131SAndroid Build Coastguard Worker       // payload, otherwise it will be overwritten.
73*5a923131SAndroid Build Coastguard Worker       resume_payload_index_ = payload_index;
74*5a923131SAndroid Build Coastguard Worker       for (int i = 0; i < payload_index; i++)
75*5a923131SAndroid Build Coastguard Worker         install_plan_.payloads[i].already_applied = true;
76*5a923131SAndroid Build Coastguard Worker     }
77*5a923131SAndroid Build Coastguard Worker   }
78*5a923131SAndroid Build Coastguard Worker   CHECK_GE(install_plan_.payloads.size(), 1UL);
79*5a923131SAndroid Build Coastguard Worker   if (!payload_)
80*5a923131SAndroid Build Coastguard Worker     payload_ = &install_plan_.payloads[0];
81*5a923131SAndroid Build Coastguard Worker 
82*5a923131SAndroid Build Coastguard Worker   LOG(INFO) << "Marking new slot as unbootable";
83*5a923131SAndroid Build Coastguard Worker   if (!boot_control_->MarkSlotUnbootable(install_plan_.target_slot)) {
84*5a923131SAndroid Build Coastguard Worker     LOG(WARNING) << "Unable to mark new slot "
85*5a923131SAndroid Build Coastguard Worker                  << BootControlInterface::SlotName(install_plan_.target_slot)
86*5a923131SAndroid Build Coastguard Worker                  << ". Proceeding with the update anyway.";
87*5a923131SAndroid Build Coastguard Worker   }
88*5a923131SAndroid Build Coastguard Worker 
89*5a923131SAndroid Build Coastguard Worker   StartDownloading();
90*5a923131SAndroid Build Coastguard Worker }
91*5a923131SAndroid Build Coastguard Worker 
LoadCachedManifest(int64_t manifest_size)92*5a923131SAndroid Build Coastguard Worker bool DownloadAction::LoadCachedManifest(int64_t manifest_size) {
93*5a923131SAndroid Build Coastguard Worker   std::string cached_manifest_bytes;
94*5a923131SAndroid Build Coastguard Worker   if (!prefs_->GetString(kPrefsManifestBytes, &cached_manifest_bytes) ||
95*5a923131SAndroid Build Coastguard Worker       cached_manifest_bytes.size() <= 0) {
96*5a923131SAndroid Build Coastguard Worker     LOG(INFO) << "Cached Manifest data not found";
97*5a923131SAndroid Build Coastguard Worker     return false;
98*5a923131SAndroid Build Coastguard Worker   }
99*5a923131SAndroid Build Coastguard Worker   if (static_cast<int64_t>(cached_manifest_bytes.size()) != manifest_size) {
100*5a923131SAndroid Build Coastguard Worker     LOG(WARNING) << "Cached metadata has unexpected size: "
101*5a923131SAndroid Build Coastguard Worker                  << cached_manifest_bytes.size() << " vs. " << manifest_size;
102*5a923131SAndroid Build Coastguard Worker     return false;
103*5a923131SAndroid Build Coastguard Worker   }
104*5a923131SAndroid Build Coastguard Worker 
105*5a923131SAndroid Build Coastguard Worker   ErrorCode error{};
106*5a923131SAndroid Build Coastguard Worker   const bool success =
107*5a923131SAndroid Build Coastguard Worker       delta_performer_->Write(
108*5a923131SAndroid Build Coastguard Worker           cached_manifest_bytes.data(), cached_manifest_bytes.size(), &error) &&
109*5a923131SAndroid Build Coastguard Worker       delta_performer_->IsManifestValid();
110*5a923131SAndroid Build Coastguard Worker   if (success) {
111*5a923131SAndroid Build Coastguard Worker     LOG(INFO) << "Successfully parsed cached manifest";
112*5a923131SAndroid Build Coastguard Worker   } else {
113*5a923131SAndroid Build Coastguard Worker     // If parsing of cached data failed, fall back to fetch them using HTTP
114*5a923131SAndroid Build Coastguard Worker     LOG(WARNING) << "Cached manifest data fails to load, error code:"
115*5a923131SAndroid Build Coastguard Worker                  << static_cast<int>(error) << "," << error;
116*5a923131SAndroid Build Coastguard Worker   }
117*5a923131SAndroid Build Coastguard Worker   return success;
118*5a923131SAndroid Build Coastguard Worker }
119*5a923131SAndroid Build Coastguard Worker 
StartDownloading()120*5a923131SAndroid Build Coastguard Worker void DownloadAction::StartDownloading() {
121*5a923131SAndroid Build Coastguard Worker   download_active_ = true;
122*5a923131SAndroid Build Coastguard Worker   http_fetcher_->ClearRanges();
123*5a923131SAndroid Build Coastguard Worker 
124*5a923131SAndroid Build Coastguard Worker   if (delta_performer_ != nullptr) {
125*5a923131SAndroid Build Coastguard Worker     LOG(INFO) << "Using writer for test.";
126*5a923131SAndroid Build Coastguard Worker   } else {
127*5a923131SAndroid Build Coastguard Worker     delta_performer_.reset(new DeltaPerformer(prefs_,
128*5a923131SAndroid Build Coastguard Worker                                               boot_control_,
129*5a923131SAndroid Build Coastguard Worker                                               hardware_,
130*5a923131SAndroid Build Coastguard Worker                                               delegate_,
131*5a923131SAndroid Build Coastguard Worker                                               &install_plan_,
132*5a923131SAndroid Build Coastguard Worker                                               payload_,
133*5a923131SAndroid Build Coastguard Worker                                               interactive_,
134*5a923131SAndroid Build Coastguard Worker                                               update_certificates_path_));
135*5a923131SAndroid Build Coastguard Worker   }
136*5a923131SAndroid Build Coastguard Worker 
137*5a923131SAndroid Build Coastguard Worker   if (install_plan_.is_resume &&
138*5a923131SAndroid Build Coastguard Worker       payload_ == &install_plan_.payloads[resume_payload_index_]) {
139*5a923131SAndroid Build Coastguard Worker     // Resuming an update so parse the cached manifest first
140*5a923131SAndroid Build Coastguard Worker     int64_t manifest_metadata_size = 0;
141*5a923131SAndroid Build Coastguard Worker     int64_t manifest_signature_size = 0;
142*5a923131SAndroid Build Coastguard Worker     prefs_->GetInt64(kPrefsManifestMetadataSize, &manifest_metadata_size);
143*5a923131SAndroid Build Coastguard Worker     prefs_->GetInt64(kPrefsManifestSignatureSize, &manifest_signature_size);
144*5a923131SAndroid Build Coastguard Worker 
145*5a923131SAndroid Build Coastguard Worker     // TODO(zhangkelvin) Add unittest for success and fallback route
146*5a923131SAndroid Build Coastguard Worker     if (!LoadCachedManifest(manifest_metadata_size + manifest_signature_size)) {
147*5a923131SAndroid Build Coastguard Worker       if (delta_performer_) {
148*5a923131SAndroid Build Coastguard Worker         // Create a new DeltaPerformer to reset all its state
149*5a923131SAndroid Build Coastguard Worker         delta_performer_ =
150*5a923131SAndroid Build Coastguard Worker             std::make_unique<DeltaPerformer>(prefs_,
151*5a923131SAndroid Build Coastguard Worker                                              boot_control_,
152*5a923131SAndroid Build Coastguard Worker                                              hardware_,
153*5a923131SAndroid Build Coastguard Worker                                              delegate_,
154*5a923131SAndroid Build Coastguard Worker                                              &install_plan_,
155*5a923131SAndroid Build Coastguard Worker                                              payload_,
156*5a923131SAndroid Build Coastguard Worker                                              interactive_,
157*5a923131SAndroid Build Coastguard Worker                                              update_certificates_path_);
158*5a923131SAndroid Build Coastguard Worker       }
159*5a923131SAndroid Build Coastguard Worker       http_fetcher_->AddRange(base_offset_,
160*5a923131SAndroid Build Coastguard Worker                               manifest_metadata_size + manifest_signature_size);
161*5a923131SAndroid Build Coastguard Worker     }
162*5a923131SAndroid Build Coastguard Worker 
163*5a923131SAndroid Build Coastguard Worker     // If there're remaining unprocessed data blobs, fetch them. Be careful
164*5a923131SAndroid Build Coastguard Worker     // not to request data beyond the end of the payload to avoid 416 HTTP
165*5a923131SAndroid Build Coastguard Worker     // response error codes.
166*5a923131SAndroid Build Coastguard Worker     int64_t next_data_offset = 0;
167*5a923131SAndroid Build Coastguard Worker     prefs_->GetInt64(kPrefsUpdateStateNextDataOffset, &next_data_offset);
168*5a923131SAndroid Build Coastguard Worker     uint64_t resume_offset =
169*5a923131SAndroid Build Coastguard Worker         manifest_metadata_size + manifest_signature_size + next_data_offset;
170*5a923131SAndroid Build Coastguard Worker     if (!payload_->size) {
171*5a923131SAndroid Build Coastguard Worker       http_fetcher_->AddRange(base_offset_ + resume_offset);
172*5a923131SAndroid Build Coastguard Worker     } else if (resume_offset < payload_->size) {
173*5a923131SAndroid Build Coastguard Worker       http_fetcher_->AddRange(base_offset_ + resume_offset,
174*5a923131SAndroid Build Coastguard Worker                               payload_->size - resume_offset);
175*5a923131SAndroid Build Coastguard Worker     }
176*5a923131SAndroid Build Coastguard Worker   } else {
177*5a923131SAndroid Build Coastguard Worker     if (payload_->size) {
178*5a923131SAndroid Build Coastguard Worker       http_fetcher_->AddRange(base_offset_, payload_->size);
179*5a923131SAndroid Build Coastguard Worker     } else {
180*5a923131SAndroid Build Coastguard Worker       // If no payload size is passed we assume we read until the end of the
181*5a923131SAndroid Build Coastguard Worker       // stream.
182*5a923131SAndroid Build Coastguard Worker       http_fetcher_->AddRange(base_offset_);
183*5a923131SAndroid Build Coastguard Worker     }
184*5a923131SAndroid Build Coastguard Worker   }
185*5a923131SAndroid Build Coastguard Worker 
186*5a923131SAndroid Build Coastguard Worker   http_fetcher_->BeginTransfer(install_plan_.download_url);
187*5a923131SAndroid Build Coastguard Worker }
188*5a923131SAndroid Build Coastguard Worker 
SuspendAction()189*5a923131SAndroid Build Coastguard Worker void DownloadAction::SuspendAction() {
190*5a923131SAndroid Build Coastguard Worker   http_fetcher_->Pause();
191*5a923131SAndroid Build Coastguard Worker }
192*5a923131SAndroid Build Coastguard Worker 
ResumeAction()193*5a923131SAndroid Build Coastguard Worker void DownloadAction::ResumeAction() {
194*5a923131SAndroid Build Coastguard Worker   http_fetcher_->Unpause();
195*5a923131SAndroid Build Coastguard Worker }
196*5a923131SAndroid Build Coastguard Worker 
TerminateProcessing()197*5a923131SAndroid Build Coastguard Worker void DownloadAction::TerminateProcessing() {
198*5a923131SAndroid Build Coastguard Worker   if (delta_performer_) {
199*5a923131SAndroid Build Coastguard Worker     delta_performer_->Close();
200*5a923131SAndroid Build Coastguard Worker     delta_performer_.reset();
201*5a923131SAndroid Build Coastguard Worker   }
202*5a923131SAndroid Build Coastguard Worker   download_active_ = false;
203*5a923131SAndroid Build Coastguard Worker   // Terminates the transfer. The action is terminated, if necessary, when the
204*5a923131SAndroid Build Coastguard Worker   // TransferTerminated callback is received.
205*5a923131SAndroid Build Coastguard Worker   http_fetcher_->TerminateTransfer();
206*5a923131SAndroid Build Coastguard Worker }
207*5a923131SAndroid Build Coastguard Worker 
SeekToOffset(off_t offset)208*5a923131SAndroid Build Coastguard Worker void DownloadAction::SeekToOffset(off_t offset) {
209*5a923131SAndroid Build Coastguard Worker   bytes_received_ = offset;
210*5a923131SAndroid Build Coastguard Worker }
211*5a923131SAndroid Build Coastguard Worker 
ReceivedBytes(HttpFetcher * fetcher,const void * bytes,size_t length)212*5a923131SAndroid Build Coastguard Worker bool DownloadAction::ReceivedBytes(HttpFetcher* fetcher,
213*5a923131SAndroid Build Coastguard Worker                                    const void* bytes,
214*5a923131SAndroid Build Coastguard Worker                                    size_t length) {
215*5a923131SAndroid Build Coastguard Worker   bytes_received_ += length;
216*5a923131SAndroid Build Coastguard Worker   uint64_t bytes_downloaded_total =
217*5a923131SAndroid Build Coastguard Worker       bytes_received_previous_payloads_ + bytes_received_;
218*5a923131SAndroid Build Coastguard Worker   if (delegate_ && download_active_) {
219*5a923131SAndroid Build Coastguard Worker     delegate_->BytesReceived(
220*5a923131SAndroid Build Coastguard Worker         length, bytes_downloaded_total - base_offset_, bytes_total_);
221*5a923131SAndroid Build Coastguard Worker   }
222*5a923131SAndroid Build Coastguard Worker   if (delta_performer_ && !delta_performer_->Write(bytes, length, &code_)) {
223*5a923131SAndroid Build Coastguard Worker     if (code_ != ErrorCode::kSuccess) {
224*5a923131SAndroid Build Coastguard Worker       LOG(ERROR) << "Error " << utils::ErrorCodeToString(code_) << " (" << code_
225*5a923131SAndroid Build Coastguard Worker                  << ") in DeltaPerformer's Write method when "
226*5a923131SAndroid Build Coastguard Worker                  << "processing the received payload -- Terminating processing";
227*5a923131SAndroid Build Coastguard Worker     } else {
228*5a923131SAndroid Build Coastguard Worker       LOG(ERROR) << "Unknown error in DeltaPerformer's Write method when "
229*5a923131SAndroid Build Coastguard Worker                  << "processing the received payload -- Terminating processing";
230*5a923131SAndroid Build Coastguard Worker       code_ = ErrorCode::kDownloadWriteError;
231*5a923131SAndroid Build Coastguard Worker     }
232*5a923131SAndroid Build Coastguard Worker     // Don't tell the action processor that the action is complete until we get
233*5a923131SAndroid Build Coastguard Worker     // the TransferTerminated callback. Otherwise, this and the HTTP fetcher
234*5a923131SAndroid Build Coastguard Worker     // objects may get destroyed before all callbacks are complete.
235*5a923131SAndroid Build Coastguard Worker     TerminateProcessing();
236*5a923131SAndroid Build Coastguard Worker     return false;
237*5a923131SAndroid Build Coastguard Worker   }
238*5a923131SAndroid Build Coastguard Worker 
239*5a923131SAndroid Build Coastguard Worker   return true;
240*5a923131SAndroid Build Coastguard Worker }
241*5a923131SAndroid Build Coastguard Worker 
TransferComplete(HttpFetcher * fetcher,bool successful)242*5a923131SAndroid Build Coastguard Worker void DownloadAction::TransferComplete(HttpFetcher* fetcher, bool successful) {
243*5a923131SAndroid Build Coastguard Worker   if (delta_performer_) {
244*5a923131SAndroid Build Coastguard Worker     LOG_IF(WARNING, delta_performer_->Close() != 0)
245*5a923131SAndroid Build Coastguard Worker         << "Error closing the writer.";
246*5a923131SAndroid Build Coastguard Worker   }
247*5a923131SAndroid Build Coastguard Worker   download_active_ = false;
248*5a923131SAndroid Build Coastguard Worker   ErrorCode code =
249*5a923131SAndroid Build Coastguard Worker       successful ? ErrorCode::kSuccess : ErrorCode::kDownloadTransferError;
250*5a923131SAndroid Build Coastguard Worker   if (code == ErrorCode::kSuccess) {
251*5a923131SAndroid Build Coastguard Worker     if (delta_performer_ && !payload_->already_applied)
252*5a923131SAndroid Build Coastguard Worker       code = delta_performer_->VerifyPayload(payload_->hash, payload_->size);
253*5a923131SAndroid Build Coastguard Worker     if (code == ErrorCode::kSuccess) {
254*5a923131SAndroid Build Coastguard Worker       CHECK_EQ(install_plan_.payloads.size(), 1UL);
255*5a923131SAndroid Build Coastguard Worker       // All payloads have been applied and verified.
256*5a923131SAndroid Build Coastguard Worker       if (delegate_)
257*5a923131SAndroid Build Coastguard Worker         delegate_->DownloadComplete();
258*5a923131SAndroid Build Coastguard Worker 
259*5a923131SAndroid Build Coastguard Worker       // Log UpdateEngine.DownloadAction.* histograms to help diagnose
260*5a923131SAndroid Build Coastguard Worker       // long-blocking operations.
261*5a923131SAndroid Build Coastguard Worker       std::string histogram_output;
262*5a923131SAndroid Build Coastguard Worker       base::StatisticsRecorder::WriteGraph("UpdateEngine.DownloadAction.",
263*5a923131SAndroid Build Coastguard Worker                                            &histogram_output);
264*5a923131SAndroid Build Coastguard Worker       LOG(INFO) << histogram_output;
265*5a923131SAndroid Build Coastguard Worker     } else {
266*5a923131SAndroid Build Coastguard Worker       LOG(ERROR) << "Download of " << install_plan_.download_url
267*5a923131SAndroid Build Coastguard Worker                  << " failed due to payload verification error.";
268*5a923131SAndroid Build Coastguard Worker     }
269*5a923131SAndroid Build Coastguard Worker   }
270*5a923131SAndroid Build Coastguard Worker 
271*5a923131SAndroid Build Coastguard Worker   // Write the path to the output pipe if we're successful.
272*5a923131SAndroid Build Coastguard Worker   if (code == ErrorCode::kSuccess && HasOutputPipe())
273*5a923131SAndroid Build Coastguard Worker     SetOutputObject(install_plan_);
274*5a923131SAndroid Build Coastguard Worker   processor_->ActionComplete(this, code);
275*5a923131SAndroid Build Coastguard Worker }
276*5a923131SAndroid Build Coastguard Worker 
TransferTerminated(HttpFetcher * fetcher)277*5a923131SAndroid Build Coastguard Worker void DownloadAction::TransferTerminated(HttpFetcher* fetcher) {
278*5a923131SAndroid Build Coastguard Worker   if (code_ != ErrorCode::kSuccess) {
279*5a923131SAndroid Build Coastguard Worker     processor_->ActionComplete(this, code_);
280*5a923131SAndroid Build Coastguard Worker   } else if (payload_->already_applied) {
281*5a923131SAndroid Build Coastguard Worker     LOG(INFO) << "TransferTerminated with ErrorCode::kSuccess when the current "
282*5a923131SAndroid Build Coastguard Worker                  "payload has already applied, treating as TransferComplete.";
283*5a923131SAndroid Build Coastguard Worker     TransferComplete(fetcher, true);
284*5a923131SAndroid Build Coastguard Worker   }
285*5a923131SAndroid Build Coastguard Worker }
286*5a923131SAndroid Build Coastguard Worker 
287*5a923131SAndroid Build Coastguard Worker }  // namespace chromeos_update_engine
288