summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorasvitkine@chromium.org <asvitkine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-23 00:37:55 +0000
committerasvitkine@chromium.org <asvitkine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-23 00:37:55 +0000
commit77aa57ffe0e224ce0192af48167a999ad7acd581 (patch)
tree1f7d168fceddbfedabfbb008145dc3a116beb333
parent4789eb4c93ec6492078cce48cbf3a77e937f0c32 (diff)
downloadchromium_src-77aa57ffe0e224ce0192af48167a999ad7acd581.zip
chromium_src-77aa57ffe0e224ce0192af48167a999ad7acd581.tar.gz
chromium_src-77aa57ffe0e224ce0192af48167a999ad7acd581.tar.bz2
Fix unsafe use of WeakPointerFactory in BrowserOptionsHandler.
The previous code was using two weak pointer factories, detaching one so that it could get bound to the FILE thread for the "this" parameter of CheckAutoLaunch(). However, that method didn't use any instance state, so this CL changes it to be static and removes one of the factories. BUG=171329 TEST=no functional changes Review URL: https://chromiumcodereview.appspot.com/12042016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178181 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/webui/options/browser_options_handler.cc8
-rw-r--r--chrome/browser/ui/webui/options/browser_options_handler.h10
2 files changed, 7 insertions, 11 deletions
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc
index a9af8b2..faf8424 100644
--- a/chrome/browser/ui/webui/options/browser_options_handler.cc
+++ b/chrome/browser/ui/webui/options/browser_options_handler.cc
@@ -118,8 +118,7 @@ namespace options {
BrowserOptionsHandler::BrowserOptionsHandler()
: page_initialized_(false),
template_url_service_(NULL),
- ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_file_(this)),
- ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_ui_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
multiprofile_ = ProfileManager::IsMultipleProfilesEnabled();
#if !defined(OS_MACOSX)
default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this);
@@ -615,10 +614,8 @@ void BrowserOptionsHandler::InitializeHandler() {
!command_line.HasSwitch(switches::kUserDataDir)) {
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
base::Bind(&BrowserOptionsHandler::CheckAutoLaunch,
- weak_ptr_factory_for_ui_.GetWeakPtr(),
- weak_ptr_factory_for_file_.GetWeakPtr(),
+ weak_ptr_factory_.GetWeakPtr(),
profile->GetPath()));
- weak_ptr_factory_for_ui_.DetachFromThread();
}
#endif
@@ -683,6 +680,7 @@ void BrowserOptionsHandler::InitializePage() {
#endif
}
+// static
void BrowserOptionsHandler::CheckAutoLaunch(
base::WeakPtr<BrowserOptionsHandler> weak_this,
const FilePath& profile_path) {
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.h b/chrome/browser/ui/webui/options/browser_options_handler.h
index 8c8ba10..3824c99 100644
--- a/chrome/browser/ui/webui/options/browser_options_handler.h
+++ b/chrome/browser/ui/webui/options/browser_options_handler.h
@@ -104,8 +104,8 @@ class BrowserOptionsHandler
// thread (see CheckAutoLaunchCallback). A weak pointer to this is passed in
// as a parameter to avoid the need to lock between this function and the
// destructor. |profile_path| is the full path to the current profile.
- void CheckAutoLaunch(base::WeakPtr<BrowserOptionsHandler> weak_this,
- const FilePath& profile_path);
+ static void CheckAutoLaunch(base::WeakPtr<BrowserOptionsHandler> weak_this,
+ const FilePath& profile_path);
// Sets up (on the UI thread) the necessary bindings for toggling auto-launch
// (if the user is part of the auto-launch and makes sure the HTML UI knows
@@ -269,10 +269,8 @@ class BrowserOptionsHandler
TemplateURLService* template_url_service_; // Weak.
- // Used to get |weak_ptr_| to self for use on the File thread.
- base::WeakPtrFactory<BrowserOptionsHandler> weak_ptr_factory_for_file_;
- // Used to post update tasks to the UI thread.
- base::WeakPtrFactory<BrowserOptionsHandler> weak_ptr_factory_for_ui_;
+ // Used to get WeakPtr to self for use on the UI thread.
+ base::WeakPtrFactory<BrowserOptionsHandler> weak_ptr_factory_;
// True if the multiprofiles switch is enabled.
bool multiprofile_;