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

Unified Diff: extensions/browser/web_ui_user_script_loader.cc

Issue 2898523002: Remove the usage of BrowserThread::FILE in web_ui_user_script_loader.cc (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/browser/user_script_loader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/web_ui_user_script_loader.cc
diff --git a/extensions/browser/web_ui_user_script_loader.cc b/extensions/browser/web_ui_user_script_loader.cc
index facbadb0ee2ed8f91890418bdd723eb0550b02aa..e3f48b3366f4ce891cebce5ce9b9c87bbd8a67a4 100644
--- a/extensions/browser/web_ui_user_script_loader.cc
+++ b/extensions/browser/web_ui_user_script_loader.cc
@@ -4,25 +4,32 @@
#include "extensions/browser/web_ui_user_script_loader.h"
+#include <set>
+#include <string>
#include <utility>
#include "base/bind.h"
+#include "base/memory/ref_counted.h"
+#include "base/sequenced_task_runner.h"
#include "base/strings/string_util.h"
+#include "base/task_scheduler/post_task.h"
+#include "base/threading/sequenced_task_runner_handle.h"
#include "content/public/browser/browser_context.h"
-#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h"
namespace {
-void SerializeOnFileThread(
+void SerializeOnBlockingTask(
+ scoped_refptr<base::SequencedTaskRunner> task_runner,
std::unique_ptr<extensions::UserScriptList> user_scripts,
extensions::UserScriptLoader::LoadScriptsCallback callback) {
std::unique_ptr<base::SharedMemory> memory =
extensions::UserScriptLoader::Serialize(*user_scripts);
- content::BrowserThread::PostTask(
- content::BrowserThread::UI, FROM_HERE,
- base::Bind(callback, base::Passed(&user_scripts), base::Passed(&memory)));
+
+ task_runner->PostTask(
+ FROM_HERE, base::BindOnce(std::move(callback), std::move(user_scripts),
+ std::move(memory)));
}
} // namespace
@@ -68,7 +75,7 @@ void WebUIUserScriptLoader::LoadScripts(
LoadScriptsCallback callback) {
DCHECK(!user_scripts_cache_) << "Loading scripts in flight.";
user_scripts_cache_.swap(user_scripts);
- scripts_loaded_callback_ = callback;
+ scripts_loaded_callback_ = std::move(callback);
// The total number of the tasks is used to trace whether all the fetches
// are complete. Therefore, we store all the fetcher pointers in |fetchers_|
@@ -156,10 +163,9 @@ void WebUIUserScriptLoader::OnSingleWebUIURLFetchComplete(
}
void WebUIUserScriptLoader::OnWebUIURLFetchComplete() {
- content::BrowserThread::PostTask(
- content::BrowserThread::FILE, FROM_HERE,
- base::Bind(&SerializeOnFileThread, base::Passed(&user_scripts_cache_),
- scripts_loaded_callback_));
- scripts_loaded_callback_.Reset();
- user_scripts_cache_.reset();
+ base::PostTaskWithTraits(
+ FROM_HERE, {base::MayBlock()},
+ base::BindOnce(
+ &SerializeOnBlockingTask, base::SequencedTaskRunnerHandle::Get(),
+ std::move(user_scripts_cache_), std::move(scripts_loaded_callback_)));
}
« no previous file with comments | « extensions/browser/user_script_loader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698