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

Side by Side Diff: services/asset_bundle/asset_bundle_impl.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: move comment 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 unified diff | Download patch
« no previous file with comments | « services/asset_bundle/asset_bundle_impl.h ('k') | services/asset_bundle/asset_unpacker_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "services/asset_bundle/asset_bundle_impl.h" 5 #include "services/asset_bundle/asset_bundle_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/threading/worker_pool.h"
12 #include "mojo/common/data_pipe_utils.h" 11 #include "mojo/common/data_pipe_utils.h"
13 12
14 namespace mojo { 13 namespace mojo {
15 namespace asset_bundle { 14 namespace asset_bundle {
16 namespace { 15 namespace {
17 16
18 void Ignored(bool) { 17 void Ignored(bool) {
19 } 18 }
20 19
21 } // namespace 20 } // namespace
22 21
23 AssetBundleImpl::AssetBundleImpl(InterfaceRequest<AssetBundle> request, 22 AssetBundleImpl::AssetBundleImpl(InterfaceRequest<AssetBundle> request,
24 scoped_ptr<base::ScopedTempDir> asset_dir) 23 scoped_ptr<base::ScopedTempDir> asset_dir,
25 : binding_(this, request.Pass()), asset_dir_(asset_dir.Pass()) { 24 scoped_refptr<base::TaskRunner> worker_runner)
25 : binding_(this, request.Pass()),
26 asset_dir_(asset_dir.Pass()),
27 worker_runner_(worker_runner.Pass()) {
26 } 28 }
27 29
28 AssetBundleImpl::~AssetBundleImpl() { 30 AssetBundleImpl::~AssetBundleImpl() {
29 } 31 }
30 32
31 void AssetBundleImpl::GetAsStream( 33 void AssetBundleImpl::GetAsStream(
32 const String& asset_name, 34 const String& asset_name,
33 const Callback<void(ScopedDataPipeConsumerHandle)>& callback) { 35 const Callback<void(ScopedDataPipeConsumerHandle)>& callback) {
34 DataPipe pipe; 36 DataPipe pipe;
35 callback.Run(pipe.consumer_handle.Pass()); 37 callback.Run(pipe.consumer_handle.Pass());
36 38
37 std::string asset_string = asset_name.To<std::string>(); 39 std::string asset_string = asset_name.To<std::string>();
38 base::FilePath asset_path = 40 base::FilePath asset_path =
39 base::MakeAbsoluteFilePath(asset_dir_->path().Append(asset_string)); 41 base::MakeAbsoluteFilePath(asset_dir_->path().Append(asset_string));
40 42
41 if (!asset_dir_->path().IsParent(asset_path)) { 43 if (!asset_dir_->path().IsParent(asset_path)) {
42 LOG(WARNING) << "Requested asset '" << asset_string << "' does not exist."; 44 LOG(WARNING) << "Requested asset '" << asset_string << "' does not exist.";
43 return; 45 return;
44 } 46 }
45 47
46 scoped_refptr<base::TaskRunner> worker = 48 common::CopyFromFile(asset_path, pipe.producer_handle.Pass(), 0,
47 base::WorkerPool::GetTaskRunner(true); 49 worker_runner_.get(), base::Bind(&Ignored));
48 common::CopyFromFile(asset_path, pipe.producer_handle.Pass(), 0, worker.get(),
49 base::Bind(&Ignored));
50 } 50 }
51 51
52 } // namespace asset_bundle 52 } // namespace asset_bundle
53 } // namespace mojo 53 } // namespace mojo
OLDNEW
« no previous file with comments | « services/asset_bundle/asset_bundle_impl.h ('k') | services/asset_bundle/asset_unpacker_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698