| 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/update_attempter.h" | 5 #include "update_engine/update_attempter.h" |
| 6 #include <tr1/memory> | 6 #include <tr1/memory> |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 #include <glib.h> | 9 #include <glib.h> |
| 10 #include "update_engine/download_action.h" | 10 #include "update_engine/download_action.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 postinstall_runner_action_postcommit)); | 63 postinstall_runner_action_postcommit)); |
| 64 | 64 |
| 65 // Enqueue the actions | 65 // Enqueue the actions |
| 66 for (vector<shared_ptr<AbstractAction> >::iterator it = actions_.begin(); | 66 for (vector<shared_ptr<AbstractAction> >::iterator it = actions_.begin(); |
| 67 it != actions_.end(); ++it) { | 67 it != actions_.end(); ++it) { |
| 68 processor_.EnqueueAction(it->get()); | 68 processor_.EnqueueAction(it->get()); |
| 69 } | 69 } |
| 70 | 70 |
| 71 // Bond them together. We have to use the leaf-types when calling | 71 // Bond them together. We have to use the leaf-types when calling |
| 72 // BondActions(). | 72 // BondActions(). |
| 73 BondActions(request_prep_action.get(), update_check_action.get()); | 73 BondActions(request_prep_action.get(), |
| 74 BondActions(update_check_action.get(), response_handler_action.get()); | 74 update_check_action.get()); |
| 75 BondActions(response_handler_action.get(), filesystem_copier_action.get()); | 75 BondActions(update_check_action.get(), |
| 76 response_handler_action.get()); |
| 76 BondActions(response_handler_action.get(), | 77 BondActions(response_handler_action.get(), |
| 78 filesystem_copier_action.get()); |
| 79 BondActions(filesystem_copier_action.get(), |
| 77 kernel_filesystem_copier_action.get()); | 80 kernel_filesystem_copier_action.get()); |
| 78 BondActions(kernel_filesystem_copier_action.get(), | 81 BondActions(kernel_filesystem_copier_action.get(), |
| 79 download_action.get()); | 82 download_action.get()); |
| 80 BondActions(download_action.get(), postinstall_runner_action_precommit.get()); | 83 BondActions(download_action.get(), |
| 84 postinstall_runner_action_precommit.get()); |
| 81 BondActions(postinstall_runner_action_precommit.get(), | 85 BondActions(postinstall_runner_action_precommit.get(), |
| 82 set_bootable_flag_action.get()); | 86 set_bootable_flag_action.get()); |
| 83 BondActions(set_bootable_flag_action.get(), | 87 BondActions(set_bootable_flag_action.get(), |
| 84 postinstall_runner_action_postcommit.get()); | 88 postinstall_runner_action_postcommit.get()); |
| 85 | 89 |
| 86 processor_.StartProcessing(); | 90 processor_.StartProcessing(); |
| 87 } | 91 } |
| 88 | 92 |
| 89 // Delegate method: | 93 // Delegate method: |
| 90 void UpdateAttempter::ProcessingDone(const ActionProcessor* processor, | 94 void UpdateAttempter::ProcessingDone(const ActionProcessor* processor, |
| 91 bool success) { | 95 bool success) { |
| 92 CHECK(response_handler_action_); | 96 CHECK(response_handler_action_); |
| 93 if (response_handler_action_->GotNoUpdateResponse()) { | 97 if (response_handler_action_->GotNoUpdateResponse()) { |
| 94 // All done. | 98 // All done. |
| 95 g_main_loop_quit(loop_); | 99 g_main_loop_quit(loop_); |
| 96 return; | 100 return; |
| 97 } | 101 } |
| 98 if (!success) { | 102 if (!success) { |
| 99 if (!full_update_) { | 103 LOG(INFO) << "Update failed."; |
| 100 LOG(ERROR) << "Update failed. Attempting full update"; | |
| 101 actions_.clear(); | |
| 102 response_handler_action_.reset(); | |
| 103 Update(true); | |
| 104 return; | |
| 105 } else { | |
| 106 LOG(ERROR) << "Full update failed. Aborting"; | |
| 107 } | |
| 108 } | 104 } |
| 109 g_main_loop_quit(loop_); | 105 g_main_loop_quit(loop_); |
| 110 } | 106 } |
| 111 | 107 |
| 112 // Stop updating. An attempt will be made to record status to the disk | 108 // Stop updating. An attempt will be made to record status to the disk |
| 113 // so that updates can be resumed later. | 109 // so that updates can be resumed later. |
| 114 void UpdateAttempter::Terminate() { | 110 void UpdateAttempter::Terminate() { |
| 115 // TODO(adlr): implement this method. | 111 // TODO(adlr): implement this method. |
| 116 NOTIMPLEMENTED(); | 112 NOTIMPLEMENTED(); |
| 117 } | 113 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 131 *last_checked_time = 123; | 127 *last_checked_time = 123; |
| 132 *progress = 0.2223; | 128 *progress = 0.2223; |
| 133 *current_operation = "DOWNLOADING"; | 129 *current_operation = "DOWNLOADING"; |
| 134 *new_version = "0.2.3.8"; | 130 *new_version = "0.2.3.8"; |
| 135 *new_size = 10002; | 131 *new_size = 10002; |
| 136 return true; | 132 return true; |
| 137 } | 133 } |
| 138 | 134 |
| 139 | 135 |
| 140 } // namespace chromeos_update_engine | 136 } // namespace chromeos_update_engine |
| OLD | NEW |