Import Cobalt 21.master.0.299983
Includes the following patches:
https://cobalt-review.googlesource.com/c/cobalt/+/6030
n1214.hwang@samsung.com
diff --git a/src/components/update_client/action_runner.cc b/src/components/update_client/action_runner.cc
index 490aeeb..11d5dc0 100644
--- a/src/components/update_client/action_runner.cc
+++ b/src/components/update_client/action_runner.cc
@@ -29,7 +29,7 @@
namespace {
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
void CleanupDirectory(base::FilePath& dir) {
std::stack<std::string> directories;
base::FileEnumerator file_enumerator(
@@ -123,7 +123,7 @@
}
void ActionRunner::RunCommand(const base::CommandLine& cmdline) {
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
CleanupDirectory(unpack_path_);
#else
base::DeleteFile(unpack_path_, true);
diff --git a/src/components/update_client/component.cc b/src/components/update_client/component.cc
index 8cd63fe..787ec2e 100644
--- a/src/components/update_client/component.cc
+++ b/src/components/update_client/component.cc
@@ -19,7 +19,7 @@
#include "base/values.h"
#include "components/update_client/action_runner.h"
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
#include "components/update_client/cobalt_slot_management.h"
#endif
@@ -92,7 +92,7 @@
// For Cobalt, don't delete the unpack_path, which is not a temp directory.
// Cobalt uses a dedicated installation slot obtained from the Installation
// Manager.
-#if !defined(OS_STARBOARD)
+#if !defined(STARBOARD)
base::DeleteFile(unpack_path, true);
#endif
const ErrorCategory error_category =
@@ -109,7 +109,7 @@
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
const base::FilePath& unpack_path,
const std::string& public_key,
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
const int installation_index,
#endif
const std::string& fingerprint,
@@ -117,7 +117,7 @@
InstallOnBlockingTaskRunnerCompleteCallback callback) {
DCHECK(base::DirectoryExists(unpack_path));
-#if !defined(OS_STARBOARD)
+#if !defined(STARBOARD)
// Acquire the ownership of the |unpack_path|.
base::ScopedTempDir unpack_path_owner;
ignore_result(unpack_path_owner.Set(unpack_path));
@@ -135,7 +135,7 @@
return;
}
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
InstallError install_error = InstallError::NONE;
const CobaltExtensionInstallationManagerApi* installation_api =
static_cast<const CobaltExtensionInstallationManagerApi*>(
@@ -177,7 +177,7 @@
void UnpackCompleteOnBlockingTaskRunner(
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
const base::FilePath& crx_path,
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
const int installation_index,
PersistedData* metadata,
const std::string& id,
@@ -188,14 +188,14 @@
InstallOnBlockingTaskRunnerCompleteCallback callback,
const ComponentUnpacker::Result& result) {
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
base::DeleteFile(crx_path, false);
#else
update_client::DeleteFileAndEmptyParentDirectory(crx_path);
#endif
if (result.error != UnpackerError::kNone) {
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
// When there is an error unpacking the downloaded CRX, such as a failure to
// verify the package, we should remember to clear out any drain files.
if (base::DirectoryExists(crx_path.DirName())) {
@@ -210,7 +210,7 @@
return;
}
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
// Write the version of the unpacked update package to the persisted data.
if (metadata != nullptr) {
main_task_runner->PostTask(
@@ -223,7 +223,7 @@
FROM_HERE, kTaskTraits,
base::BindOnce(&InstallOnBlockingTaskRunner, main_task_runner,
result.unpack_path, result.public_key,
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
installation_index,
#endif
fingerprint, installer, std::move(callback)));
@@ -233,7 +233,7 @@
scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
const std::vector<uint8_t>& pk_hash,
const base::FilePath& crx_path,
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
const int installation_index,
PersistedData* metadata,
const std::string& id,
@@ -251,7 +251,7 @@
unpacker->Unpack(base::BindOnce(&UnpackCompleteOnBlockingTaskRunner,
main_task_runner, crx_path,
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
installation_index, metadata, id, version,
#endif
fingerprint, installer, std::move(callback)));
@@ -560,7 +560,7 @@
auto& component = State::component();
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
auto& config = component.update_context_.config;
config->SetPreviousUpdaterStatus(config->GetUpdaterStatus());
#endif
@@ -604,7 +604,7 @@
DCHECK(thread_checker_.CalledOnValidThread());
auto& component = State::component();
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
auto& config = component.update_context_.config;
auto metadata = component.update_context_.update_checker->GetPersistedData();
if (metadata != nullptr) {
@@ -734,9 +734,14 @@
DCHECK(component.crx_component());
+#if defined(STARBOARD)
+ crx_downloader_ = update_context.crx_downloader_factory(
+ component.CanDoBackgroundDownload(), update_context.config);
+#else
crx_downloader_ = update_context.crx_downloader_factory(
component.CanDoBackgroundDownload(),
update_context.config->GetNetworkFetcherFactory());
+#endif
const auto& id = component.id_;
crx_downloader_->set_progress_callback(
@@ -781,7 +786,7 @@
component.crx_path_ = download_result.response;
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
component.installation_index_ = download_result.installation_index;
#endif
@@ -803,9 +808,14 @@
DCHECK(component.crx_component());
+#if defined(STARBOARD)
+ crx_downloader_ = update_context.crx_downloader_factory(
+ component.CanDoBackgroundDownload(), update_context.config);
+#else
crx_downloader_ = update_context.crx_downloader_factory(
component.CanDoBackgroundDownload(),
update_context.config->GetNetworkFetcherFactory());
+#endif
const auto& id = component.id_;
crx_downloader_->set_progress_callback(
@@ -851,7 +861,7 @@
component.crx_path_ = download_result.response;
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
component.installation_index_ = download_result.installation_index;
#endif
@@ -882,7 +892,7 @@
&update_client::StartInstallOnBlockingTaskRunner,
base::ThreadTaskRunnerHandle::Get(),
component.crx_component()->pk_hash, component.crx_path_,
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
component.installation_index_,
update_context.update_checker->GetPersistedData(), component.id_,
component.next_version_.GetString(),
@@ -948,7 +958,7 @@
&update_client::StartInstallOnBlockingTaskRunner,
base::ThreadTaskRunnerHandle::Get(),
component.crx_component()->pk_hash, component.crx_path_,
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
component.installation_index_,
update_context.update_checker->GetPersistedData(),
component.id_, component.next_version_.GetString(),
diff --git a/src/components/update_client/component.h b/src/components/update_client/component.h
index 0f9b973..4058985 100644
--- a/src/components/update_client/component.h
+++ b/src/components/update_client/component.h
@@ -25,7 +25,7 @@
#include "components/update_client/update_client.h"
#include "url/gurl.h"
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
#include "cobalt/extension/installation_manager.h"
#endif
@@ -428,7 +428,7 @@
base::FilePath crx_path_;
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
int installation_index_ = IM_EXT_INVALID_INDEX;
#endif
diff --git a/src/components/update_client/component_patcher_operation.cc b/src/components/update_client/component_patcher_operation.cc
index e07a216..01ec312 100644
--- a/src/components/update_client/component_patcher_operation.cc
+++ b/src/components/update_client/component_patcher_operation.cc
@@ -150,7 +150,7 @@
}
void DeltaUpdateOpCreate::DoRun(ComponentPatcher::Callback callback) {
-#if !defined(OS_STARBOARD)
+#if !defined(STARBOARD)
if (!base::Move(patch_abs_path_, output_abs_path_))
std::move(callback).Run(UnpackerError::kDeltaOperationFailure, 0);
else
diff --git a/src/components/update_client/component_unpacker.cc b/src/components/update_client/component_unpacker.cc
index 6741456..15dbf50 100644
--- a/src/components/update_client/component_unpacker.cc
+++ b/src/components/update_client/component_unpacker.cc
@@ -84,7 +84,7 @@
// Mind the reference to non-const type, passed as an argument below.
base::FilePath& destination = is_delta_ ? unpack_diff_path_ : unpack_path_;
-#if !defined(OS_STARBOARD)
+#if !defined(STARBOARD)
if (!base::CreateNewTempDirectory(base::FilePath::StringType(),
&destination)) {
VLOG(1) << "Unable to create temporary directory for unpacking.";
@@ -147,7 +147,7 @@
}
void ComponentUnpacker::EndUnpacking() {
-#if !defined(OS_STARBOARD)
+#if !defined(STARBOARD)
if (!unpack_diff_path_.empty())
base::DeleteFile(unpack_diff_path_, true);
if (error_ != UnpackerError::kNone && !unpack_path_.empty())
diff --git a/src/components/update_client/configurator.h b/src/components/update_client/configurator.h
index 64d931a..16fd982 100644
--- a/src/components/update_client/configurator.h
+++ b/src/components/update_client/configurator.h
@@ -166,7 +166,7 @@
// Chrome update functionality.
virtual RecoveryCRXElevator GetRecoveryCRXElevator() const = 0;
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
// Sets the value we use for the "updaterchannel=" and "prodchannel="
// parameters.
virtual void SetChannel(const std::string& channel) = 0;
@@ -175,6 +175,7 @@
virtual void SetPreviousUpdaterStatus(const std::string& status) = 0;
virtual std::string GetUpdaterStatus() const = 0;
+ virtual void SetUpdaterStatus(const std::string& status) = 0;
// Compare and swap the is_channel_changed flag.
virtual void CompareAndSwapChannelChanged(int old_value, int new_value) = 0;
diff --git a/src/components/update_client/crx_downloader.cc b/src/components/update_client/crx_downloader.cc
index abe1e3e..fe83b57 100644
--- a/src/components/update_client/crx_downloader.cc
+++ b/src/components/update_client/crx_downloader.cc
@@ -34,11 +34,19 @@
// On Windows, the first downloader in the chain is a background downloader,
// which uses the BITS service.
+#if defined(STARBOARD)
+std::unique_ptr<CrxDownloader> CrxDownloader::Create(
+ bool is_background_download,
+ scoped_refptr<Configurator> config) {
+ std::unique_ptr<CrxDownloader> url_fetcher_downloader =
+ std::make_unique<UrlFetcherDownloader>(nullptr, config);
+#else
std::unique_ptr<CrxDownloader> CrxDownloader::Create(
bool is_background_download,
scoped_refptr<NetworkFetcherFactory> network_fetcher_factory) {
std::unique_ptr<CrxDownloader> url_fetcher_downloader =
std::make_unique<UrlFetcherDownloader>(nullptr, network_fetcher_factory);
+#endif
#if defined(OS_WIN)
if (is_background_download) {
@@ -160,7 +168,7 @@
// handling the error.
result.error = static_cast<int>(CrxDownloaderError::BAD_HASH);
download_metrics.error = result.error;
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
base::DeleteFile(result.response, false);
#else
DeleteFileAndEmptyParentDirectory(result.response);
@@ -184,7 +192,7 @@
download_metrics_.push_back(download_metrics);
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
if (result.error != static_cast<int>(CrxDownloaderError::SLOT_UNAVAILABLE)) {
#endif
@@ -212,7 +220,7 @@
return;
}
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
}
#endif
diff --git a/src/components/update_client/crx_downloader.h b/src/components/update_client/crx_downloader.h
index 966ee82..6378d03 100644
--- a/src/components/update_client/crx_downloader.h
+++ b/src/components/update_client/crx_downloader.h
@@ -19,8 +19,9 @@
#include "base/threading/thread_checker.h"
#include "url/gurl.h"
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
#include "cobalt/extension/installation_manager.h"
+#include "components/update_client/configurator.h"
#endif
namespace update_client {
@@ -61,7 +62,7 @@
// Download error: 0 indicates success.
int error = 0;
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
int installation_index = IM_EXT_INVALID_INDEX;
#endif
@@ -81,18 +82,30 @@
// different urls and different downloaders.
using ProgressCallback = base::RepeatingCallback<void()>;
+#if defined(STARBOARD)
+ using Factory =
+ std::unique_ptr<CrxDownloader> (*)(bool,
+ scoped_refptr<Configurator> config);
+#else
using Factory =
std::unique_ptr<CrxDownloader> (*)(bool,
scoped_refptr<NetworkFetcherFactory>);
+#endif
- // Factory method to create an instance of this class and build the
- // chain of responsibility. |is_background_download| specifies that a
- // background downloader be used, if the platform supports it.
- // |task_runner| should be a task runner able to run blocking
- // code such as file IO operations.
+// Factory method to create an instance of this class and build the
+// chain of responsibility. |is_background_download| specifies that a
+// background downloader be used, if the platform supports it.
+// |task_runner| should be a task runner able to run blocking
+// code such as file IO operations.
+#if defined(STARBOARD)
+ static std::unique_ptr<CrxDownloader> Create(
+ bool is_background_download,
+ scoped_refptr<Configurator> config);
+#else
static std::unique_ptr<CrxDownloader> Create(
bool is_background_download,
scoped_refptr<NetworkFetcherFactory> network_fetcher_factory);
+#endif
virtual ~CrxDownloader();
void set_progress_callback(const ProgressCallback& progress_callback);
diff --git a/src/components/update_client/persisted_data.cc b/src/components/update_client/persisted_data.cc
index c14bb03..2928b2e 100644
--- a/src/components/update_client/persisted_data.cc
+++ b/src/components/update_client/persisted_data.cc
@@ -80,7 +80,7 @@
return !result.empty() ? base::StringPrintf("{%s}", result.c_str()) : result;
}
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
std::string PersistedData::GetLastUnpackedVersion(const std::string& id) const {
return GetString(id, "version");
}
@@ -144,7 +144,7 @@
value);
}
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
void PersistedData::SetLastUnpackedVersion(const std::string& id,
const std::string& version) {
SetString(id, "version", version);
diff --git a/src/components/update_client/persisted_data.h b/src/components/update_client/persisted_data.h
index 4853d39..84efa3e 100644
--- a/src/components/update_client/persisted_data.h
+++ b/src/components/update_client/persisted_data.h
@@ -50,7 +50,7 @@
// -2 indicates that the |id| has an unknown value of last active date.
int GetDateLastActive(const std::string& id) const;
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
// Returns the version of the update that was last successfully unpacked for
// the specified |id|. "" indicates that there is no recorded version value
// for the |id|.
@@ -81,7 +81,7 @@
// are set.
void SetDateLastActive(const std::vector<std::string>& ids, int datenum);
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
// Records the version of the update that is successfully unpacked for
// the specified |id|.
void SetLastUnpackedVersion(const std::string& id,
diff --git a/src/components/update_client/protocol_serializer.cc b/src/components/update_client/protocol_serializer.cc
index a03ff79..4453d8e 100644
--- a/src/components/update_client/protocol_serializer.cc
+++ b/src/components/update_client/protocol_serializer.cc
@@ -41,7 +41,7 @@
const auto ver = base::win::OSInfo::GetInstance()->version_number();
return base::StringPrintf("%d.%d.%d.%d", ver.major, ver.minor, ver.build,
ver.patch);
-#elif defined(OS_STARBOARD)
+#elif defined(STARBOARD)
// TODO: fill in OS version.
return "";
#else
@@ -130,7 +130,7 @@
request.os.platform = os_long_name;
request.os.version = GetOSVersion();
request.os.service_pack = GetServicePack();
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
// TODO: fill in arch.
request.os.arch = "";
#else
diff --git a/src/components/update_client/update_checker.cc b/src/components/update_client/update_checker.cc
index 3cfa2d5..1e7eed4 100644
--- a/src/components/update_client/update_checker.cc
+++ b/src/components/update_client/update_checker.cc
@@ -22,7 +22,7 @@
#include "base/threading/thread_checker.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
#include "cobalt/extension/installation_manager.h"
#include "cobalt/updater/utils.h"
#include "components/update_client/cobalt_slot_management.h"
@@ -87,7 +87,7 @@
bool enabled_component_updates,
UpdateCheckCallback update_check_callback) override;
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
PersistedData* GetPersistedData() override { return metadata_; }
#endif
@@ -203,7 +203,7 @@
!enabled_component_updates;
base::Version current_version = crx_component->version;
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
std::string unpacked_version =
GetPersistedData()->GetLastUnpackedVersion(app_id);
// If the version of the last unpacked update package is higher than the
@@ -224,6 +224,14 @@
}
if (CobaltQuickUpdate(installation_api, current_version)) {
+ // The last parameter in UpdateCheckFailed below, which is to be passed to
+ // update_check_callback_, indicates a throttling by the update server.
+ // Only non-negative values are valid. Negative values are not trusted
+ // and are ignored.
+ UpdateCheckFailed(ErrorCategory::kUpdateCheck,
+ static_cast<int>(UpdateCheckError::QUICK_ROLL_FORWARD),
+ -1);
+
return;
}
@@ -260,7 +268,7 @@
config_->EnabledCupSigning(),
base::BindOnce(&UpdateCheckerImpl::OnRequestSenderComplete,
base::Unretained(this)));
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
// Reset is_channel_changed flag to false if it is true
config_->CompareAndSwapChannelChanged(1, 0);
#endif
diff --git a/src/components/update_client/update_checker.h b/src/components/update_client/update_checker.h
index 30e4fba..9a53357 100644
--- a/src/components/update_client/update_checker.h
+++ b/src/components/update_client/update_checker.h
@@ -55,7 +55,7 @@
scoped_refptr<Configurator> config,
PersistedData* persistent);
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
virtual PersistedData* GetPersistedData() = 0;
#endif
diff --git a/src/components/update_client/update_client.gyp b/src/components/update_client/update_client.gyp
index 123932b..3b9edd7 100644
--- a/src/components/update_client/update_client.gyp
+++ b/src/components/update_client/update_client.gyp
@@ -89,6 +89,7 @@
'<(DEPTH)/components/client_update_protocol/client_update_protocol.gyp:client_update_protocol',
'<(DEPTH)/components/prefs/prefs.gyp:prefs',
'<(DEPTH)/crypto/crypto.gyp:crypto',
+ '<(DEPTH)/net/net.gyp:net',
'<(DEPTH)/starboard/loader_app/app_key_files.gyp:app_key_files',
'<(DEPTH)/starboard/loader_app/drain_file.gyp:drain_file',
'<(DEPTH)/third_party/libxml/libxml.gyp:libxml',
diff --git a/src/components/update_client/update_client_errors.h b/src/components/update_client/update_client_errors.h
index cf2d0db..db08a24 100644
--- a/src/components/update_client/update_client_errors.h
+++ b/src/components/update_client/update_client_errors.h
@@ -37,7 +37,7 @@
// the Chrome net stack.
enum class CrxDownloaderError {
NONE = 0,
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
SLOT_UNAVAILABLE = 9,
#endif
NO_URL = 10,
@@ -97,6 +97,17 @@
UPDATE_DISABLED = 2,
};
+// These errors are returned with the |kUpdateCheck| error category and indicate
+// an error during an update check.
+#if defined(STARBOARD)
+enum class UpdateCheckError {
+ NONE = 0,
+ // Using 21 that doesn't conflict with the exsiting error codes and stays away
+ // from the other codes below 20.
+ QUICK_ROLL_FORWARD = 21,
+};
+#endif
+
// These errors are related to serialization, deserialization, and parsing of
// protocol requests.
// The begin value for this enum is chosen not to conflict with network errors
diff --git a/src/components/update_client/update_query_params.cc b/src/components/update_client/update_query_params.cc
index f921da1..4935c95 100644
--- a/src/components/update_client/update_query_params.cc
+++ b/src/components/update_client/update_query_params.cc
@@ -37,7 +37,7 @@
"fuchsia";
#elif defined(OS_OPENBSD)
"openbsd";
-#elif defined(OS_STARBOARD)
+#elif defined(STARBOARD)
"starboard";
#else
#error "unknown os"
@@ -79,7 +79,7 @@
return base::StringPrintf(
"os=%s&arch=%s&os_arch=%s&nacl_arch=%s&prod=%s%s&acceptformat=crx2,crx3",
kOs, kArch,
-#if !defined(OS_STARBOARD)
+#if !defined(STARBOARD)
base::SysInfo().OperatingSystemArchitecture().c_str(),
#else
"",
diff --git a/src/components/update_client/url_fetcher_downloader.cc b/src/components/update_client/url_fetcher_downloader.cc
index 0890c63..2959a57 100644
--- a/src/components/update_client/url_fetcher_downloader.cc
+++ b/src/components/update_client/url_fetcher_downloader.cc
@@ -19,15 +19,20 @@
#include "base/task/task_traits.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/values.h"
+#if defined(STARBOARD)
+#include "cobalt/updater/updater_module.h"
+#endif
#include "components/update_client/network.h"
#include "components/update_client/utils.h"
-
-
#include "url/gurl.h"
namespace {
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
+
+using cobalt::updater::UpdaterStatus;
+using cobalt::updater::updater_status_string_map;
+
void CleanupDirectory(base::FilePath& dir) {
std::stack<std::string> directories;
base::FileEnumerator file_enumerator(
@@ -59,18 +64,27 @@
namespace update_client {
+#if defined(STARBOARD)
+UrlFetcherDownloader::UrlFetcherDownloader(
+ std::unique_ptr<CrxDownloader> successor,
+ scoped_refptr<Configurator> config)
+ : CrxDownloader(std::move(successor)),
+ config_(config),
+ network_fetcher_factory_(config->GetNetworkFetcherFactory()) {}
+#else
UrlFetcherDownloader::UrlFetcherDownloader(
std::unique_ptr<CrxDownloader> successor,
scoped_refptr<NetworkFetcherFactory> network_fetcher_factory)
: CrxDownloader(std::move(successor)),
network_fetcher_factory_(network_fetcher_factory) {
}
+#endif
UrlFetcherDownloader::~UrlFetcherDownloader() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
}
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
void UrlFetcherDownloader::ConfirmSlot(const GURL& url) {
SB_LOG(INFO) << "UrlFetcherDownloader::ConfirmSlot: url=" << url;
if (!cobalt_slot_management_.ConfirmSlot(download_dir_)) {
@@ -89,6 +103,8 @@
ReportDownloadFailure(url, CrxDownloaderError::SLOT_UNAVAILABLE);
return;
}
+ config_->SetUpdaterStatus(std::string(
+ updater_status_string_map.find(UpdaterStatus::kSlotLocked)->second));
// Use 15 sec delay to allow for other updaters/loaders to settle down.
base::SequencedTaskRunnerHandle::Get()->PostDelayedTask(
@@ -102,7 +118,7 @@
void UrlFetcherDownloader::DoStartDownload(const GURL& url) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
const CobaltExtensionInstallationManagerApi* installation_api =
static_cast<const CobaltExtensionInstallationManagerApi*>(
SbSystemGetExtension(kCobaltExtensionInstallationManagerName));
@@ -133,7 +149,7 @@
&download_dir_);
}
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
void UrlFetcherDownloader::ReportDownloadFailure(const GURL& url) {
ReportDownloadFailure(url, CrxDownloaderError::GENERIC_ERROR);
}
@@ -144,11 +160,11 @@
void UrlFetcherDownloader::ReportDownloadFailure(const GURL& url) {
#endif
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
cobalt_slot_management_.CleanupAllDrainFiles(download_dir_);
#endif
Result result;
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
result.error = static_cast<int>(error);
#else
result.error = -1;
@@ -171,13 +187,13 @@
void UrlFetcherDownloader::StartURLFetch(const GURL& url) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
SB_LOG(INFO) << "UrlFetcherDownloader::StartURLFetch: url" << url
<< " download_dir=" << download_dir_;
#endif
if (download_dir_.empty()) {
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
SB_LOG(ERROR) << "UrlFetcherDownloader::StartURLFetch: failed with empty "
"download_dir";
#endif
@@ -229,7 +245,7 @@
result.error = error;
if (!error) {
result.response = file_path;
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
result.installation_index = cobalt_slot_management_.GetInstallationIndex();
#endif
}
@@ -247,7 +263,7 @@
<< download_time.InMilliseconds() << "ms from " << final_url_.spec()
<< " to " << result.response.value();
-#if !defined(OS_STARBOARD)
+#if !defined(STARBOARD)
// Delete the download directory in the error cases.
if (error && !download_dir_.empty())
base::PostTaskWithTraits(
diff --git a/src/components/update_client/url_fetcher_downloader.h b/src/components/update_client/url_fetcher_downloader.h
index 1f335e9..e5c240d 100644
--- a/src/components/update_client/url_fetcher_downloader.h
+++ b/src/components/update_client/url_fetcher_downloader.h
@@ -17,7 +17,7 @@
#include "components/update_client/crx_downloader.h"
#include "components/update_client/update_client_errors.h"
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
#include "components/update_client/cobalt_slot_management.h"
#endif
@@ -29,9 +29,14 @@
// Implements a CRX downloader using a NetworkFetcher object.
class UrlFetcherDownloader : public CrxDownloader {
public:
+#if defined(STARBOARD)
+ UrlFetcherDownloader(std::unique_ptr<CrxDownloader> successor,
+ scoped_refptr<Configurator> config);
+#else
UrlFetcherDownloader(
std::unique_ptr<CrxDownloader> successor,
scoped_refptr<NetworkFetcherFactory> network_fetcher_factory);
+#endif
~UrlFetcherDownloader() override;
private:
@@ -41,7 +46,7 @@
void CreateDownloadDir();
void StartURLFetch(const GURL& url);
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
void SelectSlot(const GURL& url);
void ConfirmSlot(const GURL& url);
#endif
@@ -53,7 +58,7 @@
int64_t content_length);
void OnDownloadProgress(int64_t content_length);
void ReportDownloadFailure(const GURL& url);
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
void ReportDownloadFailure(const GURL& url, CrxDownloaderError error);
#endif
@@ -71,8 +76,9 @@
int response_code_ = -1;
int64_t total_bytes_ = -1;
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
CobaltSlotManagement cobalt_slot_management_;
+ scoped_refptr<Configurator> config_;
#endif
DISALLOW_COPY_AND_ASSIGN(UrlFetcherDownloader);
diff --git a/src/components/update_client/utils.cc b/src/components/update_client/utils.cc
index bcedb8a..2a9b45a 100644
--- a/src/components/update_client/utils.cc
+++ b/src/components/update_client/utils.cc
@@ -63,7 +63,7 @@
return result;
}
-#if defined(OS_STARBOARD)
+#if defined(STARBOARD)
bool VerifyFileHash256(const base::FilePath& filepath,
const std::string& expected_hash_str) {
std::vector<uint8_t> expected_hash;