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

Unified Diff: chrome/browser/shell_integration.cc

Issue 2888693003: Remove the usage of BrowserThread::FILE in the shell_integration* files (Closed)
Patch Set: Add SequenceChecker and make all calls to SetAsDefault share a sequence 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..6497e0cde5448149f331d209b4c10b7ccd6d4f3a 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,
- base::Bind(&DefaultWebClientWorker::CheckIsDefault, this, false));
+ base::CreateSequencedTaskRunnerWithTraits({base::MayBlock()})
gab 2017/05/26 18:44:05 Why does this need to be called on a sequence whic
Patrick Monette 2017/05/29 18:54:14 I decided to go with sequencing everything
+ ->PostTask(FROM_HERE, base::Bind(&DefaultWebClientWorker::CheckIsDefault,
+ this, false));
}
void DefaultWebClientWorker::StartSetAsDefault() {
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE,
- base::Bind(&DefaultWebClientWorker::SetAsDefault, this));
+ GetSetDefaultTaskRunner()->PostTask(
+ FROM_HERE, base::Bind(&DefaultWebClientWorker::SetAsDefault, this));
}
///////////////////////////////////////////////////////////////////////////////
@@ -170,8 +170,38 @@ void DefaultWebClientWorker::OnCheckIsDefaultComplete(
///////////////////////////////////////////////////////////////////////////////
// DefaultWebClientWorker, private:
+scoped_refptr<base::SequencedTaskRunner>
+DefaultWebClientWorker::GetSetDefaultTaskRunner() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+#if defined(OS_WIN)
+ if (base::win::GetVersion() >= base::win::VERSION_WIN10) {
+ // On Windows 10, all the calls to SetAsDefault() must be done on the same
+ // SequencedTaskRunner (see OpenSystemSettingsHelper). Because the callers
+ // don't know each others, a global is shared between them.
+ //
+ // 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.
gab 2017/05/26 18:44:05 Feels like we might as well just sequence all atte
Patrick Monette 2017/05/29 18:54:14 Sounds good.
+ static base::SingleThreadTaskRunner* task_runner = nullptr;
gab 2017/05/26 18:44:05 Make this a scoped_refptr<> assign the result of b
Patrick Monette 2017/05/29 18:54:14 Done.
+
+ if (!task_runner) {
+ scoped_refptr<base::SingleThreadTaskRunner> new_task_runner =
+ base::CreateSingleThreadTaskRunnerWithTraits({base::MayBlock()});
+
+ new_task_runner->AddRef();
+ task_runner = new_task_runner.get();
+ }
+
+ return task_runner;
+ }
+#endif // defined(OS_WIN)
gab 2017/05/26 18:44:05 #else?
Patrick Monette 2017/05/29 18:54:14 Done.
+ return base::CreateSequencedTaskRunnerWithTraits({base::MayBlock()});
+#endif // !defined(OS_WIN)
gab 2017/05/26 18:44:05 #endif // defined(OS_WIN) ^ don't add
Patrick Monette 2017/05/29 18:54:14 Done.
+}
+
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 +210,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