| Index: components/update_client/update_engine.h
|
| diff --git a/components/update_client/update_engine.h b/components/update_client/update_engine.h
|
| index e24b2a178cbda12b92e8547bb9af10c2d213a3ff..cec91f987dcf5e200d36f75e730e6240bebb57e5 100644
|
| --- a/components/update_client/update_engine.h
|
| +++ b/components/update_client/update_engine.h
|
| @@ -5,6 +5,7 @@
|
| #ifndef COMPONENTS_UPDATE_CLIENT_UPDATE_ENGINE_H_
|
| #define COMPONENTS_UPDATE_CLIENT_UPDATE_ENGINE_H_
|
|
|
| +#include <iterator>
|
| #include <list>
|
| #include <map>
|
| #include <memory>
|
| @@ -17,7 +18,8 @@
|
| #include "base/macros.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/threading/thread_checker.h"
|
| -#include "components/update_client/action.h"
|
| +#include "base/time/time.h"
|
| +#include "components/update_client/component.h"
|
| #include "components/update_client/component_patcher_operation.h"
|
| #include "components/update_client/crx_downloader.h"
|
| #include "components/update_client/crx_update_item.h"
|
| @@ -28,7 +30,6 @@
|
| namespace base {
|
| class TimeTicks;
|
| class SequencedTaskRunner;
|
| -class SingleThreadTaskRunner;
|
| } // namespace base
|
|
|
| namespace update_client {
|
| @@ -61,13 +62,37 @@ class UpdateEngine {
|
| const UpdateClient::CrxDataCallback& crx_data_callback,
|
| const Callback& update_callback);
|
|
|
| + void SendUninstallPing(const std::string& id,
|
| + const base::Version& version,
|
| + int reason,
|
| + const Callback& update_callback);
|
| +
|
| private:
|
| - void UpdateComplete(UpdateContext* update_context, Error error);
|
| + using UpdateContexts = std::set<std::unique_ptr<UpdateContext>>;
|
| + using UpdateContextIterator = UpdateContexts::iterator;
|
| +
|
| + void UpdateComplete(const UpdateContextIterator& it, Error error);
|
| +
|
| + void ComponentCheckingForUpdatesStart(const UpdateContextIterator& it,
|
| + const Component& component);
|
| + void ComponentCheckingForUpdatesComplete(const UpdateContextIterator& it,
|
| + const Component& component);
|
| + void UpdateCheckComplete(const UpdateContextIterator& it);
|
| +
|
| + void DoUpdateCheck(const UpdateContextIterator& it);
|
| + void UpdateCheckDone(const UpdateContextIterator& it,
|
| + int error,
|
| + int retry_after_sec);
|
| +
|
| + void HandleComponent(const UpdateContextIterator& it);
|
| + void HandleComponentComplete(const UpdateContextIterator& it);
|
|
|
| // Returns true if the update engine rejects this update call because it
|
| // occurs too soon.
|
| bool IsThrottled(bool is_foreground) const;
|
|
|
| + // base::TimeDelta GetNextUpdateDelay(const Component& component) const;
|
| +
|
| base::ThreadChecker thread_checker_;
|
|
|
| scoped_refptr<Configurator> config_;
|
| @@ -84,7 +109,7 @@ class UpdateEngine {
|
| const NotifyObserversCallback notify_observers_callback_;
|
|
|
| // Contains the contexts associated with each update in progress.
|
| - std::set<UpdateContext*> update_contexts_;
|
| + UpdateContexts update_contexts_;
|
|
|
| // Implements a rate limiting mechanism for background update checks. Has the
|
| // effect of rejecting the update call if the update call occurs before
|
| @@ -104,16 +129,14 @@ struct UpdateContext {
|
| const UpdateClient::CrxDataCallback& crx_data_callback,
|
| const UpdateEngine::NotifyObserversCallback& notify_observers_callback,
|
| const UpdateEngine::Callback& callback,
|
| - UpdateChecker::Factory update_checker_factory,
|
| - CrxDownloader::Factory crx_downloader_factory,
|
| - PingManager* ping_manager);
|
| + CrxDownloader::Factory crx_downloader_factory);
|
|
|
| ~UpdateContext();
|
|
|
| scoped_refptr<Configurator> config;
|
|
|
| // True if this update has been initiated by the user.
|
| - bool is_foreground;
|
| + bool is_foreground = false;
|
|
|
| // True if the component updates are enabled in this context.
|
| const bool enabled_component_updates;
|
| @@ -130,30 +153,34 @@ struct UpdateContext {
|
| // Called when the all updates associated with this context have completed.
|
| const UpdateEngine::Callback callback;
|
|
|
| - // Posts replies back to the main thread.
|
| - scoped_refptr<base::SingleThreadTaskRunner> main_task_runner;
|
| -
|
| // Runs tasks in a blocking thread pool.
|
| scoped_refptr<base::SequencedTaskRunner> blocking_task_runner;
|
|
|
| - // Creates instances of UpdateChecker;
|
| - UpdateChecker::Factory update_checker_factory;
|
| -
|
| // Creates instances of CrxDownloader;
|
| CrxDownloader::Factory crx_downloader_factory;
|
|
|
| - PingManager* ping_manager; // Not owned by this class.
|
| + std::unique_ptr<UpdateChecker> update_checker;
|
|
|
| - std::unique_ptr<Action> current_action;
|
| + // The time in seconds to wait until doing further update checks.
|
| + int retry_after_sec = 0;
|
|
|
| - // Contains the CrxUpdateItem instances of the items to update.
|
| - IdToCrxUpdateItemMap update_items;
|
| + int update_check_error = 0;
|
| + size_t num_components_ready_to_check = 0;
|
| + size_t num_components_checked = 0;
|
|
|
| - // Contains the ids of the items to update.
|
| - std::queue<std::string> queue;
|
| + IdToComponentPtrMap components;
|
|
|
| - // The time in seconds to wait until doing further update checks.
|
| - int retry_after_sec;
|
| + std::queue<std::string> component_queue;
|
| +
|
| + // The time to wait before handling the update for a component.
|
| + // The wait time is proportional with the cost incurred by updating
|
| + // the component. The more time it takes to download and apply the
|
| + // update for the current component, the longer the wait until the engine
|
| + // is handling the next component in the queue.
|
| + base::TimeDelta next_update_delay;
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(UpdateContext);
|
| };
|
|
|
| } // namespace update_client
|
|
|