Remove SystemState dependency from HttpFetcher and InstallPlan.
The SystemState class is an aggregation of all the update_engine
singletons, making it easy to handle cross-dependencies between these
singletons. Nevertheless, since we split the code into a smaller
libpayload_consumer library we need to remove the global dependencies
on the SystemState class from this library and specialize those
dependencies to the actual required class.
Bug: 25773375
TEST=FEATURES=test emerge-link update_engine; mma
Change-Id: I8800157c969db6a8d168f33ac2c6aad4f34fa236
diff --git a/common/http_fetcher_unittest.cc b/common/http_fetcher_unittest.cc
index 654cb1d..17e360e 100644
--- a/common/http_fetcher_unittest.cc
+++ b/common/http_fetcher_unittest.cc
@@ -24,6 +24,7 @@
#include <utility>
#include <vector>
+#include <base/bind.h>
#include <base/location.h>
#include <base/logging.h>
#include <base/message_loop/message_loop.h>
@@ -31,6 +32,7 @@
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
#include <base/time/time.h>
+#include <brillo/bind_lambda.h>
#include <brillo/message_loops/base_message_loop.h>
#include <brillo/message_loops/message_loop.h>
#include <brillo/message_loops/message_loop_utils.h>
@@ -46,7 +48,6 @@
#include "update_engine/common/multi_range_http_fetcher.h"
#include "update_engine/common/test_utils.h"
#include "update_engine/common/utils.h"
-#include "update_engine/fake_system_state.h"
#include "update_engine/proxy_resolver.h"
using brillo::MessageLoop;
@@ -214,12 +215,12 @@
virtual HttpServer* CreateServer() = 0;
FakeHardware* fake_hardware() {
- return fake_system_state_.fake_hardware();
+ return &fake_hardware_;
}
protected:
DirectProxyResolver proxy_resolver_;
- FakeSystemState fake_system_state_;
+ FakeHardware fake_hardware_;
};
class MockHttpFetcherTest : public AnyHttpFetcherTest {
@@ -264,11 +265,11 @@
proxy_resolver_.set_num_proxies(num_proxies);
LibcurlHttpFetcher *ret = new
LibcurlHttpFetcher(reinterpret_cast<ProxyResolver*>(&proxy_resolver_),
- &fake_system_state_);
+ &fake_hardware_);
// Speed up test execution.
ret->set_idle_seconds(1);
ret->set_retry_seconds(1);
- fake_system_state_.fake_hardware()->SetIsOfficialBuild(false);
+ fake_hardware_.SetIsOfficialBuild(false);
return ret;
}
@@ -313,13 +314,13 @@
reinterpret_cast<ProxyResolver*>(&proxy_resolver_);
MultiRangeHttpFetcher *ret =
new MultiRangeHttpFetcher(
- new LibcurlHttpFetcher(resolver, &fake_system_state_));
+ new LibcurlHttpFetcher(resolver, &fake_hardware_));
ret->ClearRanges();
ret->AddRange(0);
// Speed up test execution.
ret->set_idle_seconds(1);
ret->set_retry_seconds(1);
- fake_system_state_.fake_hardware()->SetIsOfficialBuild(false);
+ fake_hardware_.SetIsOfficialBuild(false);
return ret;
}