Migrate nacl off of deprecated BlockingPool
These are the very last calls in the codebase!
R=bradnelson@chromium.org
Bug: 667892
Change-Id: Ifd44215b9df0b47af2c83e64646d4a794df2222c
Reviewed-on: https://chromium-review.googlesource.com/663887
Commit-Queue: Brad Nelson <bradnelson@chromium.org>
Reviewed-by: Brad Nelson <bradnelson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501720}
diff --git a/components/nacl/browser/nacl_browser.cc b/components/nacl/browser/nacl_browser.cc
index ccafb43..a9b0ae9 100644
--- a/components/nacl/browser/nacl_browser.cc
+++ b/components/nacl/browser/nacl_browser.cc
@@ -31,7 +31,6 @@
// An arbitrary delay to coalesce multiple writes to the cache.
const int kValidationCacheCoalescingTimeMS = 6000;
-const char kValidationCacheSequenceName[] = "NaClValidationCache";
const base::FilePath::CharType kValidationCacheFileName[] =
FILE_PATH_LITERAL("nacl_validation_cache.bin");
@@ -537,8 +536,7 @@
// the user interface for cache clearing is likely waiting for the callback.
// In addition, we need to make sure the cache is actually cleared before
// invoking the callback to meet the implicit guarantees of the UI.
- content::BrowserThread::PostBlockingPoolSequencedTask(
- kValidationCacheSequenceName,
+ file_task_runner_->PostTask(
FROM_HERE,
base::Bind(RemoveCache, validation_cache_file_path_, callback));
}
@@ -582,11 +580,9 @@
// not allowed on the IO thread (which is the thread this method runs on)
// because it can degrade the responsiveness of the browser.
// The task is sequenced so that multiple writes happen in order.
- content::BrowserThread::PostBlockingPoolSequencedTask(
- kValidationCacheSequenceName,
- FROM_HERE,
- base::Bind(WriteCache, validation_cache_file_path_,
- base::Owned(pickle)));
+ file_task_runner_->PostTask(
+ FROM_HERE, base::Bind(WriteCache, validation_cache_file_path_,
+ base::Owned(pickle)));
}
validation_cache_is_modified_ = false;
}
diff --git a/components/nacl/browser/nacl_browser.h b/components/nacl/browser/nacl_browser.h
index fc05e53..43f688b 100644
--- a/components/nacl/browser/nacl_browser.h
+++ b/components/nacl/browser/nacl_browser.h
@@ -14,6 +14,7 @@
#include "base/containers/mru_cache.h"
#include "base/files/file.h"
#include "base/macros.h"
+#include "base/task_scheduler/post_task.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/nacl/browser/nacl_browser_delegate.h"
@@ -204,6 +205,10 @@
base::circular_deque<base::Time> crash_times_;
+ scoped_refptr<base::SequencedTaskRunner> file_task_runner_ =
+ base::CreateSequencedTaskRunnerWithTraits(
+ {base::MayBlock(), base::TaskPriority::USER_VISIBLE});
+
DISALLOW_COPY_AND_ASSIGN(NaClBrowser);
};
diff --git a/components/nacl/browser/pnacl_host.cc b/components/nacl/browser/pnacl_host.cc
index a3dafd7..9bcd9d8 100644
--- a/components/nacl/browser/pnacl_host.cc
+++ b/components/nacl/browser/pnacl_host.cc
@@ -14,7 +14,6 @@
#include "base/logging.h"
#include "base/numerics/safe_math.h"
#include "base/task_scheduler/post_task.h"
-#include "base/threading/sequenced_worker_pool.h"
#include "components/nacl/browser/nacl_browser.h"
#include "components/nacl/browser/pnacl_translation_cache.h"
#include "content/public/browser/browser_thread.h"
@@ -178,7 +177,7 @@
///////////////////////////////////////// Temp files
-// Create a temporary file on the blocking pool
+// Create a temporary file on |file_task_runner_|.
// static
void PnaclHost::DoCreateTemporaryFile(base::FilePath temp_dir,
TempFileCallback cb) {
@@ -204,10 +203,9 @@
}
void PnaclHost::CreateTemporaryFile(TempFileCallback cb) {
- if (!BrowserThread::PostBlockingPoolSequencedTask(
- "PnaclHostCreateTempFile",
- FROM_HERE,
- base::Bind(&PnaclHost::DoCreateTemporaryFile, temp_dir_, cb))) {
+ if (!file_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&PnaclHost::DoCreateTemporaryFile, temp_dir_, cb))) {
DCHECK(thread_checker_.CalledOnValidThread());
cb.Run(base::File());
}
diff --git a/components/nacl/browser/pnacl_host.h b/components/nacl/browser/pnacl_host.h
index ff3f04eb..04741e1 100644
--- a/components/nacl/browser/pnacl_host.h
+++ b/components/nacl/browser/pnacl_host.h
@@ -13,6 +13,7 @@
#include "base/callback.h"
#include "base/files/file.h"
#include "base/macros.h"
+#include "base/task_scheduler/post_task.h"
#include "base/threading/thread_checker.h"
#include "components/nacl/browser/nacl_file_host.h"
#include "components/nacl/common/pnacl_types.h"
@@ -177,6 +178,10 @@
void DeInitIfSafe();
+ scoped_refptr<base::SequencedTaskRunner> file_task_runner_ =
+ base::CreateSequencedTaskRunnerWithTraits(
+ {base::MayBlock(), base::TaskPriority::USER_VISIBLE});
+
// Operations which are pending with the cache backend, which we should
// wait for before destroying it (see comment on DeInitIfSafe).
int pending_backend_operations_ = 0;