Mechanical refactoring of error codes in the component updater.
The change consolidates the errors in components/update_client and
makes the error types more type safe.
[email protected]
BUG=615669
Review-Url: https://codereview.chromium.org/2463433003
Cr-Commit-Position: refs/heads/master@{#429348}
diff --git a/components/component_updater/component_updater_service_unittest.cc b/components/component_updater/component_updater_service_unittest.cc
index caac5add..47c7982 100644
--- a/components/component_updater/component_updater_service_unittest.cc
+++ b/components/component_updater/component_updater_service_unittest.cc
@@ -25,6 +25,7 @@
#include "components/update_client/test_configurator.h"
#include "components/update_client/test_installer.h"
#include "components/update_client/update_client.h"
+#include "components/update_client/update_client_errors.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -129,12 +130,12 @@
class OnDemandTester {
public:
void OnDemand(ComponentUpdateService* cus, const std::string& id);
- int error() const { return error_; }
+ update_client::Error error() const { return error_; }
private:
- void OnDemandComplete(int error);
+ void OnDemandComplete(update_client::Error error);
- int error_ = 0;
+ update_client::Error error_ = update_client::Error::NONE;
};
MockInstaller::MockInstaller() {
@@ -162,7 +163,7 @@
base::Bind(&OnDemandTester::OnDemandComplete, base::Unretained(this)));
}
-void OnDemandTester::OnDemandComplete(int error) {
+void OnDemandTester::OnDemandComplete(update_client::Error error) {
error_ = error;
}
@@ -228,7 +229,7 @@
void OnUpdate(const std::vector<std::string>& ids,
const UpdateClient::CrxDataCallback& crx_data_callback,
const UpdateClient::CompletionCallback& completion_callback) {
- completion_callback.Run(0);
+ completion_callback.Run(update_client::Error::NONE);
static int cnt = 0;
++cnt;
if (cnt >= max_cnt_)
@@ -287,13 +288,13 @@
TEST_F(ComponentUpdaterTest, OnDemandUpdate) {
class LoopHandler {
public:
- LoopHandler(int max_cnt) : max_cnt_(max_cnt) {}
+ explicit LoopHandler(int max_cnt) : max_cnt_(max_cnt) {}
void OnInstall(
const std::string& ids,
const UpdateClient::CrxDataCallback& crx_data_callback,
const UpdateClient::CompletionCallback& completion_callback) {
- completion_callback.Run(0);
+ completion_callback.Run(update_client::Error::NONE);
static int cnt = 0;
++cnt;
if (cnt >= max_cnt_) {
@@ -342,10 +343,9 @@
base::RunLoop().Run();
- EXPECT_EQ(
- static_cast<int>(update_client::Error::ERROR_UPDATE_INVALID_ARGUMENT),
- ondemand_tester_component_not_registered.error());
- EXPECT_EQ(0, ondemand_tester.error());
+ EXPECT_EQ(update_client::Error::INVALID_ARGUMENT,
+ ondemand_tester_component_not_registered.error());
+ EXPECT_EQ(update_client::Error::NONE, ondemand_tester.error());
ht.ExpectUniqueSample("ComponentUpdater.Calls", 0, 1);
ht.ExpectUniqueSample("ComponentUpdater.UpdateCompleteResult", 0, 1);
@@ -363,7 +363,7 @@
const std::string& ids,
const UpdateClient::CrxDataCallback& crx_data_callback,
const UpdateClient::CompletionCallback& completion_callback) {
- completion_callback.Run(0);
+ completion_callback.Run(update_client::Error::NONE);
static int cnt = 0;
++cnt;
if (cnt >= max_cnt_)