Commit 63811293 authored by fdoray's avatar fdoray Committed by Commit bot

Use TaskScheduler instead of blocking pool in zip_file_creator.cc.

The following traits are used:

Priority: Inherited (default)
  The priority is inherited from the calling context (i.e. TaskTraits
  are initialized with the priority of the current task).

Shutdown behavior: SKIP_ON_SHUTDOWN (default)
  Tasks posted with this mode that have not started executing at
  shutdown will never run. However, any task that has already begun
  executing when shutdown is invoked will be allowed to continue and
  will block shutdown until completion.

  Note: Previously, the task was posted to the blocking pool with
  BLOCK_SHUTDOWN (default in SequencedWorkerPool).

May Block:
  Tasks posted with MayBlock() may block. This includes but is not
  limited to tasks that wait on synchronous file I/O operations:
  read or write a file from disk, interact with a pipe or a socket,
  rename or delete a file, enumerate files in a directory, etc. This
  trait isn't required for the mere use of locks.

BUG=667892

Review-Url: https://codereview.chromium.org/2627093004
Cr-Commit-Position: refs/heads/master@{#443546}
parent 4ed25061
......@@ -9,7 +9,7 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/message_loop/message_loop.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/task_scheduler/post_task.h"
#include "chrome/common/chrome_utility_messages.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/browser_thread.h"
......@@ -22,7 +22,7 @@ using content::UtilityProcessHost;
namespace {
// Creates the destination zip file only if it does not already exist.
base::File OpenFileHandleOnBlockingThreadPool(const base::FilePath& zip_path) {
base::File OpenFileHandleAsync(const base::FilePath& zip_path) {
return base::File(zip_path, base::File::FLAG_CREATE | base::File::FLAG_WRITE);
}
......@@ -45,10 +45,9 @@ ZipFileCreator::ZipFileCreator(
void ZipFileCreator::Start() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
base::PostTaskAndReplyWithResult(
BrowserThread::GetBlockingPool(),
FROM_HERE,
base::Bind(&OpenFileHandleOnBlockingThreadPool, dest_file_),
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, base::TaskTraits().MayBlock(),
base::Bind(&OpenFileHandleAsync, dest_file_),
base::Bind(&ZipFileCreator::OnOpenFileHandle, this));
}
......
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