Commit e4e843cd authored by Henrique Ferreiro's avatar Henrique Ferreiro Committed by Chromium LUCI CQ

Make KioskExternalUpdater::ExternalUpdateErrorCode an enum class

This CL is part of the Chrome OS source code directory migration:
https://docs.google.com/document/d/1g-98HpzA8XcoGBWUv1gQNr4rbnD5yfvbtYZyPDDbkaE.

Bug: 1101837, 1164001
Change-Id: Ia0449cb26c992a3c410f0de71812185974c8ecff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2640234Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Cr-Commit-Position: refs/heads/master@{#845570}
parent d8072c0b
...@@ -33,11 +33,12 @@ constexpr char kExternalCrx[] = "external_crx"; ...@@ -33,11 +33,12 @@ constexpr char kExternalCrx[] = "external_crx";
constexpr char kExternalVersion[] = "external_version"; constexpr char kExternalVersion[] = "external_version";
std::pair<std::unique_ptr<base::DictionaryValue>, std::pair<std::unique_ptr<base::DictionaryValue>,
KioskExternalUpdater::ExternalUpdateErrorCode> KioskExternalUpdater::ErrorCode>
ParseExternalUpdateManifest(const base::FilePath& external_update_dir) { ParseExternalUpdateManifest(const base::FilePath& external_update_dir) {
base::FilePath manifest = external_update_dir.Append(kExternalUpdateManifest); base::FilePath manifest = external_update_dir.Append(kExternalUpdateManifest);
if (!base::PathExists(manifest)) { if (!base::PathExists(manifest)) {
return std::make_pair(nullptr, KioskExternalUpdater::ERROR_NO_MANIFEST); return std::make_pair(nullptr,
KioskExternalUpdater::ErrorCode::kNoManifest);
} }
JSONFileValueDeserializer deserializer(manifest); JSONFileValueDeserializer deserializer(manifest);
...@@ -45,11 +46,11 @@ ParseExternalUpdateManifest(const base::FilePath& external_update_dir) { ...@@ -45,11 +46,11 @@ ParseExternalUpdateManifest(const base::FilePath& external_update_dir) {
base::DictionaryValue::From(deserializer.Deserialize(nullptr, nullptr)); base::DictionaryValue::From(deserializer.Deserialize(nullptr, nullptr));
if (!extensions) { if (!extensions) {
return std::make_pair(nullptr, return std::make_pair(nullptr,
KioskExternalUpdater::ERROR_INVALID_MANIFEST); KioskExternalUpdater::ErrorCode::kInvalidManifest);
} }
return std::make_pair(std::move(extensions), return std::make_pair(std::move(extensions),
KioskExternalUpdater::ERROR_NONE); KioskExternalUpdater::ErrorCode::kNone);
} }
// Copies |external_crx_file| to |temp_crx_file|, and removes |temp_dir| // Copies |external_crx_file| to |temp_crx_file|, and removes |temp_dir|
...@@ -202,12 +203,12 @@ void KioskExternalUpdater::ProcessParsedManifest( ...@@ -202,12 +203,12 @@ void KioskExternalUpdater::ProcessParsedManifest(
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
const std::unique_ptr<base::DictionaryValue>& parsed_manifest = result.first; const std::unique_ptr<base::DictionaryValue>& parsed_manifest = result.first;
ExternalUpdateErrorCode parsing_error = result.second; ErrorCode parsing_error = result.second;
if (parsing_error == ERROR_NO_MANIFEST) { if (parsing_error == ErrorCode::kNoManifest) {
KioskAppManager::Get()->OnKioskAppExternalUpdateComplete(false); KioskAppManager::Get()->OnKioskAppExternalUpdateComplete(false);
return; return;
} }
if (parsing_error == ERROR_INVALID_MANIFEST) { if (parsing_error == ErrorCode::kInvalidManifest) {
NotifyKioskUpdateProgress( NotifyKioskUpdateProgress(
ui::ResourceBundle::GetSharedInstance().GetLocalizedString( ui::ResourceBundle::GetSharedInstance().GetLocalizedString(
IDS_KIOSK_EXTERNAL_UPDATE_INVALID_MANIFEST)); IDS_KIOSK_EXTERNAL_UPDATE_INVALID_MANIFEST));
......
...@@ -26,10 +26,10 @@ class KioskExternalUpdateNotification; ...@@ -26,10 +26,10 @@ class KioskExternalUpdateNotification;
class KioskExternalUpdater : public disks::DiskMountManager::Observer, class KioskExternalUpdater : public disks::DiskMountManager::Observer,
public KioskExternalUpdateValidatorDelegate { public KioskExternalUpdateValidatorDelegate {
public: public:
enum ExternalUpdateErrorCode { enum class ErrorCode {
ERROR_NONE, kNone,
ERROR_NO_MANIFEST, kNoManifest,
ERROR_INVALID_MANIFEST, kInvalidManifest,
}; };
KioskExternalUpdater( KioskExternalUpdater(
...@@ -69,10 +69,10 @@ class KioskExternalUpdater : public disks::DiskMountManager::Observer, ...@@ -69,10 +69,10 @@ class KioskExternalUpdater : public disks::DiskMountManager::Observer,
const base::FilePath& temp_dir) override; const base::FilePath& temp_dir) override;
void OnExternalUpdateUnpackFailure(const std::string& app_id) override; void OnExternalUpdateUnpackFailure(const std::string& app_id) override;
// Processes the parsed external update manifest, check the // Processes the parsed external update manifest, check the ErrorCode in
// ExternalUpdateErrorCode in |result| for any manifest parsing error. // |result| for any manifest parsing error.
using ParseManifestResult = std::pair<std::unique_ptr<base::DictionaryValue>, using ParseManifestResult =
ExternalUpdateErrorCode>; std::pair<std::unique_ptr<base::DictionaryValue>, ErrorCode>;
void ProcessParsedManifest(const base::FilePath& external_update_dir, void ProcessParsedManifest(const base::FilePath& external_update_dir,
const ParseManifestResult& result); const ParseManifestResult& result);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment