Skip to content

Commit

Permalink
Use TaskScheduler instead of blocking pool in chrome_download_manager…
Browse files Browse the repository at this point in the history
…_delegate.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/2623313002
Cr-Commit-Position: refs/heads/master@{#443231}
  • Loading branch information
fdoray authored and Commit bot committed Jan 12, 2017
1 parent 6f9dd03 commit d5cf623
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions chrome/browser/download/chrome_download_manager_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "base/rand_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task_runner.h"
#include "base/task_runner_util.h"
#include "base/task_scheduler/post_task.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/time/time.h"
#include "build/build_config.h"
Expand Down Expand Up @@ -176,7 +176,7 @@ void CheckDownloadUrlDone(

#endif // FULL_SAFE_BROWSING

// Called on the blocking pool to determine the MIME type for |path|.
// Called asynchronously to determine the MIME type for |path|.
std::string GetMimeType(const base::FilePath& path) {
std::string mime_type;
net::GetMimeTypeFromFile(path, &mime_type);
Expand Down Expand Up @@ -676,10 +676,9 @@ void ChromeDownloadManagerDelegate::GetFileMimeType(
const base::FilePath& path,
const GetFileMimeTypeCallback& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
base::PostTaskAndReplyWithResult(BrowserThread::GetBlockingPool(),
FROM_HERE,
base::Bind(&GetMimeType, path),
callback);
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, base::TaskTraits().MayBlock(), base::Bind(&GetMimeType, path),
callback);
}

#if defined(FULL_SAFE_BROWSING)
Expand Down

0 comments on commit d5cf623

Please sign in to comment.