Small cleanups in UpdateAttempter.
am: daeaa43ab6
Change-Id: If9c7df4f65218a87d283d128a658d9986c0e12d6
diff --git a/mock_update_attempter.h b/mock_update_attempter.h
index 405fdd6..6253e3d 100644
--- a/mock_update_attempter.h
+++ b/mock_update_attempter.h
@@ -44,7 +44,7 @@
MOCK_METHOD0(ResetStatus, bool(void));
- MOCK_METHOD0(GetCurrentUpdateAttemptFlags, UpdateAttemptFlags(void));
+ MOCK_CONST_METHOD0(GetCurrentUpdateAttemptFlags, UpdateAttemptFlags(void));
MOCK_METHOD3(CheckForUpdate,
bool(const std::string& app_version,
@@ -56,8 +56,6 @@
MOCK_CONST_METHOD0(consecutive_failed_update_checks, unsigned int(void));
MOCK_CONST_METHOD0(server_dictated_poll_interval, unsigned int(void));
-
- MOCK_METHOD0(IsAnyUpdateSourceAllowed, bool(void));
};
} // namespace chromeos_update_engine
diff --git a/update_attempter.cc b/update_attempter.cc
index db373ab..63d8a61 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -20,7 +20,6 @@
#include <algorithm>
#include <memory>
-#include <set>
#include <string>
#include <utility>
#include <vector>
@@ -47,7 +46,6 @@
#include "update_engine/common/prefs_interface.h"
#include "update_engine/common/subprocess.h"
#include "update_engine/common/utils.h"
-#include "update_engine/connection_manager_interface.h"
#include "update_engine/libcurl_http_fetcher.h"
#include "update_engine/metrics_reporter_interface.h"
#include "update_engine/omaha_request_action.h"
@@ -77,8 +75,6 @@
using chromeos_update_manager::UpdateCheckParams;
using chromeos_update_manager::CalculateStagingCase;
using chromeos_update_manager::StagingCase;
-using std::set;
-using std::shared_ptr;
using std::string;
using std::vector;
using update_engine::UpdateAttemptFlags;
@@ -106,8 +102,7 @@
// to |action| (e.g., ErrorCode::kFilesystemVerifierError). If |code| is
// not ErrorCode::kError, or the action is not matched, returns |code|
// unchanged.
-ErrorCode GetErrorCodeForAction(AbstractAction* action,
- ErrorCode code) {
+ErrorCode GetErrorCodeForAction(AbstractAction* action, ErrorCode code) {
if (code != ErrorCode::kError)
return code;
@@ -1291,8 +1286,7 @@
if (!system_state_->hardware()->IsOfficialBuild())
flags |= static_cast<uint32_t>(ErrorCode::kTestImageFlag);
- if (omaha_request_params_->update_url() !=
- constants::kOmahaDefaultProductionURL) {
+ if (!omaha_request_params_->IsUpdateUrlOfficial()) {
flags |= static_cast<uint32_t>(ErrorCode::kTestOmahaUrlFlag);
}
@@ -1589,7 +1583,7 @@
waiting_for_scheduled_check_);
}
-bool UpdateAttempter::IsAnyUpdateSourceAllowed() {
+bool UpdateAttempter::IsAnyUpdateSourceAllowed() const {
// We allow updates from any source if either of these are true:
// * The device is running an unofficial (dev/test) image.
// * The debugd dev features are accessible (i.e. in devmode with no owner).
diff --git a/update_attempter.h b/update_attempter.h
index 99bde83..d0beff6 100644
--- a/update_attempter.h
+++ b/update_attempter.h
@@ -53,8 +53,6 @@
namespace chromeos_update_engine {
-class UpdateEngineAdaptor;
-
class UpdateAttempter : public ActionProcessorDelegate,
public DownloadActionDelegate,
public CertificateChecker::Observer,
@@ -109,16 +107,6 @@
// Returns the current status in the out param. Returns true on success.
virtual bool GetStatus(update_engine::UpdateEngineStatus* out_status);
- // Runs chromeos-setgoodkernel, whose responsibility it is to mark the
- // currently booted partition has high priority/permanent/etc. The execution
- // is asynchronous. On completion, the action processor may be started
- // depending on the |start_action_processor_| field. Note that every update
- // attempt goes through this method.
- void UpdateBootFlags();
-
- // Called when the boot flags have been updated.
- void CompleteUpdateBootFlags(bool success);
-
UpdateStatus status() const { return status_; }
int http_response_code() const { return http_response_code_; }
@@ -134,7 +122,7 @@
// Returns the update attempt flags that are in place for the current update
// attempt. These are cached at the start of an update attempt so that they
// remain constant throughout the process.
- virtual UpdateAttemptFlags GetCurrentUpdateAttemptFlags() {
+ virtual UpdateAttemptFlags GetCurrentUpdateAttemptFlags() const {
return current_update_attempt_flags_;
}
@@ -181,10 +169,6 @@
ErrorCode GetAttemptErrorCode() const { return attempt_error_code_; }
- // Returns the special flags to be added to ErrorCode values based on the
- // parameters used in the current update attempt.
- uint32_t GetErrorCodeFlags();
-
// Called at update_engine startup to do various house-keeping.
void UpdateEngineStarted();
@@ -202,7 +186,7 @@
// Returns a version OS version that was being used before the last reboot,
// and if that reboot happened to be into an update (current version).
// This will return an empty string otherwise.
- std::string const& GetPrevVersion() const { return prev_version_; }
+ const std::string& GetPrevVersion() const { return prev_version_; }
// Returns the number of consecutive failed update checks.
virtual unsigned int consecutive_failed_update_checks() const {
@@ -222,8 +206,7 @@
// Note that only one callback can be set, so effectively at most one client
// can be notified.
virtual void set_forced_update_pending_callback(
- base::Callback<void(bool, bool)>* // NOLINT(readability/function)
- callback) {
+ base::Callback<void(bool, bool)>* callback) {
forced_update_pending_callback_.reset(callback);
}
@@ -231,7 +214,7 @@
// we want to restrict updates to known safe sources, but under certain
// conditions it's useful to allow updating from anywhere (e.g. to allow
// 'cros flash' to function properly).
- virtual bool IsAnyUpdateSourceAllowed();
+ bool IsAnyUpdateSourceAllowed() const;
// Add and remove a service observer.
void AddObserver(ServiceObserverInterface* observer) {
@@ -249,9 +232,6 @@
void ClearObservers() { service_observers_.clear(); }
private:
- // Update server URL for automated lab test.
- static const char* const kTestUpdateUrl;
-
// Friend declarations for testing purposes.
friend class UpdateAttempterUnderTest;
friend class UpdateAttempterTest;
@@ -283,7 +263,10 @@
FRIEND_TEST(UpdateAttempterTest, UpdateAttemptFlagsCachedAtUpdateStart);
FRIEND_TEST(UpdateAttempterTest, UpdateDeferredByPolicyTest);
FRIEND_TEST(UpdateAttempterTest, UpdateIsNotRunningWhenUpdateAvailable);
- FRIEND_TEST(UpdateAttempterTest, UpdateTest);
+
+ // Returns the special flags to be added to ErrorCode values based on the
+ // parameters used in the current update attempt.
+ uint32_t GetErrorCodeFlags();
// CertificateChecker::Observer method.
// Report metrics about the certificate being checked.
@@ -326,12 +309,10 @@
ProxyResolver* GetProxyResolver() {
#if USE_CHROME_NETWORK_PROXY
- return obeying_proxies_ ?
- reinterpret_cast<ProxyResolver*>(&chrome_proxy_resolver_) :
- reinterpret_cast<ProxyResolver*>(&direct_proxy_resolver_);
-#else
- return &direct_proxy_resolver_;
+ if (obeying_proxies_)
+ return &chrome_proxy_resolver_;
#endif // USE_CHROME_NETWORK_PROXY
+ return &direct_proxy_resolver_;
}
// Sends a ping to Omaha.
diff --git a/update_attempter_android.h b/update_attempter_android.h
index 641374a..0438c16 100644
--- a/update_attempter_android.h
+++ b/update_attempter_android.h
@@ -93,14 +93,6 @@
private:
friend class UpdateAttempterAndroidTest;
- // Asynchronously marks the current slot as successful if needed. If already
- // marked as good, CompleteUpdateBootFlags() is called starting the action
- // processor.
- void UpdateBootFlags();
-
- // Called when the boot flags have been updated.
- void CompleteUpdateBootFlags(bool success);
-
// Schedules an event loop callback to start the action processor. This is
// scheduled asynchronously to unblock the event loop.
void ScheduleProcessingStart();