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

Unified Diff: chrome/browser/shell_integration.cc

Issue 2888693003: Remove the usage of BrowserThread::FILE in the shell_integration* files (Closed)
Patch Set: Stuff 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
Index: chrome/browser/shell_integration.cc
diff --git a/chrome/browser/shell_integration.cc b/chrome/browser/shell_integration.cc
index a846887aa0d8bb3a30a26c9878843fec0096d1bd..36881ea6375dad3da16ddad7be006a9ab2022f60 100644
--- a/chrome/browser/shell_integration.cc
+++ b/chrome/browser/shell_integration.cc
@@ -11,6 +11,7 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/task_scheduler/post_task.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "chrome/browser/policy/policy_path_parser.h"
@@ -136,15 +137,14 @@ base::string16 GetAppShortcutsSubdirName() {
//
void DefaultWebClientWorker::StartCheckIsDefault() {
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE,
+ GetTaskRunner()->PostTask(
+ FROM_HERE,
base::Bind(&DefaultWebClientWorker::CheckIsDefault, this, false));
}
void DefaultWebClientWorker::StartSetAsDefault() {
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE,
- base::Bind(&DefaultWebClientWorker::SetAsDefault, this));
+ GetTaskRunner()->PostTask(
+ FROM_HERE, base::Bind(&DefaultWebClientWorker::SetAsDefault, this));
}
///////////////////////////////////////////////////////////////////////////////
@@ -170,8 +170,36 @@ void DefaultWebClientWorker::OnCheckIsDefaultComplete(
///////////////////////////////////////////////////////////////////////////////
// DefaultWebClientWorker, private:
+scoped_refptr<base::SequencedTaskRunner>
+DefaultWebClientWorker::GetTaskRunner() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ static scoped_refptr<base::SequencedTaskRunner>* task_runner = nullptr;
gab 2017/05/30 19:22:21 I think this can just be a static scoped_refptr<b
Patrick Monette 2017/05/31 16:13:57 As per offline discussion, keeping this as a point
robliao 2017/07/14 21:13:13 Wait, why must function static variables be POD? A
Patrick Monette 2017/07/14 21:25:34 Prescribed by the style guide. https://google.gith
robliao 2017/07/14 21:30:57 Got it. I thought that only applied at the global
+
+ if (!task_runner) {
+#if defined(OS_WIN)
+ if (base::win::GetVersion() >= base::win::VERSION_WIN10) {
+ // TODO(pmonette): Windows 10's implementation uses a base::Timer which
+ // currently still requires a SingleThreadTaskRunner. Change this to a
+ // SequencedTaskRunner when crbug.com/552633 is fixed.
+ task_runner = new scoped_refptr<base::SequencedTaskRunner>(
gab 2017/05/30 19:22:21 and then here you can forgo this new
Patrick Monette 2017/05/31 16:13:57 Acknowledged.
+ base::CreateSingleThreadTaskRunnerWithTraits({base::MayBlock()}));
+ } else {
+ task_runner = new scoped_refptr<base::SequencedTaskRunner>(
+ base::CreateSequencedTaskRunnerWithTraits({base::MayBlock()}));
+ }
+#else // defined(OS_WIN)
+ task_runner = new scoped_refptr<base::SequencedTaskRunner>(
+ base::CreateSequencedTaskRunnerWithTraits({base::MayBlock()}));
+#endif // defined(OS_WIN)
+ }
+
+ return *task_runner;
+}
+
void DefaultWebClientWorker::CheckIsDefault(bool is_following_set_as_default) {
- DCHECK_CURRENTLY_ON(BrowserThread::FILE);
+ base::ThreadRestrictions::AssertIOAllowed();
+
DefaultWebClientState state = CheckIsDefaultImpl();
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
@@ -180,7 +208,7 @@ void DefaultWebClientWorker::CheckIsDefault(bool is_following_set_as_default) {
}
void DefaultWebClientWorker::SetAsDefault() {
- DCHECK_CURRENTLY_ON(BrowserThread::FILE);
+ base::ThreadRestrictions::AssertIOAllowed();
// SetAsDefaultImpl will make sure the callback is executed exactly once.
SetAsDefaultImpl(

Powered by Google App Engine
This is Rietveld 408576698