Index: chrome/browser/shell_integration_win.cc |
diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc |
index 06dbc42d025ac612636b61e19ce233ebdeec3f5f..c8fc1ac86bd11b43b26bea15402ef5ec15fdea61 100644 |
--- a/chrome/browser/shell_integration_win.cc |
+++ b/chrome/browser/shell_integration_win.cc |
@@ -32,6 +32,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/time/time.h" |
#include "base/timer/timer.h" |
#include "base/win/registry.h" |
@@ -54,12 +55,9 @@ |
#include "chrome/installer/util/scoped_user_protocol_entry.h" |
#include "chrome/installer/util/shell_util.h" |
#include "components/variations/variations_associated_data.h" |
-#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/utility_process_mojo_client.h" |
#include "ui/base/l10n/l10n_util.h" |
-using content::BrowserThread; |
- |
namespace shell_integration { |
namespace { |
@@ -150,8 +148,7 @@ base::string16 GetExpectedAppId(const base::CommandLine& command_line, |
} |
void MigrateTaskbarPinsCallback() { |
- // This should run on the file thread. |
- DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
+ base::ThreadRestrictions::AssertIOAllowed(); |
// Get full path of chrome. |
base::FilePath chrome_exe; |
@@ -328,7 +325,7 @@ class OpenSystemSettingsHelper { |
// watched. The array must contain at least one element. |
static void Begin(const wchar_t* const protocols[], |
const base::Closure& on_finished_callback) { |
- DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
+ base::ThreadRestrictions::AssertIOAllowed(); |
delete instance_; |
instance_ = new OpenSystemSettingsHelper(protocols, on_finished_callback); |
@@ -364,13 +361,16 @@ class OpenSystemSettingsHelper { |
weak_ptr_factory_.GetWeakPtr(), ConcludeReason::TIMEOUT)); |
} |
+ ~OpenSystemSettingsHelper() { |
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
+ } |
+ |
// Called when a change is detected on one of the registry keys being watched. |
// Note: All types of modification to the registry key will trigger this |
// function even if the value change is the only one that matters. This |
// is good enough for now. |
void OnRegistryKeyChanged() { |
- DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
- |
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
// Make sure all the registry watchers have fired. |
if (--registry_watcher_count_ == 0) { |
UMA_HISTOGRAM_MEDIUM_TIMES( |
@@ -385,7 +385,7 @@ class OpenSystemSettingsHelper { |
// |on_finished_callback_| and then dispose of this class instance to make |
// sure the callback won't get called subsequently. |
void ConcludeInteraction(ConcludeReason conclude_reason) { |
- DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
UMA_HISTOGRAM_ENUMERATION( |
"DefaultBrowser.SettingsInteraction.ConcludeReason", conclude_reason, |
@@ -398,6 +398,8 @@ class OpenSystemSettingsHelper { |
// Helper function to create a registry watcher for a given |key_path|. Do |
// nothing on initialization failure. |
void AddRegistryKeyWatcher(const wchar_t* key_path) { |
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
+ |
auto reg_key = base::MakeUnique<base::win::RegKey>(HKEY_CURRENT_USER, |
key_path, KEY_NOTIFY); |
@@ -433,6 +435,8 @@ class OpenSystemSettingsHelper { |
// Records the time it takes for the final registry watcher to get signaled. |
base::TimeTicks start_time_; |
+ SEQUENCE_CHECKER(sequence_checker_); |
+ |
// Weak ptrs are used to bind this class to the callbacks of the timer and the |
// registry watcher. This makes it possible to self-delete after one of the |
// callbacks is executed to cancel the remaining ones. |
@@ -464,6 +468,8 @@ class IsPinnedToTaskbarHelper { |
ErrorCallback error_callback_; |
ResultCallback result_callback_; |
+ SEQUENCE_CHECKER(sequence_checker_); |
+ |
DISALLOW_COPY_AND_ASSIGN(IsPinnedToTaskbarHelper); |
}; |
@@ -497,6 +503,8 @@ IsPinnedToTaskbarHelper::IsPinnedToTaskbarHelper( |
} |
void IsPinnedToTaskbarHelper::OnConnectionError() { |
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
+ |
error_callback_.Run(); |
delete this; |
} |
@@ -504,6 +512,8 @@ void IsPinnedToTaskbarHelper::OnConnectionError() { |
void IsPinnedToTaskbarHelper::OnIsPinnedToTaskbarResult( |
bool succeeded, |
bool is_pinned_to_taskbar) { |
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
+ |
result_callback_.Run(succeeded, is_pinned_to_taskbar); |
delete this; |
} |
@@ -511,6 +521,8 @@ void IsPinnedToTaskbarHelper::OnIsPinnedToTaskbarResult( |
} // namespace |
bool SetAsDefaultBrowser() { |
+ base::ThreadRestrictions::AssertIOAllowed(); |
+ |
base::FilePath chrome_exe; |
if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { |
LOG(ERROR) << "Error getting app exe path"; |
@@ -530,6 +542,8 @@ bool SetAsDefaultBrowser() { |
} |
bool SetAsDefaultProtocolClient(const std::string& protocol) { |
+ base::ThreadRestrictions::AssertIOAllowed(); |
+ |
if (protocol.empty()) |
return false; |
@@ -625,6 +639,8 @@ DefaultWebClientState IsDefaultProtocolClient(const std::string& protocol) { |
namespace win { |
bool SetAsDefaultBrowserUsingIntentPicker() { |
+ base::ThreadRestrictions::AssertIOAllowed(); |
+ |
base::FilePath chrome_exe; |
if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { |
NOTREACHED() << "Error getting app exe path"; |
@@ -643,7 +659,7 @@ bool SetAsDefaultBrowserUsingIntentPicker() { |
void SetAsDefaultBrowserUsingSystemSettings( |
const base::Closure& on_finished_callback) { |
- DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
+ base::ThreadRestrictions::AssertIOAllowed(); |
base::FilePath chrome_exe; |
if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { |
@@ -670,6 +686,8 @@ void SetAsDefaultBrowserUsingSystemSettings( |
} |
bool SetAsDefaultProtocolClientUsingIntentPicker(const std::string& protocol) { |
+ base::ThreadRestrictions::AssertIOAllowed(); |
+ |
base::FilePath chrome_exe; |
if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { |
NOTREACHED() << "Error getting app exe path"; |
@@ -691,7 +709,7 @@ bool SetAsDefaultProtocolClientUsingIntentPicker(const std::string& protocol) { |
void SetAsDefaultProtocolClientUsingSystemSettings( |
const std::string& protocol, |
const base::Closure& on_finished_callback) { |
- DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
+ base::ThreadRestrictions::AssertIOAllowed(); |
base::FilePath chrome_exe; |
if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { |
@@ -731,14 +749,12 @@ void MigrateTaskbarPins() { |
if (base::win::GetVersion() < base::win::VERSION_WIN7) |
return; |
- // This needs to happen eventually (e.g. so that the appid is fixed and the |
- // run-time Chrome icon is merged with the taskbar shortcut), but this is not |
- // urgent and shouldn't delay Chrome startup. |
- static const int64_t kMigrateTaskbarPinsDelaySeconds = 15; |
- BrowserThread::PostDelayedTask( |
- BrowserThread::FILE, FROM_HERE, |
- base::Bind(&MigrateTaskbarPinsCallback), |
- base::TimeDelta::FromSeconds(kMigrateTaskbarPinsDelaySeconds)); |
+ // This needs to happen (e.g. so that the appid is fixed and the |
+ // run-time Chrome icon is merged with the taskbar shortcut), but it is not an |
+ // urgent task. |
+ base::PostTaskWithTraits(FROM_HERE, |
+ {base::MayBlock(), base::TaskPriority::BACKGROUND}, |
+ base::Bind(&MigrateTaskbarPinsCallback)); |
} |
void GetIsPinnedToTaskbarState( |