summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-16 21:30:07 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-16 21:30:07 +0000
commitf41301e22f97b5117f8b6ada563d7916b01fe56c (patch)
tree5fb1ecea7b16d71c740a44651b8588b500b9ad77 /chrome/browser
parent92b004f5485530d81daab60b5b02207507d1a2bd (diff)
downloadchromium_src-f41301e22f97b5117f8b6ada563d7916b01fe56c.zip
chromium_src-f41301e22f97b5117f8b6ada563d7916b01fe56c.tar.gz
chromium_src-f41301e22f97b5117f8b6ada563d7916b01fe56c.tar.bz2
Spellchecker: call init *after* constructor.
This fixes the error where PostTask would post the task to the file thread and release its reference before the constructor returned. credit for fix goes to jam@ and thestig@ Review URL: http://codereview.chromium.org/399011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32089 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/profile.cc4
-rw-r--r--chrome/browser/spellcheck_host.cc10
-rw-r--r--chrome/browser/spellcheck_host.h4
3 files changed, 12 insertions, 6 deletions
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc
index 76d9b3d..2b6eb4e 100644
--- a/chrome/browser/profile.cc
+++ b/chrome/browser/profile.cc
@@ -1318,11 +1318,12 @@ void ProfileImpl::ReinitializeSpellCheckHost(bool force) {
if (!force && spellcheck_host_.get())
return;
+ spellcheck_host_ready_ = false;
+
bool notify = false;
if (spellcheck_host_.get()) {
spellcheck_host_->UnsetObserver();
spellcheck_host_ = NULL;
- spellcheck_host_ready_ = false;
notify = true;
}
@@ -1332,6 +1333,7 @@ void ProfileImpl::ReinitializeSpellCheckHost(bool force) {
spellcheck_host_ = new SpellCheckHost(this,
WideToASCII(prefs->GetString(prefs::kSpellCheckDictionary)),
GetRequestContext());
+ spellcheck_host_->Initialize();
} else if (notify) {
// The spellchecker has been disabled.
SpellCheckHostInitialized();
diff --git a/chrome/browser/spellcheck_host.cc b/chrome/browser/spellcheck_host.cc
index c9fea3ecf..6e77e19 100644
--- a/chrome/browser/spellcheck_host.cc
+++ b/chrome/browser/spellcheck_host.cc
@@ -144,9 +144,6 @@ SpellCheckHost::SpellCheckHost(Observer* observer,
PathService::Get(chrome::DIR_USER_DATA, &personal_file_directory);
custom_dictionary_file_ =
personal_file_directory.Append(chrome::kCustomDictionaryFileName);
-
- ChromeThread::PostTask(ChromeThread::FILE, FROM_HERE,
- NewRunnableMethod(this, &SpellCheckHost::Initialize));
}
SpellCheckHost::~SpellCheckHost() {
@@ -154,6 +151,11 @@ SpellCheckHost::~SpellCheckHost() {
close(fd_.fd);
}
+void SpellCheckHost::Initialize() {
+ ChromeThread::PostTask(ChromeThread::FILE, FROM_HERE,
+ NewRunnableMethod(this, &SpellCheckHost::InitializeInternal));
+}
+
void SpellCheckHost::UnsetObserver() {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
@@ -172,7 +174,7 @@ void SpellCheckHost::AddWord(const std::string& word) {
Source<SpellCheckHost>(this), NotificationService::NoDetails());
}
-void SpellCheckHost::Initialize() {
+void SpellCheckHost::InitializeInternal() {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE));
if (!observer_)
diff --git a/chrome/browser/spellcheck_host.h b/chrome/browser/spellcheck_host.h
index 8c2ef55..ac540f1 100644
--- a/chrome/browser/spellcheck_host.h
+++ b/chrome/browser/spellcheck_host.h
@@ -28,6 +28,8 @@ class SpellCheckHost : public base::RefCountedThreadSafe<SpellCheckHost,
const std::string& language,
URLRequestContextGetter* request_context_getter);
+ void Initialize();
+
// Clear |observer_|. Used to prevent calling back to a deleted object.
void UnsetObserver();
@@ -52,7 +54,7 @@ class SpellCheckHost : public base::RefCountedThreadSafe<SpellCheckHost,
// Load and parse the custom words dictionary and open the bdic file.
// Executed on the file thread.
- void Initialize();
+ void InitializeInternal();
// Inform |observer_| that initialization has finished.
void InformObserverOfInitialization();