Commit 2f326951 authored by Sorin Jianu's avatar Sorin Jianu Committed by Commit Bot

Create the ControlService instance when a thread pool is available.

When AppWake::AppWake() is invoked, a thread pool is not available yet.

This fix is not ideal since it changes how the class members are
initialized but the fix helps unblocking some future work.

Bug: 1113448
Change-Id: I875b1f27ef7538cc4b5d41c1646e313b2564a6c4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2339613Reviewed-by: default avatarSorin Jianu <sorin@chromium.org>
Reviewed-by: default avatarS. Ganesh <ganesh@chromium.org>
Commit-Queue: Sorin Jianu <sorin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795485}
parent 86aa351f
...@@ -20,7 +20,7 @@ namespace updater { ...@@ -20,7 +20,7 @@ namespace updater {
// ControlService interface. // ControlService interface.
class AppWake : public App { class AppWake : public App {
public: public:
AppWake() : service_(CreateControlService()) {} AppWake() = default;
private: private:
~AppWake() override = default; ~AppWake() override = default;
...@@ -32,6 +32,12 @@ class AppWake : public App { ...@@ -32,6 +32,12 @@ class AppWake : public App {
}; };
void AppWake::FirstTaskRun() { void AppWake::FirstTaskRun() {
// The service creation might need task runners and the control service needs
// to be instantiated after the base class has initialized the thread pool.
//
// TODO(crbug.com/1113448) - consider initializing the thread pool in the
// constructor of the base class or earlier, in the updater main.
service_ = CreateControlService();
service_->Run(base::BindOnce(&AppWake::Shutdown, this, 0)); service_->Run(base::BindOnce(&AppWake::Shutdown, this, 0));
} }
...@@ -39,6 +45,6 @@ scoped_refptr<App> MakeAppWake() { ...@@ -39,6 +45,6 @@ scoped_refptr<App> MakeAppWake() {
return base::MakeRefCounted<AppWake>(); return base::MakeRefCounted<AppWake>();
} }
#endif #endif // OS_WIN
} // namespace updater } // namespace updater
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment