summaryrefslogtreecommitdiffstats
path: root/components/component_updater
diff options
context:
space:
mode:
authorvasilii <vasilii@chromium.org>2015-04-14 01:59:12 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-14 08:59:44 +0000
commitbc47245d8ae9d6b75dd5f4b4cd17613fd9a5438b (patch)
tree8c240165607918feb373532edb5c7d1a356e119d /components/component_updater
parent2ff69ba324f7f3f9413fca5db954510ba00ba69a (diff)
downloadchromium_src-bc47245d8ae9d6b75dd5f4b4cd17613fd9a5438b.zip
chromium_src-bc47245d8ae9d6b75dd5f4b4cd17613fd9a5438b.tar.gz
chromium_src-bc47245d8ae9d6b75dd5f4b4cd17613fd9a5438b.tar.bz2
Revert of Implement common code for component and extension updaters. (patchset #3 id:40001 of https://codereview.chromium.org/1055903003/)
Reason for revert: Performance regression: chrome-si/initializers (14.29%) http://build.chromium.org/p/chromium/builders/Linux%20x64/builds/1504/steps/sizes/logs/stdio # Static initializers in src/out/Release/chrome: # HINT: To get this list, run tools/linux/dump-static-initializers.py # HINT: diff against the log from the last run to see what changed # atomicops_internals_x86.cc .L.str # atomicops_internals_x86.cc _GLOBAL__sub_I_atomicops_internals_x86.cc+0x78 # atomicops_internals_x86.cc _GLOBAL__sub_I_atomicops_internals_x86.cc+0xed # atomicops_internals_x86.cc (anonymous namespace)::google_initializer_module_atomicops_x86 # atomicops_internals_x86.cc GoogleInitializer::~GoogleInitializer() # atomicops_internals_x86.cc __cxa_atexit@plt [registers a dtor to run at exit] # atomicops_internals_x86.cc __init_array_end+0x3250 # atomicops_internals_x86.cc __init_array_end+0x34f0 # atomicops_internals_x86.cc __stack_chk_fail@plt # atomicops_internals_x86.cc strcmp@plt # atomicops_internals_x86_gcc.cc .L.str # atomicops_internals_x86_gcc.cc _GLOBAL__sub_I_atomicops_internals_x86_gcc.cc+0x69 # atomicops_internals_x86_gcc.cc _GLOBAL__sub_I_atomicops_internals_x86_gcc.cc+0xb5 # atomicops_internals_x86_gcc.cc google::protobuf::internal::AtomicOps_Internalx86CPUFeatures # atomicops_internals_x86_gcc.cc google::protobuf::internal::AtomicOps_Internalx86CPUFeatures+0x1 # atomicops_internals_x86_gcc.cc __stack_chk_fail@plt # atomicops_internals_x86_gcc.cc strcmp@plt # atomicops_internals_x86_gcc.cc .L.str # atomicops_internals_x86_gcc.cc _GLOBAL__sub_I_atomicops_internals_x86_gcc.cc+0x62 # atomicops_internals_x86_gcc.cc _GLOBAL__sub_I_atomicops_internals_x86_gcc.cc+0x9e # atomicops_internals_x86_gcc.cc v8::base::AtomicOps_Internalx86CPUFeatures # atomicops_internals_x86_gcc.cc __stack_chk_fail@plt # atomicops_internals_x86_gcc.cc strcmp@plt # component_updater_service.cc std::ios_base::Init::Init()@plt # component_updater_service.cc std::__ioinit [#includes <iostream>, use <ostream> instead] # component_updater_service.cc __cxa_atexit@plt [registers a dtor to run at exit] # component_updater_service.cc __init_array_end+0x34f0 # component_updater_service.cc __init_array_end+0x4608 # debugallocation_shim.cc module_enter_exit_hook # debugallocation_shim.cc (anonymous namespace)::large_alloc_threshold # debugallocation_shim.cc TCMallocGuard::TCMallocGuard() # debugallocation_shim.cc __cxa_atexit@plt [registers a dtor to run at exit] # debugallocation_shim.cc __init_array_end+0x34e8 # debugallocation_shim.cc __init_array_end+0x34f0 # debugallocation_shim.cc __init_array_end+0x34f8 # memory_region_map.cc libpthread_initialized # spinlock.cc _GLOBAL__sub_I_spinlock.cc+0x12 # spinlock.cc NumCPUs() # spinlock.cc adaptive_spin_count # spinlock_internal.cc _GLOBAL__sub_I_spinlock_internal.cc+0x79 # spinlock_internal.cc have_futex # spinlock_internal.cc futex_private_flag # spinlock_internal.cc syscall@plt # Found 43 static initializers in 8 files. Original issue's description: > Implement common code for component and extension updaters. > > The changes not under update_client are mechanical. > > This change creates a working UpdateClient updater client, which can be reused by both component and extension updaters. > > This code is not hooked up yet with any of the updaters above. > Those changes will be committed in the near future by other CLs. > > R=waffles,erikwright,agl,dgarrett,jhawkins,brettw > > BUG=450337 > > Committed: https://crrev.com/ba6742df55de47568e3aa438378d844a7439c391 > Cr-Commit-Position: refs/heads/master@{#325006} TBR=agl@chromium.org,dgarrett@chromium.org,erikwright@chromium.org,waffles@chromium.org,dgarrett@google.com,jhawkins@chromium.org,brettw@chromium.org,wfh@chromium.org,sorin@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=450337 Review URL: https://codereview.chromium.org/1085643003 Cr-Commit-Position: refs/heads/master@{#325015}
Diffstat (limited to 'components/component_updater')
-rw-r--r--components/component_updater/component_updater_service.cc243
-rw-r--r--components/component_updater/component_updater_service.h18
-rw-r--r--components/component_updater/default_component_installer.cc4
-rw-r--r--components/component_updater/default_component_installer.h2
4 files changed, 126 insertions, 141 deletions
diff --git a/components/component_updater/component_updater_service.cc b/components/component_updater/component_updater_service.cc
index 4270e31..4bfc2d7 100644
--- a/components/component_updater/component_updater_service.cc
+++ b/components/component_updater/component_updater_service.cc
@@ -5,7 +5,6 @@
#include "components/component_updater/component_updater_service.h"
#include <algorithm>
-#include <iostream>
#include <set>
#include <vector>
@@ -38,7 +37,7 @@
#include "components/update_client/utils.h"
#include "url/gurl.h"
-using update_client::CrxInstaller;
+using update_client::ComponentInstaller;
using update_client::ComponentUnpacker;
using update_client::Configurator;
using update_client::CrxComponent;
@@ -50,11 +49,6 @@ using update_client::UpdateResponse;
namespace component_updater {
-std::ostream& operator<<(std::ostream& os,
- const ComponentUpdateService::Status& status) {
- return os << static_cast<int>(status);
-}
-
// The component updater is designed to live until process shutdown, so
// base::Bind() calls are not refcounted.
@@ -97,7 +91,7 @@ void AppendDownloadMetrics(
// thread.
class CrxUpdateService : public ComponentUpdateService, public OnDemandUpdater {
public:
- explicit CrxUpdateService(const scoped_refptr<Configurator>& config);
+ explicit CrxUpdateService(Configurator* config);
~CrxUpdateService() override;
// Overrides for ComponentUpdateService.
@@ -115,7 +109,7 @@ class CrxUpdateService : public ComponentUpdateService, public OnDemandUpdater {
// Context for a crx download url request.
struct CRXContext {
- scoped_refptr<CrxInstaller> installer;
+ scoped_refptr<ComponentInstaller> installer;
std::vector<uint8_t> pk_hash;
std::string id;
std::string fingerprint;
@@ -189,9 +183,9 @@ class CrxUpdateService : public ComponentUpdateService, public OnDemandUpdater {
ComponentUnpacker::Error error,
int extended_error);
- void ChangeItemState(CrxUpdateItem* item, CrxUpdateItem::State to);
+ void ChangeItemState(CrxUpdateItem* item, CrxUpdateItem::Status to);
- size_t ChangeItemStatus(CrxUpdateItem::State from, CrxUpdateItem::State to);
+ size_t ChangeItemStatus(CrxUpdateItem::Status from, CrxUpdateItem::Status to);
CrxUpdateItem* FindUpdateItemById(const std::string& id) const;
@@ -199,9 +193,9 @@ class CrxUpdateService : public ComponentUpdateService, public OnDemandUpdater {
bool HasOnDemandItems() const;
- Status GetServiceStatus(const CrxUpdateItem::State state);
+ Status GetServiceStatus(const CrxUpdateItem::Status status);
- scoped_refptr<Configurator> config_;
+ scoped_ptr<Configurator> config_;
scoped_ptr<UpdateChecker> update_checker_;
@@ -233,7 +227,7 @@ class CrxUpdateService : public ComponentUpdateService, public OnDemandUpdater {
//////////////////////////////////////////////////////////////////////////////
-CrxUpdateService::CrxUpdateService(const scoped_refptr<Configurator>& config)
+CrxUpdateService::CrxUpdateService(Configurator* config)
: config_(config),
ping_manager_(new PingManager(*config)),
main_task_runner_(base::MessageLoopProxy::current()),
@@ -266,9 +260,9 @@ ComponentUpdateService::Status CrxUpdateService::Start() {
VLOG(1) << "CrxUpdateService starting up";
running_ = true;
if (work_items_.empty())
- return Status::kOk;
+ return kOk;
- NotifyObservers(Observer::Events::COMPONENT_UPDATER_STARTED, "");
+ NotifyObservers(Observer::COMPONENT_UPDATER_STARTED, "");
VLOG(1) << "First update attempt will take place in "
<< config_->InitialDelay() << " seconds";
@@ -276,7 +270,7 @@ ComponentUpdateService::Status CrxUpdateService::Start() {
base::TimeDelta::FromSeconds(config_->InitialDelay()),
this,
&CrxUpdateService::ProcessPendingItems);
- return Status::kOk;
+ return kOk;
}
// Stop the main check + update loop. In flight operations will be
@@ -285,7 +279,7 @@ ComponentUpdateService::Status CrxUpdateService::Stop() {
VLOG(1) << "CrxUpdateService stopping";
running_ = false;
timer_.Stop();
- return Status::kOk;
+ return kOk;
}
bool CrxUpdateService::HasOnDemandItems() const {
@@ -336,7 +330,7 @@ void CrxUpdateService::ScheduleNextRun(StepDelayInterval step_delay) {
}
if (step_delay != kStepDelayShort) {
- NotifyObservers(Observer::Events::COMPONENT_UPDATER_SLEEPING, "");
+ NotifyObservers(Observer::COMPONENT_UPDATER_SLEEPING, "");
// Zero is only used for unit tests.
if (0 == delay_seconds)
@@ -360,50 +354,47 @@ CrxUpdateItem* CrxUpdateService::FindUpdateItemById(
return it != work_items_.end() ? *it : NULL;
}
-// Changes a component's state, clearing on_demand and firing notifications as
+// Changes a component's status, clearing on_demand and firing notifications as
// necessary. By convention, this is the only function that can change a
-// CrxUpdateItem's |state|.
+// CrxUpdateItem's |status|.
// TODO(waffles): Do we want to add DCHECKS for valid state transitions here?
void CrxUpdateService::ChangeItemState(CrxUpdateItem* item,
- CrxUpdateItem::State to) {
+ CrxUpdateItem::Status to) {
DCHECK(thread_checker_.CalledOnValidThread());
- if (to == CrxUpdateItem::State::kNoUpdate ||
- to == CrxUpdateItem::State::kUpdated ||
- to == CrxUpdateItem::State::kUpToDate) {
+ if (to == CrxUpdateItem::kNoUpdate || to == CrxUpdateItem::kUpdated ||
+ to == CrxUpdateItem::kUpToDate) {
item->on_demand = false;
}
- item->state = to;
+ item->status = to;
switch (to) {
- case CrxUpdateItem::State::kCanUpdate:
- NotifyObservers(Observer::Events::COMPONENT_UPDATE_FOUND, item->id);
+ case CrxUpdateItem::kCanUpdate:
+ NotifyObservers(Observer::COMPONENT_UPDATE_FOUND, item->id);
break;
- case CrxUpdateItem::State::kUpdatingDiff:
- case CrxUpdateItem::State::kUpdating:
- NotifyObservers(Observer::Events::COMPONENT_UPDATE_READY, item->id);
+ case CrxUpdateItem::kUpdatingDiff:
+ case CrxUpdateItem::kUpdating:
+ NotifyObservers(Observer::COMPONENT_UPDATE_READY, item->id);
break;
- case CrxUpdateItem::State::kUpdated:
- NotifyObservers(Observer::Events::COMPONENT_UPDATED, item->id);
+ case CrxUpdateItem::kUpdated:
+ NotifyObservers(Observer::COMPONENT_UPDATED, item->id);
break;
- case CrxUpdateItem::State::kUpToDate:
- case CrxUpdateItem::State::kNoUpdate:
- NotifyObservers(Observer::Events::COMPONENT_NOT_UPDATED, item->id);
+ case CrxUpdateItem::kUpToDate:
+ case CrxUpdateItem::kNoUpdate:
+ NotifyObservers(Observer::COMPONENT_NOT_UPDATED, item->id);
break;
- case CrxUpdateItem::State::kNew:
- case CrxUpdateItem::State::kChecking:
- case CrxUpdateItem::State::kDownloading:
- case CrxUpdateItem::State::kDownloadingDiff:
- case CrxUpdateItem::State::kDownloaded:
- case CrxUpdateItem::State::kLastStatus:
+ case CrxUpdateItem::kNew:
+ case CrxUpdateItem::kChecking:
+ case CrxUpdateItem::kDownloading:
+ case CrxUpdateItem::kDownloadingDiff:
+ case CrxUpdateItem::kLastStatus:
// No notification for these states.
break;
}
// Free possible pending network requests.
- if ((to == CrxUpdateItem::State::kUpdated) ||
- (to == CrxUpdateItem::State::kUpToDate) ||
- (to == CrxUpdateItem::State::kNoUpdate)) {
+ if ((to == CrxUpdateItem::kUpdated) || (to == CrxUpdateItem::kUpToDate) ||
+ (to == CrxUpdateItem::kNoUpdate)) {
for (std::vector<base::Closure>::iterator it =
item->ready_callbacks.begin();
it != item->ready_callbacks.end();
@@ -414,17 +405,17 @@ void CrxUpdateService::ChangeItemState(CrxUpdateItem* item,
}
}
-// Changes all the components in |work_items_| that have |from| state to
-// |to| state and returns how many have been changed.
-size_t CrxUpdateService::ChangeItemStatus(CrxUpdateItem::State from,
- CrxUpdateItem::State to) {
+// Changes all the components in |work_items_| that have |from| status to
+// |to| status and returns how many have been changed.
+size_t CrxUpdateService::ChangeItemStatus(CrxUpdateItem::Status from,
+ CrxUpdateItem::Status to) {
DCHECK(thread_checker_.CalledOnValidThread());
size_t count = 0;
for (UpdateItems::iterator it = work_items_.begin();
it != work_items_.end();
++it) {
CrxUpdateItem* item = *it;
- if (item->state == from) {
+ if (item->status == from) {
ChangeItemState(item, to);
++count;
}
@@ -433,20 +424,20 @@ size_t CrxUpdateService::ChangeItemStatus(CrxUpdateItem::State from,
}
// Adds a component to be checked for upgrades. If the component exists it
-// it will be replaced and the return code is Status::kReplaced.
+// it will be replaced and the return code is kReplaced.
ComponentUpdateService::Status CrxUpdateService::RegisterComponent(
const CrxComponent& component) {
DCHECK(thread_checker_.CalledOnValidThread());
if (component.pk_hash.empty() || !component.version.IsValid() ||
!component.installer)
- return Status::kError;
+ return kError;
std::string id(GetCrxComponentID(component));
CrxUpdateItem* uit = FindUpdateItemById(id);
if (uit) {
uit->component = component;
uit->unregistered = false;
- return Status::kReplaced;
+ return kReplaced;
}
uit = new CrxUpdateItem;
@@ -472,7 +463,7 @@ ComponentUpdateService::Status CrxUpdateService::RegisterComponent(
}
}
- return Status::kOk;
+ return kOk;
}
ComponentUpdateService::Status CrxUpdateService::UnregisterComponent(
@@ -480,12 +471,12 @@ ComponentUpdateService::Status CrxUpdateService::UnregisterComponent(
auto it = std::find_if(work_items_.begin(), work_items_.end(),
CrxUpdateItem::FindById(crx_id));
if (it == work_items_.end())
- return Status::kError;
+ return kError;
(*it)->unregistered = true;
ScheduleNextRun(kStepDelayShort);
- return Status::kOk;
+ return kOk;
}
std::vector<std::string> CrxUpdateService::GetComponentIDs() const {
@@ -510,7 +501,7 @@ void CrxUpdateService::MaybeThrottle(const std::string& crx_id,
// Check if we can on-demand update, else unblock the request anyway.
CrxUpdateItem* item = FindUpdateItemById(crx_id);
Status status = OnDemandUpdateWithCooldown(item);
- if (status == Status::kOk || status == Status::kInProgress) {
+ if (status == kOk || status == kInProgress) {
item->ready_callbacks.push_back(callback);
return;
}
@@ -578,7 +569,7 @@ CrxUpdateItem* CrxUpdateService::FindReadyComponent() const {
return item->on_demand && IsReady(item);
}
static bool IsReady(CrxUpdateItem* item) {
- return item->state == CrxUpdateItem::State::kCanUpdate;
+ return item->status == CrxUpdateItem::kCanUpdate;
}
};
@@ -603,10 +594,10 @@ bool CrxUpdateService::CheckForUpdates() {
std::vector<CrxUpdateItem*> items_to_check;
for (size_t i = 0; i != work_items_.size(); ++i) {
CrxUpdateItem* item = work_items_[i];
- DCHECK(item->state == CrxUpdateItem::State::kNew ||
- item->state == CrxUpdateItem::State::kNoUpdate ||
- item->state == CrxUpdateItem::State::kUpToDate ||
- item->state == CrxUpdateItem::State::kUpdated);
+ DCHECK(item->status == CrxUpdateItem::kNew ||
+ item->status == CrxUpdateItem::kNoUpdate ||
+ item->status == CrxUpdateItem::kUpToDate ||
+ item->status == CrxUpdateItem::kUpdated);
const base::TimeDelta time_since_last_checked(now - item->last_check);
@@ -641,7 +632,7 @@ bool CrxUpdateService::CheckForUpdates() {
items_to_check.push_back(item);
- ChangeItemState(item, CrxUpdateItem::State::kChecking);
+ ChangeItemState(item, CrxUpdateItem::kChecking);
}
if (items_to_check.empty())
@@ -665,13 +656,13 @@ void CrxUpdateService::UpdateComponent(CrxUpdateItem* workitem) {
bool allow_background_download = false;
if (CanTryDiffUpdate(workitem, *config_)) {
urls = &workitem->crx_diffurls;
- ChangeItemState(workitem, CrxUpdateItem::State::kDownloadingDiff);
+ ChangeItemState(workitem, CrxUpdateItem::kDownloadingDiff);
} else {
// Background downloads are enabled only for selected components and
// only for full downloads (see issue 340448).
allow_background_download = workitem->component.allow_background_download;
urls = &workitem->crx_urls;
- ChangeItemState(workitem, CrxUpdateItem::State::kDownloading);
+ ChangeItemState(workitem, CrxUpdateItem::kDownloading);
}
// On demand component updates are always downloaded in foreground.
@@ -680,9 +671,10 @@ void CrxUpdateService::UpdateComponent(CrxUpdateItem* workitem) {
config_->UseBackgroundDownloader();
crx_downloader_.reset(
- CrxDownloader::Create(is_background_download, config_->RequestContext(),
+ CrxDownloader::Create(is_background_download,
+ config_->RequestContext(),
blocking_task_runner_,
- config_->GetSingleThreadTaskRunner()).release());
+ config_->GetSingleThreadTaskRunner()));
crx_downloader_->set_progress_callback(
base::Bind(&CrxUpdateService::DownloadProgress,
base::Unretained(this),
@@ -723,21 +715,21 @@ void CrxUpdateService::OnUpdateCheckSucceeded(
if (!crx)
continue;
- if (crx->state != CrxUpdateItem::State::kChecking) {
+ if (crx->status != CrxUpdateItem::kChecking) {
NOTREACHED();
continue; // Not updating this component now.
}
if (it->manifest.version.empty()) {
// No version means no update available.
- ChangeItemState(crx, CrxUpdateItem::State::kNoUpdate);
+ ChangeItemState(crx, CrxUpdateItem::kNoUpdate);
VLOG(1) << "No update available for component: " << crx->id;
continue;
}
if (!IsVersionNewer(crx->component.version, it->manifest.version)) {
// The component is up to date.
- ChangeItemState(crx, CrxUpdateItem::State::kUpToDate);
+ ChangeItemState(crx, CrxUpdateItem::kUpToDate);
VLOG(1) << "Component already up-to-date: " << crx->id;
continue;
}
@@ -747,7 +739,7 @@ void CrxUpdateService::OnUpdateCheckSucceeded(
it->manifest.browser_min_version)) {
// The component is not compatible with this Chrome version.
VLOG(1) << "Ignoring incompatible component: " << crx->id;
- ChangeItemState(crx, CrxUpdateItem::State::kNoUpdate);
+ ChangeItemState(crx, CrxUpdateItem::kNoUpdate);
continue;
}
}
@@ -755,7 +747,7 @@ void CrxUpdateService::OnUpdateCheckSucceeded(
if (it->manifest.packages.size() != 1) {
// Assume one and only one package per component.
VLOG(1) << "Ignoring multiple packages for component: " << crx->id;
- ChangeItemState(crx, CrxUpdateItem::State::kNoUpdate);
+ ChangeItemState(crx, CrxUpdateItem::kNoUpdate);
continue;
}
@@ -780,14 +772,13 @@ void CrxUpdateService::OnUpdateCheckSucceeded(
crx->crx_diffurls.push_back(url);
}
- ChangeItemState(crx, CrxUpdateItem::State::kCanUpdate);
+ ChangeItemState(crx, CrxUpdateItem::kCanUpdate);
++num_updates_pending;
}
// All components that are not included in the update response are
// considered up to date.
- ChangeItemStatus(CrxUpdateItem::State::kChecking,
- CrxUpdateItem::State::kUpToDate);
+ ChangeItemStatus(CrxUpdateItem::kChecking, CrxUpdateItem::kUpToDate);
// If there are updates pending we do a short wait, otherwise we take
// a longer delay until we check the components again.
@@ -798,8 +789,8 @@ void CrxUpdateService::OnUpdateCheckFailed(int error,
const std::string& error_message) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(error);
- size_t count = ChangeItemStatus(CrxUpdateItem::State::kChecking,
- CrxUpdateItem::State::kNoUpdate);
+ size_t count =
+ ChangeItemStatus(CrxUpdateItem::kChecking, CrxUpdateItem::kNoUpdate);
DCHECK_GT(count, 0ul);
VLOG(1) << "Update check failed.";
ScheduleNextRun(kStepDelayLong);
@@ -812,7 +803,7 @@ void CrxUpdateService::DownloadProgress(
const std::string& component_id,
const CrxDownloader::Result& download_result) {
DCHECK(thread_checker_.CalledOnValidThread());
- NotifyObservers(Observer::Events::COMPONENT_UPDATE_DOWNLOADING, component_id);
+ NotifyObservers(Observer::COMPONENT_UPDATE_DOWNLOADING, component_id);
}
// Called when the CRX package has been downloaded to a temporary location.
@@ -825,8 +816,8 @@ void CrxUpdateService::DownloadComplete(
CrxUpdateItem* crx = FindUpdateItemById(crx_context->id);
- DCHECK(crx->state == CrxUpdateItem::State::kDownloadingDiff ||
- crx->state == CrxUpdateItem::State::kDownloading);
+ DCHECK(crx->status == CrxUpdateItem::kDownloadingDiff ||
+ crx->status == CrxUpdateItem::kDownloading);
AppendDownloadMetrics(crx_downloader_->download_metrics(),
&crx->download_metrics);
@@ -834,12 +825,12 @@ void CrxUpdateService::DownloadComplete(
crx_downloader_.reset();
if (download_result.error) {
- if (crx->state == CrxUpdateItem::State::kDownloadingDiff) {
+ if (crx->status == CrxUpdateItem::kDownloadingDiff) {
crx->diff_error_category = kNetworkError;
crx->diff_error_code = download_result.error;
crx->diff_update_failed = true;
- size_t count = ChangeItemStatus(CrxUpdateItem::State::kDownloadingDiff,
- CrxUpdateItem::State::kCanUpdate);
+ size_t count = ChangeItemStatus(CrxUpdateItem::kDownloadingDiff,
+ CrxUpdateItem::kCanUpdate);
DCHECK_EQ(count, 1ul);
ScheduleNextRun(kStepDelayShort);
@@ -847,8 +838,8 @@ void CrxUpdateService::DownloadComplete(
}
crx->error_category = kNetworkError;
crx->error_code = download_result.error;
- size_t count = ChangeItemStatus(CrxUpdateItem::State::kDownloading,
- CrxUpdateItem::State::kNoUpdate);
+ size_t count =
+ ChangeItemStatus(CrxUpdateItem::kDownloading, CrxUpdateItem::kNoUpdate);
DCHECK_EQ(count, 1ul);
// At this point, since both the differential and the full downloads failed,
@@ -859,12 +850,12 @@ void CrxUpdateService::DownloadComplete(
ScheduleNextRun(kStepDelayMedium);
} else {
size_t count = 0;
- if (crx->state == CrxUpdateItem::State::kDownloadingDiff) {
- count = ChangeItemStatus(CrxUpdateItem::State::kDownloadingDiff,
- CrxUpdateItem::State::kUpdatingDiff);
+ if (crx->status == CrxUpdateItem::kDownloadingDiff) {
+ count = ChangeItemStatus(CrxUpdateItem::kDownloadingDiff,
+ CrxUpdateItem::kUpdatingDiff);
} else {
- count = ChangeItemStatus(CrxUpdateItem::State::kDownloading,
- CrxUpdateItem::State::kUpdating);
+ count = ChangeItemStatus(CrxUpdateItem::kDownloading,
+ CrxUpdateItem::kUpdating);
}
DCHECK_EQ(count, 1ul);
@@ -916,7 +907,7 @@ void CrxUpdateService::EndUnpacking(const std::string& component_id,
unpacker_ = NULL;
}
-// Installation has been completed. Adjust the component state and
+// Installation has been completed. Adjust the component status and
// schedule the next check. Schedule a short delay before trying the full
// update when the differential update failed.
void CrxUpdateService::DoneInstalling(const std::string& component_id,
@@ -940,13 +931,13 @@ void CrxUpdateService::DoneInstalling(const std::string& component_id,
CrxUpdateItem* item = FindUpdateItemById(component_id);
- if (item->state == CrxUpdateItem::State::kUpdatingDiff && !is_success) {
+ if (item->status == CrxUpdateItem::kUpdatingDiff && !is_success) {
item->diff_error_category = error_category;
item->diff_error_code = error;
item->diff_extra_code1 = extra_code;
item->diff_update_failed = true;
- size_t count = ChangeItemStatus(CrxUpdateItem::State::kUpdatingDiff,
- CrxUpdateItem::State::kCanUpdate);
+ size_t count = ChangeItemStatus(CrxUpdateItem::kUpdatingDiff,
+ CrxUpdateItem::kCanUpdate);
DCHECK_EQ(count, 1ul);
ScheduleNextRun(kStepDelayShort);
return;
@@ -955,12 +946,12 @@ void CrxUpdateService::DoneInstalling(const std::string& component_id,
if (is_success) {
item->component.version = item->next_version;
item->component.fingerprint = item->next_fp;
- ChangeItemState(item, CrxUpdateItem::State::kUpdated);
+ ChangeItemState(item, CrxUpdateItem::kUpdated);
} else {
item->error_category = error_category;
item->error_code = error;
item->extra_code1 = extra_code;
- ChangeItemState(item, CrxUpdateItem::State::kNoUpdate);
+ ChangeItemState(item, CrxUpdateItem::kNoUpdate);
}
ping_manager_->OnUpdateComplete(item);
@@ -978,12 +969,12 @@ void CrxUpdateService::NotifyObservers(Observer::Events event,
ComponentUpdateService::Status CrxUpdateService::OnDemandUpdateWithCooldown(
CrxUpdateItem* uit) {
if (!uit)
- return Status::kError;
+ return kError;
// Check if the request is too soon.
base::TimeDelta delta = base::Time::Now() - uit->last_check;
if (delta < base::TimeDelta::FromSeconds(config_->OnDemandDelay()))
- return Status::kError;
+ return kError;
return OnDemandUpdateInternal(uit);
}
@@ -991,23 +982,23 @@ ComponentUpdateService::Status CrxUpdateService::OnDemandUpdateWithCooldown(
ComponentUpdateService::Status CrxUpdateService::OnDemandUpdateInternal(
CrxUpdateItem* uit) {
if (!uit)
- return Status::kError;
+ return kError;
uit->on_demand = true;
// If there is an update available for this item, then continue processing
// the update. This is an artifact of how update checks are done: in addition
// to the on-demand item, the update check may include other items as well.
- if (uit->state != CrxUpdateItem::State::kCanUpdate) {
- Status service_status = GetServiceStatus(uit->state);
+ if (uit->status != CrxUpdateItem::kCanUpdate) {
+ Status service_status = GetServiceStatus(uit->status);
// If the item is already in the process of being updated, there is
- // no point in this call, so return Status::kInProgress.
- if (service_status == Status::kInProgress)
+ // no point in this call, so return kInProgress.
+ if (service_status == kInProgress)
return service_status;
// Otherwise the item was already checked a while back (or it is new),
- // set its state to kNew to give it a slightly higher priority.
- ChangeItemState(uit, CrxUpdateItem::State::kNew);
+ // set its status to kNew to give it a slightly higher priority.
+ ChangeItemState(uit, CrxUpdateItem::kNew);
}
// In case the current delay is long, set the timer to a shorter value
@@ -1020,39 +1011,37 @@ ComponentUpdateService::Status CrxUpdateService::OnDemandUpdateInternal(
&CrxUpdateService::ProcessPendingItems);
}
- return Status::kOk;
+ return kOk;
}
ComponentUpdateService::Status CrxUpdateService::GetServiceStatus(
- CrxUpdateItem::State state) {
- switch (state) {
- case CrxUpdateItem::State::kChecking:
- case CrxUpdateItem::State::kCanUpdate:
- case CrxUpdateItem::State::kDownloadingDiff:
- case CrxUpdateItem::State::kDownloading:
- case CrxUpdateItem::State::kDownloaded:
- case CrxUpdateItem::State::kUpdatingDiff:
- case CrxUpdateItem::State::kUpdating:
- return Status::kInProgress;
- case CrxUpdateItem::State::kNew:
- case CrxUpdateItem::State::kUpdated:
- case CrxUpdateItem::State::kUpToDate:
- case CrxUpdateItem::State::kNoUpdate:
- return Status::kOk;
- case CrxUpdateItem::State::kLastStatus:
- NOTREACHED() << static_cast<int>(state);
+ CrxUpdateItem::Status status) {
+ switch (status) {
+ case CrxUpdateItem::kChecking:
+ case CrxUpdateItem::kCanUpdate:
+ case CrxUpdateItem::kDownloadingDiff:
+ case CrxUpdateItem::kDownloading:
+ case CrxUpdateItem::kUpdatingDiff:
+ case CrxUpdateItem::kUpdating:
+ return kInProgress;
+ case CrxUpdateItem::kNew:
+ case CrxUpdateItem::kUpdated:
+ case CrxUpdateItem::kUpToDate:
+ case CrxUpdateItem::kNoUpdate:
+ return kOk;
+ case CrxUpdateItem::kLastStatus:
+ NOTREACHED() << status;
}
- return Status::kError;
+ return kError;
}
///////////////////////////////////////////////////////////////////////////////
// The component update factory. Using the component updater as a singleton
// is the job of the browser process.
-scoped_ptr<ComponentUpdateService> ComponentUpdateServiceFactory(
- const scoped_refptr<Configurator>& config) {
+ComponentUpdateService* ComponentUpdateServiceFactory(Configurator* config) {
DCHECK(config);
- return scoped_ptr<ComponentUpdateService>(new CrxUpdateService(config));
+ return new CrxUpdateService(config);
}
} // namespace component_updater
diff --git a/components/component_updater/component_updater_service.h b/components/component_updater/component_updater_service.h
index 6871993..ac60a7f 100644
--- a/components/component_updater/component_updater_service.h
+++ b/components/component_updater/component_updater_service.h
@@ -6,15 +6,12 @@
#define COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_
#include <stdint.h>
-
-#include <iosfwd>
#include <string>
#include <vector>
#include "base/callback_forward.h"
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "base/version.h"
#include "url/gurl.h"
@@ -64,14 +61,14 @@ class OnDemandUpdater;
// All methods are safe to call ONLY from the browser's main thread.
class ComponentUpdateService {
public:
- enum class Status { kOk, kReplaced, kInProgress, kError };
+ enum Status { kOk, kReplaced, kInProgress, kError };
// Defines an interface to observe ComponentUpdateService. It provides
// notifications when state changes occur for the service or for the
// registered components.
class Observer {
public:
- enum class Events {
+ enum Events {
// Sent when the component updater starts doing update checks.
COMPONENT_UPDATER_STARTED,
@@ -172,9 +169,7 @@ class ComponentUpdateService {
friend class ::ComponentsUI;
};
-using ServiceObserver = ComponentUpdateService::Observer;
-std::ostream& operator<<(std::ostream& os,
- const ComponentUpdateService::Status& status);
+typedef ComponentUpdateService::Observer ServiceObserver;
class OnDemandUpdater {
public:
@@ -195,9 +190,10 @@ class OnDemandUpdater {
const std::string& component_id) = 0;
};
-// Creates the component updater.
-scoped_ptr<ComponentUpdateService> ComponentUpdateServiceFactory(
- const scoped_refptr<update_client::Configurator>& config);
+// Creates the component updater. You must pass a valid |config| allocated on
+// the heap which the component updater will own.
+ComponentUpdateService* ComponentUpdateServiceFactory(
+ update_client::Configurator* config);
} // namespace component_updater
diff --git a/components/component_updater/default_component_installer.cc b/components/component_updater/default_component_installer.cc
index 36844fb..d430863 100644
--- a/components/component_updater/default_component_installer.cc
+++ b/components/component_updater/default_component_installer.cc
@@ -249,8 +249,8 @@ void DefaultComponentInstaller::FinishRegistration(
crx.fingerprint = current_fingerprint_;
installer_traits_->GetHash(&crx.pk_hash);
ComponentUpdateService::Status status = cus->RegisterComponent(crx);
- if (status != ComponentUpdateService::Status::kOk &&
- status != ComponentUpdateService::Status::kReplaced) {
+ if (status != ComponentUpdateService::kOk &&
+ status != ComponentUpdateService::kReplaced) {
NOTREACHED() << "Component registration failed for "
<< installer_traits_->GetName();
return;
diff --git a/components/component_updater/default_component_installer.h b/components/component_updater/default_component_installer.h
index f76bc83..1725798 100644
--- a/components/component_updater/default_component_installer.h
+++ b/components/component_updater/default_component_installer.h
@@ -85,7 +85,7 @@ class ComponentInstallerTraits {
// A DefaultComponentInstaller is intended to be final, and not derived from.
// Customization must be provided by passing a ComponentInstallerTraits object
// to the constructor.
-class DefaultComponentInstaller : public update_client::CrxInstaller {
+class DefaultComponentInstaller : public update_client::ComponentInstaller {
public:
DefaultComponentInstaller(
scoped_ptr<ComponentInstallerTraits> installer_traits);