summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/render_thread.h
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-06 03:05:46 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-06 03:05:46 +0000
commit85c55dcd717445cd3763b5c94f9902b4cdd194b0 (patch)
tree2deea721cfac202e3eb8556f66a4cf317a331288 /chrome/renderer/render_thread.h
parentf1a8b962f0a6f1deb6c8c05a3f86d541e2ba61dd (diff)
downloadchromium_src-85c55dcd717445cd3763b5c94f9902b4cdd194b0.zip
chromium_src-85c55dcd717445cd3763b5c94f9902b4cdd194b0.tar.gz
chromium_src-85c55dcd717445cd3763b5c94f9902b4cdd194b0.tar.bz2
Move the spellchecker to the renderer.
The motivation is that this removes the sync IPC on every call to the spellchecker. Also, currently we spellcheck in the IO thread, which frequently needs to go to disk (in particular, the entire spellcheck dictionary starts paged out), so this will block just the single renderer when that happens, rather than the whole IO thread. This breaks the SpellChecker class into two new classes. 1) On the browser side, we have SpellCheckHost. This class handles browser-wide tasks, such as keeping the custom words list in sync with the on-disk custom words dictionary, downloading missing dictionaries, etc. On Posix, it also opens the bdic file since the renderer isn't allowed to open files. SpellCheckHost is created and destroyed on the UI thread. It is initialized on the file thread. 2) On the renderer side, SpellChecker2. This class will one day be renamed SpellChecker. It handles actual checking of the words, memory maps the dictionary file, loads hunspell, etc. There is one SpellChecker2 per RenderThread (hence one per render process). My intention is for this patch to move Linux to this new approach, and follow up with ports for Windows (which will involve passing a dictionary file name rather than a file descriptor through to the renderer) and Mac (which will involve adding sync ViewHost IPC callsfor when the platform spellchecker is enabled). Note that anyone using the platform spellchecker rather than Hunspell will get no benefit out of this refactor. There should be no loss of functionality for Linux (or any other platform) in this patch. The following should all still work: - dictionary is loaded lazily - hunspell is initialized lazily, per renderer - language changes work. - Dynamic downloading of new dictionaries - auto spell correct works (as well as toggling it). - disabling spellcheck works. - custom words work (including adding in one renderer and immediately having it take effect in other renderers, for certain values of "immediate") TODO: - move spellchecker unit tests to test SpellCheck2 - add sync IPC for platform spellchecker; port to Mac - add dictionary location fallback; port to Windows - remove SpellChecker classes from browser/ BUG=25677 Review URL: http://codereview.chromium.org/357003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31199 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/render_thread.h')
-rw-r--r--chrome/renderer/render_thread.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h
index 249c57a..dece3ee 100644
--- a/chrome/renderer/render_thread.h
+++ b/chrome/renderer/render_thread.h
@@ -10,6 +10,7 @@
#include "app/gfx/native_widget_types.h"
#include "base/shared_memory.h"
+#include "base/string16.h"
#include "base/task.h"
#include "build/build_config.h"
#include "chrome/common/child_thread.h"
@@ -28,6 +29,7 @@ class RenderDnsMaster;
class RendererHistogram;
class RendererWebDatabaseObserver;
class RendererWebKitClientImpl;
+class SpellCheck;
class SkBitmap;
class SocketStreamDispatcher;
class UserScriptSlave;
@@ -121,6 +123,12 @@ class RenderThread : public RenderThreadBase,
return socket_stream_dispatcher_.get();
}
+#if defined(SPELLCHECKER_IN_RENDERER)
+ SpellCheck* spellchecker() const {
+ return spellchecker_.get();
+ }
+#endif
+
bool plugin_refresh_allowed() const { return plugin_refresh_allowed_; }
// Do DNS prefetch resolution of a hostname.
@@ -139,6 +147,11 @@ class RenderThread : public RenderThreadBase,
// Sends a message to the browser to enable or disable the disk cache.
void SetCacheMode(bool enabled);
+#if defined(SPELLCHECKER_IN_RENDERER)
+ // Send a message to the browser to request a spellcheck dictionary.
+ void RequestSpellCheckDictionary();
+#endif
+
private:
virtual void OnControlMessageReceived(const IPC::Message& msg);
@@ -185,6 +198,15 @@ class RenderThread : public RenderThreadBase,
void OnPurgeMemory();
void OnPurgePluginListCache(bool reload_pages);
+#if defined(SPELLCHECKER_IN_RENDERER)
+ void OnInitSpellChecker(const base::FileDescriptor& bdict_fd,
+ const std::vector<std::string>& custom_words,
+ const std::string& language,
+ bool auto_spell_correct);
+ void OnSpellCheckWordAdded(const std::string& word);
+ void OnSpellCheckEnableAutoSpellCorrect(bool enable);
+#endif
+
// Gather usage statistics from the in-memory cache and inform our host.
// These functions should be call periodically so that the host can make
// decisions about how to allocation resources using current information.
@@ -208,6 +230,9 @@ class RenderThread : public RenderThreadBase,
scoped_ptr<WebKit::WebStorageEventDispatcher> dom_storage_event_dispatcher_;
scoped_ptr<SocketStreamDispatcher> socket_stream_dispatcher_;
scoped_ptr<RendererWebDatabaseObserver> renderer_web_database_observer_;
+#if defined(SPELLCHECKER_IN_RENDERER)
+ scoped_ptr<SpellCheck> spellchecker_;
+#endif
// Used on the renderer and IPC threads.
scoped_refptr<DBMessageFilter> db_message_filter_;