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); |
}; |