Chromium Code Reviews| Index: chromeos/printing/ppd_cache.cc |
| diff --git a/chromeos/printing/ppd_cache.cc b/chromeos/printing/ppd_cache.cc |
| index 44abfd9565168c4122bf1cf794be57929bea3c7b..0cc007925e374b366ecd38a8e37d805e6e003aac 100644 |
| --- a/chromeos/printing/ppd_cache.cc |
| +++ b/chromeos/printing/ppd_cache.cc |
| @@ -15,6 +15,7 @@ |
| #include "base/strings/string_number_conversions.h" |
| #include "base/strings/string_util.h" |
| #include "base/synchronization/lock.h" |
| +#include "base/task_scheduler/post_task.h" |
| #include "base/threading/sequenced_task_runner_handle.h" |
| #include "base/threading/thread_restrictions.h" |
| #include "base/time/time.h" |
| @@ -30,16 +31,21 @@ namespace { |
| class PpdCacheImpl : public PpdCache { |
| public: |
| - PpdCacheImpl(const base::FilePath& cache_base_dir, |
| - const scoped_refptr<base::SequencedTaskRunner>& disk_task_runner) |
| - : cache_base_dir_(cache_base_dir), disk_task_runner_(disk_task_runner) {} |
| + explicit PpdCacheImpl(const base::FilePath& cache_base_dir) |
| + : cache_base_dir_(cache_base_dir), |
| + fetch_task_runner_(base::CreateSequencedTaskRunnerWithTraits( |
| + {base::TaskPriority::USER_VISIBLE, |
| + base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})), |
| + store_task_runner_(base::CreateSequencedTaskRunnerWithTraits( |
| + {base::TaskPriority::BACKGROUND, |
| + base::TaskShutdownBehavior::BLOCK_SHUTDOWN})) {} |
| // Public API functions. |
| void Find(const std::string& key, const FindCallback& cb) override { |
| // Ensure the cache lives until the op is over. |
| AddRef(); |
| ++inflight_ops_; |
| - disk_task_runner_->PostTask( |
| + fetch_task_runner_->PostTask( |
| FROM_HERE, base::Bind(&PpdCacheImpl::FindImpl, this, key, |
| base::SequencedTaskRunnerHandle::Get(), cb)); |
| } |
| @@ -51,7 +57,7 @@ class PpdCacheImpl : public PpdCache { |
| const base::Callback<void()>& cb) override { |
| AddRef(); |
| ++inflight_ops_; |
| - disk_task_runner_->PostTask( |
| + store_task_runner_->PostTask( |
|
gab
2017/06/19 15:13:21
It's weird to run read/write on different sequence
skau
2017/06/19 23:31:08
I was able to convert the tasks to anonymous metho
|
| FROM_HERE, base::Bind(&PpdCacheImpl::StoreImpl, this, key, contents, |
| base::SequencedTaskRunnerHandle::Get(), cb)); |
| } |
| @@ -159,7 +165,8 @@ class PpdCacheImpl : public PpdCache { |
| int inflight_ops_ = 0; |
| base::FilePath cache_base_dir_; |
| - scoped_refptr<base::SequencedTaskRunner> disk_task_runner_; |
| + scoped_refptr<base::SequencedTaskRunner> fetch_task_runner_; |
| + scoped_refptr<base::SequencedTaskRunner> store_task_runner_; |
| DISALLOW_COPY_AND_ASSIGN(PpdCacheImpl); |
| }; |
| @@ -167,11 +174,8 @@ class PpdCacheImpl : public PpdCache { |
| } // namespace |
| // static |
| -scoped_refptr<PpdCache> PpdCache::Create( |
| - const base::FilePath& cache_base_dir, |
| - scoped_refptr<base::SequencedTaskRunner> disk_task_runner) { |
| - return scoped_refptr<PpdCache>( |
| - new PpdCacheImpl(cache_base_dir, disk_task_runner)); |
| +scoped_refptr<PpdCache> PpdCache::Create(const base::FilePath& cache_base_dir) { |
| + return scoped_refptr<PpdCache>(new PpdCacheImpl(cache_base_dir)); |
| } |
| } // namespace printing |