Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1063)

Unified Diff: services/asset_bundle/main.cc

Issue 1206673006: Don't use base::WorkerPool in the asset_bundle app. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/asset_bundle/asset_unpacker_job.cc ('k') | sky/shell/ui/internals.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/asset_bundle/main.cc
diff --git a/services/asset_bundle/main.cc b/services/asset_bundle/main.cc
index ea59dd0aabb4b6e6b28a1d331f0af4239c72ba08..815a22a50e588fd4ce1541bad4c7d383e03495d2 100644
--- a/services/asset_bundle/main.cc
+++ b/services/asset_bundle/main.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/macros.h"
+#include "base/threading/sequenced_worker_pool.h"
#include "mojo/application/application_runner_chromium.h"
#include "mojo/public/c/system/main.h"
#include "mojo/public/cpp/application/application_connection.h"
@@ -16,6 +17,7 @@ namespace asset_bundle {
class AssetBundleApp : public ApplicationDelegate,
public InterfaceFactory<AssetUnpacker> {
public:
+ // TODO(vtl): What's the "right" way to choose the maximum number of threads?
kulakowski 2015/06/24 22:19:08 This could maybe be closer to the magical |4| cons
viettrungluu 2015/06/24 22:23:43 Done. (Forgot to move the comment after I discover
AssetBundleApp() {}
~AssetBundleApp() override {}
@@ -29,9 +31,24 @@ class AssetBundleApp : public ApplicationDelegate,
// |InterfaceFactory<AssetUnpacker>| implementation:
void Create(ApplicationConnection* connection,
InterfaceRequest<AssetUnpacker> request) override {
- new AssetUnpackerImpl(request.Pass());
+ // Lazily initialize |sequenced_worker_pool_|. (We can't create it in the
+ // constructor, since AtExitManager is only created in
+ // ApplicationRunnerChromium::Run().)
+ if (!sequenced_worker_pool_) {
+ sequenced_worker_pool_ =
+ new base::SequencedWorkerPool(4, "AssetBundleWorker");
+ }
+
+ new AssetUnpackerImpl(
+ request.Pass(),
+ sequenced_worker_pool_->GetTaskRunnerWithShutdownBehavior(
+ base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
}
+ // We don't really need the "sequenced" part, but we need to be able to shut
+ // down our worker pool.
+ scoped_refptr<base::SequencedWorkerPool> sequenced_worker_pool_;
+
DISALLOW_COPY_AND_ASSIGN(AssetBundleApp);
};
« no previous file with comments | « services/asset_bundle/asset_unpacker_job.cc ('k') | sky/shell/ui/internals.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698