Import Cobalt 22.master.0.306106
diff --git a/components/prefs/pref_service.cc b/components/prefs/pref_service.cc
index 624a78f..a59c614 100644
--- a/components/prefs/pref_service.cc
+++ b/components/prefs/pref_service.cc
@@ -97,6 +97,9 @@
user_pref_store_(std::move(user_prefs)),
read_error_callback_(std::move(read_error_callback)),
pref_registry_(std::move(pref_registry)) {
+#if defined(STARBOARD)
+ LOG(INFO) << "PrefService::PrefService";
+#endif
pref_notifier_->SetPrefService(this);
DCHECK(pref_registry_);
@@ -106,6 +109,9 @@
}
PrefService::~PrefService() {
+#if defined(STARBOARD)
+ LOG(INFO) << "PrefService::~PrefService";
+#endif
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// TODO(crbug.com/942491, 946668, 945772) The following code collects
diff --git a/components/update_client/cobalt_slot_management.cc b/components/update_client/cobalt_slot_management.cc
index cc8856e..0c601d7 100644
--- a/components/update_client/cobalt_slot_management.cc
+++ b/components/update_client/cobalt_slot_management.cc
@@ -14,6 +14,8 @@
#include "components/update_client/cobalt_slot_management.h"
+#include <vector>
+
#include "base/values.h"
#include "cobalt/updater/utils.h"
#include "components/update_client/utils.h"
@@ -29,9 +31,9 @@
std::string bad_app_key_file_path =
starboard::loader_app::GetBadAppKeyFilePath(installation_path, app_key);
SB_DCHECK(!bad_app_key_file_path.empty());
- SB_LOG(INFO) << "bad_app_key_file_path: " << bad_app_key_file_path;
- SB_LOG(INFO) << "bad_app_key_file_path SbFileExists: "
- << SbFileExists(bad_app_key_file_path.c_str());
+ LOG(INFO) << "bad_app_key_file_path: " << bad_app_key_file_path;
+ LOG(INFO) << "bad_app_key_file_path SbFileExists: "
+ << SbFileExists(bad_app_key_file_path.c_str());
return !bad_app_key_file_path.empty() &&
SbFileExists(bad_app_key_file_path.c_str());
}
@@ -41,21 +43,21 @@
bool CobaltSlotManagement::Init(
const CobaltExtensionInstallationManagerApi* installation_api) {
- SB_LOG(INFO) << "CobaltSlotManagement::Init";
+ LOG(INFO) << "CobaltSlotManagement::Init";
installation_api_ = installation_api;
// Make sure the index is reset
installation_index_ = IM_EXT_INVALID_INDEX;
if (!installation_api_) {
- SB_LOG(ERROR) << "Failed to get installation manager";
+ LOG(ERROR) << "Failed to get installation manager";
return false;
}
char app_key[IM_EXT_MAX_APP_KEY_LENGTH];
if (installation_api_->GetAppKey(app_key, IM_EXT_MAX_APP_KEY_LENGTH) ==
IM_EXT_ERROR) {
- SB_LOG(ERROR) << "Failed to get app key.";
+ LOG(ERROR) << "Failed to get app key.";
return false;
}
app_key_ = app_key;
@@ -64,10 +66,10 @@
bool CobaltSlotManagement::SelectSlot(base::FilePath* dir) {
SB_DCHECK(installation_api_);
- SB_LOG(INFO) << "CobaltSlotManagement::SelectSlot";
+ LOG(INFO) << "CobaltSlotManagement::SelectSlot";
int max_slots = installation_api_->GetMaxNumberInstallations();
if (max_slots == IM_EXT_ERROR) {
- SB_LOG(ERROR) << "Failed to get max number of slots";
+ LOG(ERROR) << "Failed to get max number of slots";
return false;
}
@@ -78,14 +80,14 @@
// Iterate over all writeable slots - index >= 1.
for (int i = 1; i < max_slots; i++) {
- SB_LOG(INFO) << "CobaltSlotManagement::SelectSlot iterating slot=" << i;
+ LOG(INFO) << "CobaltSlotManagement::SelectSlot iterating slot=" << i;
std::vector<char> installation_path(kSbFileMaxPath);
if (installation_api_->GetInstallationPath(i, installation_path.data(),
installation_path.size()) ==
IM_EXT_ERROR) {
- SB_LOG(ERROR) << "CobaltSlotManagement::SelectSlot: Failed to get "
- "installation path for slot="
- << i;
+ LOG(ERROR) << "CobaltSlotManagement::SelectSlot: Failed to get "
+ "installation path for slot="
+ << i;
continue;
}
@@ -103,31 +105,29 @@
base::Version version =
cobalt::updater::ReadEvergreenVersion(installation_dir);
if (!version.IsValid()) {
- SB_LOG(INFO)
- << "CobaltSlotManagement::SelectSlot installed version invalid";
+ LOG(INFO) << "CobaltSlotManagement::SelectSlot installed version invalid";
if (!DrainFileDraining(installation_dir.value().c_str(), "")) {
- SB_LOG(INFO) << "CobaltSlotManagement::SelectSlot not draining";
+ LOG(INFO) << "CobaltSlotManagement::SelectSlot not draining";
// Found empty slot.
slot_candidate = i;
slot_candidate_path = installation_dir;
break;
} else {
// There is active draining from another updater so bail out.
- SB_LOG(ERROR) << "CobaltSlotManagement::SelectSlot bailing out";
+ LOG(ERROR) << "CobaltSlotManagement::SelectSlot bailing out";
return false;
}
} else if ((!slot_candidate_version.IsValid() ||
slot_candidate_version > version)) {
if (!DrainFileDraining(installation_dir.value().c_str(), "")) {
// Found a slot with older version that's not draining.
- SB_LOG(INFO) << "CobaltSlotManagement::SelectSlot slot candidate: "
- << i;
+ LOG(INFO) << "CobaltSlotManagement::SelectSlot slot candidate: " << i;
slot_candidate_version = version;
slot_candidate = i;
slot_candidate_path = installation_dir;
} else {
// There is active draining from another updater so bail out.
- SB_LOG(ERROR) << "CobaltSlotManagement::SelectSlot bailing out";
+ LOG(ERROR) << "CobaltSlotManagement::SelectSlot bailing out";
return false;
}
}
@@ -138,7 +138,7 @@
if (installation_index_ == -1 ||
!DrainFileTryDrain(dir->value().c_str(), app_key_.c_str())) {
- SB_LOG(ERROR)
+ LOG(ERROR)
<< "CobaltSlotManagement::SelectSlot unable to find a slot, candidate="
<< installation_index_;
return false;
@@ -148,19 +148,19 @@
bool CobaltSlotManagement::ConfirmSlot(const base::FilePath& dir) {
SB_DCHECK(installation_api_);
- SB_LOG(INFO) << "CobaltSlotManagement::ConfirmSlot ";
+ LOG(INFO) << "CobaltSlotManagement::ConfirmSlot ";
if (!DrainFileRankAndCheck(dir.value().c_str(), app_key_.c_str())) {
- SB_LOG(INFO) << "CobaltSlotManagement::ConfirmSlot: failed to lock slot ";
+ LOG(INFO) << "CobaltSlotManagement::ConfirmSlot: failed to lock slot ";
return false;
}
// TODO: Double check the installed_version.
// Use the installation slot
- SB_LOG(INFO) << "Resetting the slot: " << installation_index_;
+ LOG(INFO) << "Resetting the slot: " << installation_index_;
if (installation_api_->ResetInstallation(installation_index_) ==
IM_EXT_ERROR) {
- SB_LOG(INFO) << "CobaltSlotManagement::ConfirmSlot: failed to reset slot ";
+ LOG(INFO) << "CobaltSlotManagement::ConfirmSlot: failed to reset slot ";
return false;
}
@@ -189,13 +189,13 @@
starboard::loader_app::GetGoodAppKeyFilePath(dir, app_key);
SB_CHECK(!good_app_key_file_path.empty());
if (!starboard::loader_app::CreateAppKeyFile(good_app_key_file_path)) {
- SB_LOG(WARNING) << "Failed to create good app key file";
+ LOG(WARNING) << "Failed to create good app key file";
}
DrainFileRemove(dir.c_str(), app_key.c_str());
int ret =
installation_api->RequestRollForwardToInstallation(installation_index);
if (ret == IM_EXT_ERROR) {
- SB_LOG(ERROR) << "Failed to request roll forward.";
+ LOG(ERROR) << "Failed to request roll forward.";
return false;
}
return true;
@@ -210,13 +210,13 @@
char app_key[IM_EXT_MAX_APP_KEY_LENGTH];
if (installation_api->GetAppKey(app_key, IM_EXT_MAX_APP_KEY_LENGTH) ==
IM_EXT_ERROR) {
- SB_LOG(ERROR) << "CobaltQuickUpdate: Failed to get app key.";
+ LOG(ERROR) << "CobaltQuickUpdate: Failed to get app key.";
return true;
}
int max_slots = installation_api->GetMaxNumberInstallations();
if (max_slots == IM_EXT_ERROR) {
- SB_LOG(ERROR) << "CobaltQuickUpdate: Failed to get max number of slots.";
+ LOG(ERROR) << "CobaltQuickUpdate: Failed to get max number of slots.";
return true;
}
@@ -227,14 +227,14 @@
// Iterate over all writeable slots - index >= 1.
for (int i = 1; i < max_slots; i++) {
- SB_LOG(INFO) << "CobaltQuickInstallation: iterating slot=" << i;
+ LOG(INFO) << "CobaltQuickInstallation: iterating slot=" << i;
// Get the path to new installation.
std::vector<char> installation_path(kSbFileMaxPath);
if (installation_api->GetInstallationPath(i, installation_path.data(),
installation_path.size()) ==
IM_EXT_ERROR) {
- SB_LOG(ERROR) << "CobaltQuickInstallation: Failed to get "
- << "installation path for slot=" << i;
+ LOG(ERROR) << "CobaltQuickInstallation: Failed to get "
+ << "installation path for slot=" << i;
continue;
}
@@ -248,7 +248,7 @@
cobalt::updater::ReadEvergreenVersion(installation_dir);
if (!installed_version.IsValid()) {
- SB_LOG(WARNING) << "CobaltQuickInstallation: invalid version ";
+ LOG(WARNING) << "CobaltQuickInstallation: invalid version ";
continue;
} else if (slot_candidate_version < installed_version &&
current_version < installed_version &&
@@ -260,7 +260,7 @@
// draining, and no bad file of current app exists, and a good file
// exists. The final candidate is the newest version of the valid
// candidates.
- SB_LOG(INFO) << "CobaltQuickInstallation: slot candidate: " << i;
+ LOG(INFO) << "CobaltQuickInstallation: slot candidate: " << i;
slot_candidate_version = installed_version;
slot_candidate = i;
}
@@ -269,11 +269,11 @@
if (slot_candidate != -1) {
if (installation_api->RequestRollForwardToInstallation(slot_candidate) !=
IM_EXT_ERROR) {
- SB_LOG(INFO) << "CobaltQuickInstallation: quick update succeeded.";
+ LOG(INFO) << "CobaltQuickInstallation: quick update succeeded.";
return true;
}
}
- SB_LOG(WARNING) << "CobaltQuickInstallation: quick update failed.";
+ LOG(WARNING) << "CobaltQuickInstallation: quick update failed.";
return false;
}
diff --git a/components/update_client/cobalt_slot_management_test.cc b/components/update_client/cobalt_slot_management_test.cc
index f12f060..55256de 100644
--- a/components/update_client/cobalt_slot_management_test.cc
+++ b/components/update_client/cobalt_slot_management_test.cc
@@ -149,7 +149,7 @@
base::FilePath dir;
cobalt_slot_management.SelectSlot(&dir);
ASSERT_TRUE(DrainFileDraining(dir.value().c_str(), kTestAppKey1));
- SB_LOG(INFO) << "dir=" << dir;
+ LOG(INFO) << "dir=" << dir;
ASSERT_TRUE(base::EndsWith(dir.value(), "installation_2",
base::CompareCase::SENSITIVE));
@@ -169,7 +169,7 @@
ASSERT_TRUE(cobalt_slot_management.Init(api_));
base::FilePath dir;
ASSERT_TRUE(cobalt_slot_management.SelectSlot(&dir));
- SB_LOG(INFO) << "dir=" << dir;
+ LOG(INFO) << "dir=" << dir;
ASSERT_TRUE(base::EndsWith(dir.value(), "installation_1",
base::CompareCase::SENSITIVE));
diff --git a/components/update_client/component.cc b/components/update_client/component.cc
index 421dc40..d9158fc 100644
--- a/components/update_client/component.cc
+++ b/components/update_client/component.cc
@@ -15,6 +15,9 @@
#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/post_task.h"
+#if defined(STARBOARD)
+#include "base/threading/thread_id_name_manager.h"
+#endif
#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
#include "components/update_client/action_runner.h"
@@ -81,6 +84,10 @@
InstallOnBlockingTaskRunnerCompleteCallback callback,
const base::FilePath& unpack_path,
const CrxInstaller::Result& result) {
+#if defined(STARBOARD)
+ LOG(INFO) << "InstallComplete thread_name="
+ << base::ThreadIdNameManager::GetInstance()->GetNameForCurrentThread();
+#endif
base::PostTaskWithTraits(
FROM_HERE, {base::TaskPriority::BEST_EFFORT, base::MayBlock()},
base::BindOnce(
@@ -88,7 +95,10 @@
InstallOnBlockingTaskRunnerCompleteCallback callback,
const base::FilePath& unpack_path,
const CrxInstaller::Result& result) {
-
+#if defined(STARBOARD)
+ LOG(INFO) << "Closure kicked off from InstallComplete thread_name="
+ << base::ThreadIdNameManager::GetInstance()->GetNameForCurrentThread();
+#endif
// 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.
@@ -117,6 +127,11 @@
InstallOnBlockingTaskRunnerCompleteCallback callback) {
DCHECK(base::DirectoryExists(unpack_path));
+#if defined(STARBOARD)
+ LOG(INFO) << "InstallOnBlockingTaskRunner thread_name="
+ << base::ThreadIdNameManager::GetInstance()->GetNameForCurrentThread();
+#endif
+
#if !defined(STARBOARD)
// Acquire the ownership of the |unpack_path|.
base::ScopedTempDir unpack_path_owner;
@@ -141,11 +156,11 @@
static_cast<const CobaltExtensionInstallationManagerApi*>(
SbSystemGetExtension(kCobaltExtensionInstallationManagerName));
if (!installation_api) {
- SB_LOG(ERROR) << "Failed to get installation manager api.";
+ LOG(ERROR) << "Failed to get installation manager api.";
// TODO: add correct error code.
install_error = InstallError::GENERIC_ERROR;
} else if (installation_index == IM_EXT_INVALID_INDEX) {
- SB_LOG(ERROR) << "Installation index is invalid.";
+ LOG(ERROR) << "Installation index is invalid.";
// TODO: add correct error code.
install_error = InstallError::GENERIC_ERROR;
} else {
@@ -187,8 +202,9 @@
scoped_refptr<CrxInstaller> installer,
InstallOnBlockingTaskRunnerCompleteCallback callback,
const ComponentUnpacker::Result& result) {
-
#if defined(STARBOARD)
+ LOG(INFO) << "UnpackCompleteOnBlockingTaskRunner thread_name="
+ << base::ThreadIdNameManager::GetInstance()->GetNameForCurrentThread();
base::DeleteFile(crx_path, false);
#else
update_client::DeleteFileAndEmptyParentDirectory(crx_path);
@@ -245,6 +261,10 @@
scoped_refptr<Patcher> patcher_,
crx_file::VerifierFormat crx_format,
InstallOnBlockingTaskRunnerCompleteCallback callback) {
+#if defined(STARBOARD)
+ LOG(INFO) << "StartInstallOnBlockingTaskRunner thread_name="
+ << base::ThreadIdNameManager::GetInstance()->GetNameForCurrentThread();
+#endif
auto unpacker = base::MakeRefCounted<ComponentUnpacker>(
pk_hash, crx_path, installer, std::move(unzipper_), std::move(patcher_),
crx_format);
@@ -274,9 +294,17 @@
Component::Component(const UpdateContext& update_context, const std::string& id)
: id_(id),
state_(std::make_unique<StateNew>(this)),
- update_context_(update_context) {}
+ update_context_(update_context) {
+#if defined(STARBOARD)
+ LOG(INFO) << "Component::Component";
+#endif
+}
-Component::~Component() {}
+Component::~Component() {
+#if defined(STARBOARD)
+ LOG(INFO) << "Component::~Component";
+#endif
+}
scoped_refptr<Configurator> Component::config() const {
return update_context_.config;
@@ -293,7 +321,9 @@
void Component::Handle(CallbackHandleComplete callback_handle_complete) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(state_);
-
+#if defined(STARBOARD)
+ LOG(INFO) << "Component::Handle";
+#endif
callback_handle_complete_ = std::move(callback_handle_complete);
state_->Handle(
@@ -309,6 +339,10 @@
void Component::ChangeState(std::unique_ptr<State> next_state) {
DCHECK(thread_checker_.CalledOnValidThread());
+#if defined(STARBOARD)
+ LOG(INFO) << "Component::ChangeState next_state="
+ << ((next_state)? next_state->state_name(): "nullptr");
+#endif
previous_state_ = state();
if (next_state)
@@ -533,6 +567,9 @@
void Component::State::Handle(CallbackNextState callback_next_state) {
DCHECK(thread_checker_.CalledOnValidThread());
+#if defined(STARBOARD)
+ LOG(INFO) << "Component::State::Handle";
+#endif
callback_next_state_ = std::move(callback_next_state);
@@ -542,7 +579,7 @@
#if defined(STARBOARD)
void Component::State::Cancel() {
DCHECK(thread_checker_.CalledOnValidThread());
- // Further work may be needed to ensure cancelation during any state results
+ // Further work may be needed to ensure cancellation during any state results
// in a clear result and no memory leaks.
}
#endif
@@ -550,6 +587,10 @@
void Component::State::TransitionState(std::unique_ptr<State> next_state) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(next_state);
+#if defined(STARBOARD)
+ LOG(INFO) << "Component::State::TransitionState next_state="
+ << ((next_state)? next_state->state_name(): "nullptr");
+#endif
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
@@ -628,7 +669,7 @@
base::Unretained(metadata), component.id_,
config->GetChannel()));
} else {
- SB_LOG(WARNING) << "Failed to get the persisted data store to write the "
+ LOG(WARNING) << "Failed to get the persisted data store to write the "
"updater channel.";
}
#endif
@@ -972,6 +1013,10 @@
}
void Component::StateUpdating::DoHandle() {
+#if defined(STARBOARD)
+ LOG(INFO) << "Component::StateUpdating::DoHandle() thread_name="
+ << base::ThreadIdNameManager::GetInstance()->GetNameForCurrentThread();
+#endif
DCHECK(thread_checker_.CalledOnValidThread());
const auto& component = Component::State::component();
diff --git a/components/update_client/component.h b/components/update_client/component.h
index f6cc035..83b8a35 100644
--- a/components/update_client/component.h
+++ b/components/update_client/component.h
@@ -169,6 +169,41 @@
ComponentState state() const { return state_; }
+#if defined(STARBOARD)
+ std::string state_name() {
+ switch (state_) {
+ case ComponentState::kNew:
+ return "New";
+ case ComponentState::kChecking:
+ return "Checking";
+ case ComponentState::kCanUpdate:
+ return "CanUpdate";
+ case ComponentState::kDownloadingDiff:
+ return "DownloadingDiff";
+ case ComponentState::kDownloading:
+ return "Downloaded";
+ case ComponentState::kUpdatingDiff:
+ return "UpdatingDiff";
+ case ComponentState::kUpdating:
+ return "Updating";
+ case ComponentState::kUpdated:
+ return "Updated";
+ case ComponentState::kUpToDate:
+ return "UpToDate";
+ case ComponentState::kUpdateError:
+ return "UpdateError";
+ case ComponentState::kUninstalled:
+ return "Uninstalled";
+ case ComponentState::kRun:
+ return "Run";
+ case ComponentState::kLastStatus:
+ return "LastStatus";
+ default:
+ return "Unknown";
+ }
+ }
+#endif
+
protected:
// Initiates the transition to the new state.
void TransitionState(std::unique_ptr<State> new_state);
diff --git a/components/update_client/component_unpacker.cc b/components/update_client/component_unpacker.cc
index 15dbf50..f76cb6a 100644
--- a/components/update_client/component_unpacker.cc
+++ b/components/update_client/component_unpacker.cc
@@ -72,7 +72,7 @@
result != crx_file::VerifierResult::OK_DELTA) {
error_ = UnpackerError::kInvalidFile;
extended_error_ = static_cast<int>(result);
- SB_LOG(INFO) << "Verification failed. Verifier error = " << extended_error_;
+ LOG(INFO) << "Verification failed. Verifier error = " << extended_error_;
return false;
}
is_delta_ = result == crx_file::VerifierResult::OK_DELTA;
diff --git a/components/update_client/crx_downloader.cc b/components/update_client/crx_downloader.cc
index 8f2bffa..fb18952 100644
--- a/components/update_client/crx_downloader.cc
+++ b/components/update_client/crx_downloader.cc
@@ -12,6 +12,9 @@
#include "base/logging.h"
#include "base/task/post_task.h"
#include "base/task/task_traits.h"
+#if defined(STARBOARD)
+#include "base/threading/thread_id_name_manager.h"
+#endif
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#if defined(OS_WIN)
@@ -60,9 +63,17 @@
CrxDownloader::CrxDownloader(std::unique_ptr<CrxDownloader> successor)
: main_task_runner_(base::ThreadTaskRunnerHandle::Get()),
- successor_(std::move(successor)) {}
+ successor_(std::move(successor)) {
+#if defined(STARBOARD)
+ LOG(INFO) << "CrxDownloader::CrxDownloader";
+#endif
+}
-CrxDownloader::~CrxDownloader() {}
+CrxDownloader::~CrxDownloader() {
+#if defined(STARBOARD)
+ LOG(INFO) << "CrxDownloader::~CrxDownloader";
+#endif
+}
void CrxDownloader::set_progress_callback(
const ProgressCallback& progress_callback) {
@@ -87,6 +98,9 @@
void CrxDownloader::StartDownloadFromUrl(const GURL& url,
const std::string& expected_hash,
DownloadCallback download_callback) {
+#if defined(STARBOARD)
+ LOG(INFO) << "CrxDownloader::StartDownloadFromUrl: url=" << url;
+#endif
std::vector<GURL> urls;
urls.push_back(url);
StartDownload(urls, expected_hash, std::move(download_callback));
@@ -122,6 +136,7 @@
#if defined(STARBOARD)
void CrxDownloader::CancelDownload() {
+ LOG(INFO) << "CrxDownloader::CancelDownload";
DoCancelDownload();
}
#endif
@@ -131,7 +146,9 @@
const Result& result,
const DownloadMetrics& download_metrics) {
DCHECK(thread_checker_.CalledOnValidThread());
-
+#if defined(STARBOARD)
+ LOG(INFO) << "CrxDownloader::OnDownloadComplete";
+#endif
if (!result.error)
base::PostTaskWithTraits(
FROM_HERE, kTaskTraits,
@@ -161,7 +178,10 @@
DCHECK_EQ(0, result.error);
DCHECK_EQ(0, download_metrics.error);
DCHECK(is_handled);
-
+#if defined(STARBOARD)
+ LOG(INFO) << "CrxDownloader::VerifyResponse thread_name="
+ << base::ThreadIdNameManager::GetInstance()->GetNameForCurrentThread();
+#endif
if (VerifyFileHash256(result.response, expected_hash_)) {
download_metrics_.push_back(download_metrics);
main_task_runner()->PostTask(
@@ -196,6 +216,10 @@
DCHECK(result.response.empty());
DCHECK_NE(0, download_metrics.error);
+#if defined(STARBOARD)
+ LOG(INFO) << "CrxDownloader::HandleDownloadError";
+#endif
+
download_metrics_.push_back(download_metrics);
#if defined(STARBOARD)
diff --git a/components/update_client/net/network_impl_cobalt.cc b/components/update_client/net/network_impl_cobalt.cc
index 088dc25..feada05 100644
--- a/components/update_client/net/network_impl_cobalt.cc
+++ b/components/update_client/net/network_impl_cobalt.cc
@@ -82,8 +82,8 @@
PostRequestCompleteCallback post_request_complete_callback) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
- SB_LOG(INFO) << "PostRequest url = " << url;
- SB_LOG(INFO) << "PostRequest post_data = " << post_data;
+ LOG(INFO) << "PostRequest url = " << url;
+ LOG(INFO) << "PostRequest post_data = " << post_data;
response_started_callback_ = std::move(response_started_callback);
progress_callback_ = std::move(progress_callback);
@@ -114,8 +114,8 @@
DownloadToFileCompleteCallback download_to_file_complete_callback) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
- SB_LOG(INFO) << "DownloadToFile url = " << url;
- SB_LOG(INFO) << "DownloadToFile file_path = " << file_path;
+ LOG(INFO) << "DownloadToFile url = " << url;
+ LOG(INFO) << "DownloadToFile file_path = " << file_path;
response_started_callback_ = std::move(response_started_callback);
progress_callback_ = std::move(progress_callback);
@@ -132,10 +132,10 @@
url_fetcher_->Start();
}
-void NetworkFetcherCobaltImpl::CancelDownloadToFile() {
+void NetworkFetcherCobaltImpl::Cancel() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
- SB_LOG(INFO) << "Canceling DownloadToFile";
+ LOG(INFO) << "Cancel";
url_fetcher_.reset();
}
@@ -213,11 +213,10 @@
}
if (response_body->empty()) {
- SB_LOG(ERROR) << "PostRequest got empty response.";
+ LOG(ERROR) << "PostRequest got empty response.";
}
- SB_LOG(INFO) << "OnPostRequestComplete response_body = "
- << *response_body.get();
+ LOG(INFO) << "OnPostRequestComplete response_body = " << *response_body.get();
net::HttpResponseHeaders* response_headers = source->GetResponseHeaders();
std::move(post_request_complete_callback_)
@@ -233,9 +232,9 @@
const int status_error) {
base::FilePath response_file;
if (!source->GetResponseAsFilePath(true, &response_file)) {
- SB_LOG(ERROR) << "DownloadToFile failed to get response from a file";
+ LOG(ERROR) << "DownloadToFile failed to get response from a file";
}
- SB_LOG(INFO) << "OnDownloadToFileComplete response_file = " << response_file;
+ LOG(INFO) << "OnDownloadToFileComplete response_file = " << response_file;
std::move(download_to_file_complete_callback_)
.Run(response_file, status_error,
@@ -247,7 +246,7 @@
NetworkFetcherCobaltImpl::ReturnWrapper NetworkFetcherCobaltImpl::HandleError(
const std::string& message) {
url_fetcher_.reset();
- SB_LOG(ERROR) << message;
+ LOG(ERROR) << message;
return ReturnWrapper();
}
diff --git a/components/update_client/net/network_impl_cobalt.h b/components/update_client/net/network_impl_cobalt.h
index 757cc7e..742e8ea 100644
--- a/components/update_client/net/network_impl_cobalt.h
+++ b/components/update_client/net/network_impl_cobalt.h
@@ -71,7 +71,7 @@
ProgressCallback progress_callback,
DownloadToFileCompleteCallback
download_to_file_complete_callback) override;
- void CancelDownloadToFile() override;
+ void Cancel() override;
// net::URLFetcherDelegate interface.
void OnURLFetchResponseStarted(const net::URLFetcher* source) override;
diff --git a/components/update_client/network.h b/components/update_client/network.h
index dec108f..cf884b5 100644
--- a/components/update_client/network.h
+++ b/components/update_client/network.h
@@ -64,7 +64,7 @@
ProgressCallback progress_callback,
DownloadToFileCompleteCallback download_to_file_complete_callback) = 0;
#if defined(STARBOARD)
- virtual void CancelDownloadToFile() = 0;
+ virtual void Cancel() = 0;
#endif
protected:
diff --git a/components/update_client/ping_manager.cc b/components/update_client/ping_manager.cc
index 3c2a60c..25c2c25 100644
--- a/components/update_client/ping_manager.cc
+++ b/components/update_client/ping_manager.cc
@@ -32,6 +32,12 @@
const int kErrorNoEvents = -1;
const int kErrorNoUrl = -2;
+// When building for STARBOARD add the PingSender to the update_client namespace
+// as we keep a reference to it in PingManager.
+#if defined(STARBOARD)
+}
+#endif
+
// An instance of this class can send only one ping.
class PingSender : public base::RefCountedThreadSafe<PingSender> {
public:
@@ -39,6 +45,10 @@
explicit PingSender(scoped_refptr<Configurator> config);
void SendPing(const Component& component, Callback callback);
+#if defined(STARBOARD)
+ void Cancel();
+#endif
+
protected:
virtual ~PingSender();
@@ -66,6 +76,10 @@
void PingSender::SendPing(const Component& component, Callback callback) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
+#if defined(STARBOARD)
+ LOG(INFO) << "PingSender::SendPing";
+#endif
+
if (component.events().empty()) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), kErrorNoEvents, ""));
@@ -103,27 +117,62 @@
false, base::BindOnce(&PingSender::SendPingComplete, this));
}
+#if defined(STARBOARD)
+void PingSender::Cancel() {
+ LOG(INFO) << "PingSender::Cancel";
+ if (request_sender_.get()) {
+ request_sender_->Cancel();
+ }
+}
+#endif
+
void PingSender::SendPingComplete(int error,
const std::string& response,
int retry_after_sec) {
+ LOG(INFO) << "PingSender::SendPingComplete";
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
std::move(callback_).Run(error, response);
}
+#if !defined(STARBOARD)
} // namespace
+#endif
PingManager::PingManager(scoped_refptr<Configurator> config)
- : config_(config) {}
+ : config_(config) {
+#if defined(STARBOARD)
+ LOG(INFO) << "PingManager::PingManager";
+#endif
+}
+
+#if defined(STARBOARD)
+void PingManager::Cancel() {
+ LOG(INFO) << "PingManager::Cancel";
+ if (ping_sender_.get()) {
+ ping_sender_->Cancel();
+ }
+}
+#endif
PingManager::~PingManager() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
+#if defined(STARBOARD)
+ LOG(INFO) << "PingManager::~PingManager";
+#endif
}
void PingManager::SendPing(const Component& component, Callback callback) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
+#if defined(STARBOARD)
+ LOG(INFO) << "PingManager::SendPing";
+
+ ping_sender_ = base::MakeRefCounted<PingSender>(config_);
+ ping_sender_->SendPing(component, std::move(callback));
+#else
auto ping_sender = base::MakeRefCounted<PingSender>(config_);
ping_sender->SendPing(component, std::move(callback));
+#endif
}
} // namespace update_client
diff --git a/components/update_client/ping_manager.h b/components/update_client/ping_manager.h
index 24040e6..d049788 100644
--- a/components/update_client/ping_manager.h
+++ b/components/update_client/ping_manager.h
@@ -17,6 +17,10 @@
class Configurator;
class Component;
+#if defined(STARBOARD)
+class PingSender;
+#endif
+
class PingManager : public base::RefCountedThreadSafe<PingManager> {
public:
// |error| is 0 if the ping was sent successfully, otherwise |error| contains
@@ -31,6 +35,9 @@
// be discarded if it has not been sent for any reason.
virtual void SendPing(const Component& component, Callback callback);
+#if defined(STARBOARD)
+ virtual void Cancel();
+#endif
protected:
virtual ~PingManager();
@@ -40,6 +47,10 @@
THREAD_CHECKER(thread_checker_);
const scoped_refptr<Configurator> config_;
+#if defined(STARBOARD)
+ scoped_refptr<PingSender> ping_sender_;
+#endif
+
DISALLOW_COPY_AND_ASSIGN(PingManager);
};
diff --git a/components/update_client/request_sender.cc b/components/update_client/request_sender.cc
index a68df98..2f3d878 100644
--- a/components/update_client/request_sender.cc
+++ b/components/update_client/request_sender.cc
@@ -45,6 +45,9 @@
bool use_signing,
RequestSenderCallback request_sender_callback) {
DCHECK(thread_checker_.CalledOnValidThread());
+#if defined(STARBOARD)
+ LOG(INFO) << "RequestSender::Send";
+#endif
urls_ = urls;
request_extra_headers_ = request_extra_headers;
@@ -101,10 +104,22 @@
base::Unretained(this), url));
}
+#if defined(STARBOARD)
+void RequestSender::Cancel() {
+ LOG(INFO) << "RequestSender::Cancel";
+ if (network_fetcher_.get()) {
+ network_fetcher_->Cancel();
+ }
+}
+#endif
+
void RequestSender::SendInternalComplete(int error,
const std::string& response_body,
const std::string& response_etag,
int retry_after_sec) {
+#if defined(STARBOARD)
+ LOG(INFO) << "RequestSender::SendInternalComplete";
+#endif
if (!error) {
if (!use_signing_) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
@@ -152,6 +167,9 @@
const std::string& header_etag,
int64_t xheader_retry_after_sec) {
DCHECK(thread_checker_.CalledOnValidThread());
+#if defined(STARBOARD)
+ LOG(INFO) << "RequestSender::OnNetworkFetcherComplete";
+#endif
VLOG(1) << "request completed from url: " << original_url.spec();
diff --git a/components/update_client/request_sender.h b/components/update_client/request_sender.h
index 7b9e21b..1936047 100644
--- a/components/update_client/request_sender.h
+++ b/components/update_client/request_sender.h
@@ -58,6 +58,10 @@
bool use_signing,
RequestSenderCallback request_sender_callback);
+#if defined(STARBOARD)
+ void Cancel();
+#endif
+
private:
// Combines the |url| and |query_params| parameters.
static GURL BuildUpdateUrl(const GURL& url, const std::string& query_params);
diff --git a/components/update_client/task_update.cc b/components/update_client/task_update.cc
index 0129e4c..b4894b7 100644
--- a/components/update_client/task_update.cc
+++ b/components/update_client/task_update.cc
@@ -22,14 +22,28 @@
is_foreground_(is_foreground),
ids_(ids),
crx_data_callback_(std::move(crx_data_callback)),
- callback_(std::move(callback)) {}
+ callback_(std::move(callback))
+#if defined(STARBOARD)
+ , is_completed_(false)
+#endif
+{
+#if defined(STARBOARD)
+ LOG(INFO) << "TaskUpdate::TaskUpdate";
+#endif
+}
TaskUpdate::~TaskUpdate() {
DCHECK(thread_checker_.CalledOnValidThread());
+#if defined(STARBOARD)
+ LOG(INFO) << "TaskUpdate::~TaskUpdate";
+#endif
}
void TaskUpdate::Run() {
DCHECK(thread_checker_.CalledOnValidThread());
+#if defined(STARBOARD)
+ LOG(INFO) << "TaskUpdate::Run begin";
+#endif
if (ids_.empty()) {
TaskComplete(Error::INVALID_ARGUMENT);
@@ -40,16 +54,19 @@
update_engine_->Update(is_foreground_, ids_, std::move(crx_data_callback_),
base::BindOnce(&TaskUpdate::TaskComplete, this),
cancelation_closure_);
+ LOG(INFO) << "TaskUpdate::Run end";
#else
update_engine_->Update(is_foreground_, ids_, std::move(crx_data_callback_),
base::BindOnce(&TaskUpdate::TaskComplete, this));
#endif
+
}
void TaskUpdate::Cancel() {
DCHECK(thread_checker_.CalledOnValidThread());
#if defined(STARBOARD)
+ LOG(INFO) << "TaskUpdate::Cancel";
if (cancelation_closure_) { // The engine's picked up the task.
std::move(cancelation_closure_).Run();
}
@@ -64,6 +81,18 @@
void TaskUpdate::TaskComplete(Error error) {
DCHECK(thread_checker_.CalledOnValidThread());
+#if defined(STARBOARD)
+ LOG(INFO) << "TaskUpdate::TaskComplete";
+
+ // The callback is defined as OnceCallback and should not
+ // be called multiple times.
+ if(is_completed_) {
+ LOG(INFO) << "TaskUpdate::TaskComplete already called";
+ return;
+ }
+
+ is_completed_ = true;
+#endif
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback_),
diff --git a/components/update_client/task_update.h b/components/update_client/task_update.h
index 74c0a6a..2697c35 100644
--- a/components/update_client/task_update.h
+++ b/components/update_client/task_update.h
@@ -59,6 +59,7 @@
Callback callback_;
#if defined(STARBOARD)
base::OnceClosure cancelation_closure_;
+ bool is_completed_;
#endif
DISALLOW_COPY_AND_ASSIGN(TaskUpdate);
diff --git a/components/update_client/update_checker.cc b/components/update_client/update_checker.cc
index 1e7eed4..4951abf 100644
--- a/components/update_client/update_checker.cc
+++ b/components/update_client/update_checker.cc
@@ -20,6 +20,9 @@
#include "base/strings/stringprintf.h"
#include "base/task/post_task.h"
#include "base/threading/thread_checker.h"
+#if defined(STARBOARD)
+#include "base/threading/thread_id_name_manager.h"
+#endif
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#if defined(STARBOARD)
@@ -98,6 +101,9 @@
const IdToComponentPtrMap& components,
const base::flat_map<std::string, std::string>& additional_attributes,
bool enabled_component_updates);
+#if defined(STARBOARD)
+ void Cancel();
+#endif
void OnRequestSenderComplete(int error,
const std::string& response,
int retry_after_sec);
@@ -121,10 +127,17 @@
UpdateCheckerImpl::UpdateCheckerImpl(scoped_refptr<Configurator> config,
PersistedData* metadata)
- : config_(config), metadata_(metadata) {}
+ : config_(config), metadata_(metadata) {
+#if defined(STARBOARD)
+ LOG(INFO) << "UpdateCheckerImpl::UpdateCheckerImpl";
+#endif
+}
UpdateCheckerImpl::~UpdateCheckerImpl() {
DCHECK(thread_checker_.CalledOnValidThread());
+#if defined(STARBOARD)
+ LOG(INFO) << "UpdateCheckerImpl::~UpdateCheckerImpl";
+#endif
}
void UpdateCheckerImpl::CheckForUpdates(
@@ -135,6 +148,9 @@
bool enabled_component_updates,
UpdateCheckCallback update_check_callback) {
DCHECK(thread_checker_.CalledOnValidThread());
+#if defined(STARBOARD)
+ LOG(INFO) << "UpdateCheckerImpl::CheckForUpdates";
+#endif
ids_checked_ = ids_checked;
update_check_callback_ = std::move(update_check_callback);
@@ -150,6 +166,11 @@
// This function runs on the blocking pool task runner.
void UpdateCheckerImpl::ReadUpdaterStateAttributes() {
+#if defined(STARBOARD)
+ LOG(INFO) << "UpdateCheckerImpl::ReadUpdaterStateAttributes current_thread="
+ << base::ThreadIdNameManager::GetInstance()->GetNameForCurrentThread();
+#endif
+
#if defined(OS_WIN)
// On Windows, the Chrome and the updater install modes are matched by design.
updater_state_attributes_ =
@@ -168,6 +189,9 @@
const base::flat_map<std::string, std::string>& additional_attributes,
bool enabled_component_updates) {
DCHECK(thread_checker_.CalledOnValidThread());
+#if defined(STARBOARD)
+ LOG(INFO) << "UpdateCheckerImpl::CheckForUpdatesHelper";
+#endif
auto urls(config_->UpdateUrl());
if (IsEncryptionRequired(components))
@@ -219,7 +243,7 @@
static_cast<const CobaltExtensionInstallationManagerApi*>(
SbSystemGetExtension(kCobaltExtensionInstallationManagerName));
if (!installation_api) {
- SB_LOG(ERROR) << "Failed to get installation manager extension.";
+ LOG(ERROR) << "Failed to get installation manager extension.";
return;
}
@@ -274,6 +298,15 @@
#endif
}
+#if defined(STARBOARD)
+void UpdateCheckerImpl::Cancel() {
+ LOG(INFO) << "UpdateCheckerImpl::Cancel";
+ if (request_sender_.get()) {
+ request_sender_->Cancel();
+ }
+}
+#endif
+
void UpdateCheckerImpl::OnRequestSenderComplete(int error,
const std::string& response,
int retry_after_sec) {
diff --git a/components/update_client/update_checker.h b/components/update_client/update_checker.h
index 9a53357..78eb968 100644
--- a/components/update_client/update_checker.h
+++ b/components/update_client/update_checker.h
@@ -51,6 +51,10 @@
bool enabled_component_updates,
UpdateCheckCallback update_check_callback) = 0;
+#if defined(STARBOARD)
+ virtual void Cancel() = 0;
+#endif
+
static std::unique_ptr<UpdateChecker> Create(
scoped_refptr<Configurator> config,
PersistedData* persistent);
diff --git a/components/update_client/update_checker_unittest.cc b/components/update_client/update_checker_unittest.cc
index de84eb9..7905805 100644
--- a/components/update_client/update_checker_unittest.cc
+++ b/components/update_client/update_checker_unittest.cc
@@ -369,7 +369,7 @@
EXPECT_EQ(GURL("http://localhost/download/"), result.crx_urls.front());
EXPECT_STREQ("this", result.action_run.c_str());
- // Check the DDOS protection header values.
+// Check the DDOS protection header values.
#if defined(STARBOARD)
const auto extra_request_headers = post_interceptor_->GetRequests()[0].second;
#else
@@ -740,8 +740,12 @@
if (is_foreground_) {
{
+#if defined(STARBOARD)
+ auto post_interceptor = post_interceptor_;
+#else
auto post_interceptor = std::make_unique<URLLoaderPostInterceptor>(
config_->test_url_loader_factory());
+#endif
EXPECT_TRUE(post_interceptor->ExpectRequest(
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.json")));
@@ -758,8 +762,12 @@
EXPECT_FALSE(app.FindKey("installedby"));
}
{
+#if defined(STARBOARD)
+ auto post_interceptor = post_interceptor_;
+#else
auto post_interceptor = std::make_unique<URLLoaderPostInterceptor>(
config_->test_url_loader_factory());
+#endif
EXPECT_TRUE(post_interceptor->ExpectRequest(
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.json")));
@@ -783,8 +791,12 @@
DCHECK(!is_foreground_);
{
+#if defined(STARBOARD)
+ auto post_interceptor = post_interceptor_;
+#else
auto post_interceptor = std::make_unique<URLLoaderPostInterceptor>(
config_->test_url_loader_factory());
+#endif
EXPECT_TRUE(post_interceptor->ExpectRequest(
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.json")));
@@ -800,8 +812,12 @@
EXPECT_FALSE(app.FindKey("installsource"));
}
{
+#if defined(STARBOARD)
+ auto post_interceptor = post_interceptor_;
+#else
auto post_interceptor = std::make_unique<URLLoaderPostInterceptor>(
config_->test_url_loader_factory());
+#endif
EXPECT_TRUE(post_interceptor->ExpectRequest(
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.json")));
@@ -832,8 +848,12 @@
auto crx_component = component->crx_component();
{
+#if defined(STARBOARD)
+ auto post_interceptor = post_interceptor_;
+#else
auto post_interceptor = std::make_unique<URLLoaderPostInterceptor>(
config_->test_url_loader_factory());
+#endif
EXPECT_TRUE(post_interceptor->ExpectRequest(
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.json")));
@@ -853,8 +873,12 @@
{
crx_component->disabled_reasons = {};
component->set_crx_component(*crx_component);
+#if defined(STARBOARD)
+ auto post_interceptor = post_interceptor_;
+#else
auto post_interceptor = std::make_unique<URLLoaderPostInterceptor>(
config_->test_url_loader_factory());
+#endif
EXPECT_TRUE(post_interceptor->ExpectRequest(
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.json")));
@@ -874,8 +898,12 @@
{
crx_component->disabled_reasons = {0};
component->set_crx_component(*crx_component);
+#if defined(STARBOARD)
+ auto post_interceptor = post_interceptor_;
+#else
auto post_interceptor = std::make_unique<URLLoaderPostInterceptor>(
config_->test_url_loader_factory());
+#endif
EXPECT_TRUE(post_interceptor->ExpectRequest(
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.json")));
@@ -896,8 +924,12 @@
{
crx_component->disabled_reasons = {1};
component->set_crx_component(*crx_component);
+#if defined(STARBOARD)
+ auto post_interceptor = post_interceptor_;
+#else
auto post_interceptor = std::make_unique<URLLoaderPostInterceptor>(
config_->test_url_loader_factory());
+#endif
EXPECT_TRUE(post_interceptor->ExpectRequest(
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.json")));
@@ -919,8 +951,12 @@
{
crx_component->disabled_reasons = {4, 8, 16};
component->set_crx_component(*crx_component);
+#if defined(STARBOARD)
+ auto post_interceptor = post_interceptor_;
+#else
auto post_interceptor = std::make_unique<URLLoaderPostInterceptor>(
config_->test_url_loader_factory());
+#endif
EXPECT_TRUE(post_interceptor->ExpectRequest(
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.json")));
@@ -944,8 +980,12 @@
{
crx_component->disabled_reasons = {0, 4, 8, 16};
component->set_crx_component(*crx_component);
+#if defined(STARBOARD)
+ auto post_interceptor = post_interceptor_;
+#else
auto post_interceptor = std::make_unique<URLLoaderPostInterceptor>(
config_->test_url_loader_factory());
+#endif
EXPECT_TRUE(post_interceptor->ExpectRequest(
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.json")));
@@ -987,8 +1027,12 @@
// Expects the group policy to be ignored and the update check to not
// include the "updatedisabled" attribute.
EXPECT_FALSE(crx_component->supports_group_policy_enable_component_updates);
+#if defined(STARBOARD)
+ auto post_interceptor = post_interceptor_;
+#else
auto post_interceptor = std::make_unique<URLLoaderPostInterceptor>(
config_->test_url_loader_factory());
+#endif
EXPECT_TRUE(post_interceptor->ExpectRequest(
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.json")));
@@ -1013,8 +1057,12 @@
// Expects the update check to include the "updatedisabled" attribute.
crx_component->supports_group_policy_enable_component_updates = true;
component->set_crx_component(*crx_component);
+#if defined(STARBOARD)
+ auto post_interceptor = post_interceptor_;
+#else
auto post_interceptor = std::make_unique<URLLoaderPostInterceptor>(
config_->test_url_loader_factory());
+#endif
EXPECT_TRUE(post_interceptor->ExpectRequest(
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.json")));
@@ -1039,8 +1087,12 @@
// Expects the update check to not include the "updatedisabled" attribute.
crx_component->supports_group_policy_enable_component_updates = false;
component->set_crx_component(*crx_component);
+#if defined(STARBOARD)
+ auto post_interceptor = post_interceptor_;
+#else
auto post_interceptor = std::make_unique<URLLoaderPostInterceptor>(
config_->test_url_loader_factory());
+#endif
EXPECT_TRUE(post_interceptor->ExpectRequest(
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.json")));
@@ -1065,8 +1117,12 @@
// Expects the update check to not include the "updatedisabled" attribute.
crx_component->supports_group_policy_enable_component_updates = true;
component->set_crx_component(*crx_component);
+#if defined(STARBOARD)
+ auto post_interceptor = post_interceptor_;
+#else
auto post_interceptor = std::make_unique<URLLoaderPostInterceptor>(
config_->test_url_loader_factory());
+#endif
EXPECT_TRUE(post_interceptor->ExpectRequest(
std::make_unique<PartialMatch>("updatecheck"),
test_file("updatecheck_reply_1.json")));
@@ -1221,7 +1277,7 @@
}
// The update response contains a status |error-unknownApplication| for the
-// app. The response is succesfully parsed and a result is extracted to
+// app. The response is successfully parsed and a result is extracted to
// indicate this status.
TEST_P(UpdateCheckerTest, ParseErrorAppStatusErrorUnknownApplication) {
EXPECT_TRUE(post_interceptor_->ExpectRequest(
diff --git a/components/update_client/update_client.cc b/components/update_client/update_client.cc
index 6ce65bf..0ba76cd 100644
--- a/components/update_client/update_client.cc
+++ b/components/update_client/update_client.cc
@@ -78,6 +78,10 @@
DCHECK(task_queue_.empty());
DCHECK(tasks_.empty());
+#if defined(STARBOARD)
+ LOG(INFO) << "UpdateClientImpl::~UpdateClientImpl: task_queue_.size=" << task_queue_.size() << " tasks.size=" << tasks_.size();
+#endif
+
config_ = nullptr;
}
@@ -135,6 +139,10 @@
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(task);
+#if defined(STARBOARD)
+ LOG(INFO) << "UpdateClientImpl::OnTaskComplete";
+#endif
+
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), error));
diff --git a/components/update_client/update_client.gyp b/components/update_client/update_client.gyp
index efd729d..6a15ed0 100644
--- a/components/update_client/update_client.gyp
+++ b/components/update_client/update_client.gyp
@@ -155,11 +155,12 @@
# 'protocol_serializer_json_unittest.cc',
'protocol_serializer_unittest.cc',
'request_sender_unittest.cc',
- # 'update_checker_unittest.cc',
+ 'update_checker_unittest.cc',
# 'update_client_unittest.cc',
'update_query_params_unittest.cc',
'updater_state_unittest.cc',
'utils_unittest.cc',
+ '<(DEPTH)/cobalt/updater/utils.cc',
],
'dependencies': [
'update_client',
diff --git a/components/update_client/update_engine.cc b/components/update_client/update_engine.cc
index 29c260b..9e39a0f 100644
--- a/components/update_client/update_engine.cc
+++ b/components/update_client/update_engine.cc
@@ -51,7 +51,11 @@
}
}
-UpdateContext::~UpdateContext() {}
+UpdateContext::~UpdateContext() {
+#if defined(STARBOARD)
+ LOG(INFO) << "UpdateContext::~UpdateContext";
+#endif
+}
UpdateEngine::UpdateEngine(
scoped_refptr<Configurator> config,
@@ -66,10 +70,17 @@
metadata_(
std::make_unique<PersistedData>(config->GetPrefService(),
config->GetActivityDataService())),
- notify_observers_callback_(notify_observers_callback) {}
+ notify_observers_callback_(notify_observers_callback) {
+#if defined(STARBOARD)
+ LOG(INFO) << "UpdateEngine::UpdateEngine";
+#endif
+}
UpdateEngine::~UpdateEngine() {
DCHECK(thread_checker_.CalledOnValidThread());
+#if defined(STARBOARD)
+ LOG(INFO) << "UpdateEngine::~UpdateEngine";
+#endif
}
#if !defined(STARBOARD)
@@ -87,6 +98,10 @@
#endif
DCHECK(thread_checker_.CalledOnValidThread());
+#if defined(STARBOARD)
+ LOG(INFO) << "UpdateEngine::Update";
+#endif
+
if (ids.empty()) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
@@ -169,6 +184,10 @@
DCHECK_EQ(1u, update_context->components.count(id));
DCHECK(update_context->components.at(id));
+#if defined(STARBOARD)
+ LOG(INFO) << "UpdateEngine::ComponentCheckingForUpdatesStart";
+#endif
+
// Handle |kChecking| state.
auto& component = *update_context->components.at(id);
component.Handle(
@@ -190,6 +209,10 @@
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(update_context);
+#if defined(STARBOARD)
+ LOG(INFO) << "UpdateEngine::DoUpdateCheck";
+#endif
+
update_context->update_checker =
update_checker_factory_(config_, metadata_.get());
@@ -211,6 +234,10 @@
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(update_context);
+#if defined(STARBOARD)
+ LOG(INFO) << "UpdateEngine::UpdateCheckResultsAvailable";
+#endif
+
update_context->retry_after_sec = retry_after_sec;
// Only positive values for throttle_sec are effective. 0 means that no
@@ -283,6 +310,10 @@
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(update_context);
+#if defined(STARBOARD)
+ LOG(INFO) << "UpdateEngine::ComponentCheckingForUpdatesComplete";
+#endif
+
++update_context->num_components_checked;
if (update_context->num_components_checked <
update_context->components_to_check_for_updates.size()) {
@@ -299,6 +330,10 @@
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(update_context);
+#if defined(STARBOARD)
+ LOG(INFO) << "UpdateEngine::UpdateCheckComplete";
+#endif
+
for (const auto& id : update_context->components_to_check_for_updates)
update_context->component_queue.push(id);
@@ -312,6 +347,10 @@
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(update_context);
+#if defined(STARBOARD)
+ LOG(INFO) << "UpdateEngine::HandleComponent";
+#endif
+
auto& queue = update_context->component_queue;
if (queue.empty()) {
@@ -354,6 +393,10 @@
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(update_context);
+#if defined(STARBOARD)
+ LOG(INFO) << "UpdateEngine::HandleComponentComplete";
+#endif
+
auto& queue = update_context->component_queue;
DCHECK(!queue.empty());
@@ -380,6 +423,10 @@
void UpdateEngine::UpdateComplete(scoped_refptr<UpdateContext> update_context,
Error error) {
+#if defined(STARBOARD)
+ LOG(INFO) << "UpdateEngine::UpdateComplete";
+#endif
+
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(update_context);
@@ -393,6 +440,9 @@
bool UpdateEngine::GetUpdateState(const std::string& id,
CrxUpdateItem* update_item) {
DCHECK(thread_checker_.CalledOnValidThread());
+#if defined(STARBOARD)
+ LOG(INFO) << "UpdateEngine::GetUpdateState";
+#endif
for (const auto& context : update_contexts_) {
const auto& components = context.second->components;
const auto it = components.find(id);
@@ -406,6 +456,9 @@
bool UpdateEngine::IsThrottled(bool is_foreground) const {
DCHECK(thread_checker_.CalledOnValidThread());
+#if defined(STARBOARD)
+ LOG(INFO) << "UpdateEngine::IsThrottled";
+#endif
if (is_foreground || throttle_updates_until_.is_null())
return false;
@@ -421,7 +474,16 @@
#if defined(STARBOARD)
void UpdateEngine::Cancel(const std::string& update_context_session_id,
const std::vector<std::string>& crx_component_ids) {
+ LOG(INFO) << "UpdateEngine::Cancel";
+
+ if (ping_manager_.get()) {
+ ping_manager_->Cancel();
+ }
+
const auto& context = update_contexts_.at(update_context_session_id);
+ if (context->update_checker.get()) {
+ context->update_checker->Cancel();
+ }
for (const auto& crx_component_id : crx_component_ids) {
auto& component = context->components.at(crx_component_id);
component->Cancel();
@@ -435,6 +497,10 @@
Callback callback) {
DCHECK(thread_checker_.CalledOnValidThread());
+#if defined(STARBOARD)
+ LOG(INFO) << "UpdateEngine::SendUninstallPing";
+#endif
+
const auto update_context = base::MakeRefCounted<UpdateContext>(
config_, false, std::vector<std::string>{id},
UpdateClient::CrxDataCallback(), UpdateEngine::NotifyObserversCallback(),
diff --git a/components/update_client/update_engine.h b/components/update_client/update_engine.h
index 4384fa8..1cd0ac9 100644
--- a/components/update_client/update_engine.h
+++ b/components/update_client/update_engine.h
@@ -109,7 +109,8 @@
#if defined(STARBOARD)
// Cancels updates currently handled by the engine for each component
// identified by one of |crx_component_ids| for the update context identified
- // by the |update_context_session_id|.
+ // by the |update_context_session_id|. Also cancels the |UpdateChecker| for
+ // the component and the |PingManager|.
void Cancel(const std::string& update_context_session_id,
const std::vector<std::string>& crx_component_ids);
#endif
diff --git a/components/update_client/url_fetcher_downloader.cc b/components/update_client/url_fetcher_downloader.cc
index 078c275..b5c13cc 100644
--- a/components/update_client/url_fetcher_downloader.cc
+++ b/components/update_client/url_fetcher_downloader.cc
@@ -71,7 +71,9 @@
scoped_refptr<Configurator> config)
: CrxDownloader(std::move(successor)),
config_(config),
- network_fetcher_factory_(config->GetNetworkFetcherFactory()) {}
+ network_fetcher_factory_(config->GetNetworkFetcherFactory()) {
+ LOG(INFO) << "UrlFetcherDownloader::UrlFetcherDownloader";
+}
#else
UrlFetcherDownloader::UrlFetcherDownloader(
std::unique_ptr<CrxDownloader> successor,
@@ -82,11 +84,14 @@
UrlFetcherDownloader::~UrlFetcherDownloader() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
+#if defined(STARBOARD)
+ LOG(INFO) << "UrlFetcherDownloader::UrlFetcherDownloader";
+#endif
}
#if defined(STARBOARD)
void UrlFetcherDownloader::ConfirmSlot(const GURL& url) {
- SB_LOG(INFO) << "UrlFetcherDownloader::ConfirmSlot: url=" << url;
+ LOG(INFO) << "UrlFetcherDownloader::ConfirmSlot: url=" << url;
if (!cobalt_slot_management_.ConfirmSlot(download_dir_)) {
ReportDownloadFailure(url, CrxDownloaderError::SLOT_UNAVAILABLE);
return;
@@ -98,7 +103,7 @@
}
void UrlFetcherDownloader::SelectSlot(const GURL& url) {
- SB_LOG(INFO) << "UrlFetcherDownloader::SelectSlot: url=" << url;
+ LOG(INFO) << "UrlFetcherDownloader::SelectSlot: url=" << url;
if (!cobalt_slot_management_.SelectSlot(&download_dir_)) {
ReportDownloadFailure(url, CrxDownloaderError::SLOT_UNAVAILABLE);
return;
@@ -119,11 +124,13 @@
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
#if defined(STARBOARD)
+ LOG(INFO) << "UrlFetcherDownloader::DoStartDownload";
+
const CobaltExtensionInstallationManagerApi* installation_api =
static_cast<const CobaltExtensionInstallationManagerApi*>(
SbSystemGetExtension(kCobaltExtensionInstallationManagerName));
if (!installation_api) {
- SB_LOG(ERROR) << "Failed to get installation manager";
+ LOG(ERROR) << "Failed to get installation manager";
ReportDownloadFailure(url);
return;
}
@@ -146,8 +153,11 @@
#if defined(STARBOARD)
void UrlFetcherDownloader::DoCancelDownload() {
+ LOG(INFO) << "UrlFetcherDownloader::DoCancelDownload";
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
- network_fetcher_->CancelDownloadToFile();
+ if (network_fetcher_.get()) {
+ network_fetcher_->Cancel();
+ }
}
#endif
@@ -158,6 +168,7 @@
#if defined(STARBOARD)
void UrlFetcherDownloader::ReportDownloadFailure(const GURL& url) {
+ LOG(INFO) << "UrlFetcherDownloader::ReportDownloadFailure";
ReportDownloadFailure(url, CrxDownloaderError::GENERIC_ERROR);
}
@@ -195,13 +206,13 @@
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
#if defined(STARBOARD)
- SB_LOG(INFO) << "UrlFetcherDownloader::StartURLFetch: url" << url
+ LOG(INFO) << "UrlFetcherDownloader::StartURLFetch: url" << url
<< " download_dir=" << download_dir_;
#endif
if (download_dir_.empty()) {
#if defined(STARBOARD)
- SB_LOG(ERROR) << "UrlFetcherDownloader::StartURLFetch: failed with empty "
+ LOG(ERROR) << "UrlFetcherDownloader::StartURLFetch: failed with empty "
"download_dir";
#endif
ReportDownloadFailure(url);
@@ -227,6 +238,10 @@
int64_t content_size) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
+#if defined(STARBOARD)
+ LOG(INFO) << "UrlFetcherDownloader::OnNetworkFetcherComplete";
+#endif
+
const base::TimeTicks download_end_time(base::TimeTicks::Now());
const base::TimeDelta download_time =
download_end_time >= download_start_time_
@@ -299,6 +314,10 @@
int64_t content_length) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
+#if defined(STARBOARD)
+ LOG(INFO) << "UrlFetcherDownloader::OnResponseStarted";
+#endif
+
VLOG(1) << "url fetcher response started for: " << final_url.spec();
final_url_ = final_url;