CefComponentUpdater
Header: cef_component_updater.h
Interfaces: CefComponentUpdateCallback, CefComponent, CefComponentUpdater
Category: System Utilities
Overview
Tasks, threads, parsers, streams, cookies, URL requests, scheme registration, and constant tables.
CefComponentUpdateCallback (added=14600)
Source File: include/cef_component_updater.h
Process / Thread Context: Browser Process / UI Thread (callback invocation).
Purpose: Client-implemented callback passed to CefComponentUpdater::Update. Invoked asynchronously on the UI thread when the on-demand update operation completes — including the "already up-to-date" case (returns CEF_COMPONENT_UPDATE_ERROR_NONE), the "component doesn't exist" case, and the "service unavailable" case (both return CEF_COMPONENT_UPDATE_ERROR_SERVICE_ERROR).
Methods
void OnComplete(const CefString& component_id, cef_component_update_error_t error)
Parameters:
component_id— ID of the component that was the subject of the update.error— result code from thecef_component_update_error_tenum.
Return Value: None.
Usage Instruction: Always handle error; the callback is invoked unconditionally. Do not hold references to the callback beyond the call.
Threading Constraint: UI thread.
CefComponent (added=14600)
Source File: include/cef_component_updater.h
Process / Thread Context: Any thread (snapshot object).
Purpose: Library-provided snapshot of a component's state at the time of retrieval. State may change after retrieval; get a fresh CefComponent via CefComponentUpdater::GetComponentByID or GetComponents to observe the current state.
Methods
virtual CefString GetID()
Parameters:
- None.
Return Value: The unique identifier for this component.
Usage Instruction: Use as a stable key for cross-referencing components across snapshots.
Threading Constraint: Any thread.
virtual CefString GetName()
Parameters:
- None.
Return Value: Human-readable name; empty string if the component is not installed.
Usage Instruction: Display name; do not use as a key.
Threading Constraint: Any thread.
virtual CefString GetVersion()
Parameters:
- None.
Return Value: Version as a dotted string (e.g. "1.2.3.4"); empty if not installed.
Usage Instruction: Display/parse with a 4-part version scheme.
Threading Constraint: Any thread.
virtual cef_component_state_t GetState()
Parameters:
- None.
Return Value: State at the time this CefComponent was created. Default (cross-version) return is CEF_COMPONENT_STATE_NEW.
Usage Instruction: A component is installed iff the returned state is UPDATED, UP_TO_DATE, or RUN.
Threading Constraint: Any thread.
CefComponentUpdater (added=14600)
Source File: include/cef_component_updater.h
Process / Thread Context: Browser Process / UI Thread only. Methods return safe defaults (0 / nullptr / empty) if the context is not initialized or the service is unavailable.
Purpose: Library-provided singleton providing access to Chromium's component updater service. Allows discovery of registered components and triggering on-demand updates.
Methods
static CefRefPtr<CefComponentUpdater> GetComponentUpdater()
Parameters:
- None.
Return Value: The global CefComponentUpdater singleton, or nullptr if called from the wrong thread.
Usage Instruction: Cache on UI thread; all subsequent calls must also be on the UI thread.
Threading Constraint: UI thread.
virtual size_t GetComponentCount()
Parameters:
- None.
Return Value: Number of registered components, or 0 if the service is not available.
Usage Instruction: Use to pre-size containers before calling GetComponents.
Threading Constraint: UI thread.
virtual void GetComponents(std::vector<CefRefPtr<CefComponent>>& components)
Parameters:
components— output vector; existing contents are cleared.
Return Value: None (vector populated; may be empty if service is unavailable).
Usage Instruction: Snapshot the components you care about and call GetState on each.
Threading Constraint: UI thread.
virtual CefRefPtr<CefComponent> GetComponentByID(const CefString& component_id)
Parameters:
component_id— ID to look up.
Return Value: The component with the specified ID, or nullptr if not found or the service is unavailable.
Usage Instruction: Useful for polling a specific component's state after triggering an update.
Threading Constraint: UI thread.
virtual void Update(const CefString& component_id, cef_component_update_priority_t priority, CefRefPtr<CefComponentUpdateCallback> callback)
Parameters:
component_id— component to update.priority—CEF_COMPONENT_UPDATE_PRIORITY_BACKGROUNDor_FOREGROUND(use foreground for user-initiated updates).callback— optional; receivesOnComplete(component_id, error)asynchronously on the UI thread. May benullptrif no notification is needed.
Return Value: None (result is delivered via the callback).
Usage Instruction: The callback is always executed — including success (already up-to-date returns CEF_COMPONENT_UPDATE_ERROR_NONE), missing component (returns CEF_COMPONENT_UPDATE_ERROR_SERVICE_ERROR), and service-unavailable (returns CEF_COMPONENT_UPDATE_ERROR_SERVICE_ERROR).
Threading Constraint: UI thread for the call; callback is invoked on the UI thread.
Usage Example
// Enumerate all registered components on the UI thread.
class UpdateListener : public CefComponentUpdateCallback {
public:
CefString id_;
explicit UpdateListener(const CefString& id) : id_(id) {}
void OnComplete(const CefString& component_id,
cef_component_update_error_t error) override {
DLOG(INFO) << "Update complete for " << component_id.ToString()
<< " error=" << error;
}
};
void RefreshComponent(const CefString& component_id) {
auto updater = CefComponentUpdater::GetComponentUpdater();
if (!updater) return;
std::vector<CefRefPtr<CefComponent>> comps;
updater->GetComponents(comps);
for (auto& c : comps) {
DLOG(INFO) << "Component " << c->GetID().ToString()
<< " v" << c->GetVersion().ToString()
<< " state=" << c->GetState();
}
// Trigger a user-initiated on-demand update.
updater->Update(component_id,
CEF_COMPONENT_UPDATE_PRIORITY_FOREGROUND,
new UpdateListener(component_id));
}