summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/render_thread.cc6
-rw-r--r--chrome/renderer/render_thread.h3
-rw-r--r--chrome/renderer/render_view.cc20
-rw-r--r--chrome/renderer/spellchecker/spellcheck.cc14
-rw-r--r--chrome/renderer/spellchecker/spellcheck.h10
5 files changed, 22 insertions, 31 deletions
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index 7779a01..fc76f86 100644
--- a/chrome/renderer/render_thread.cc
+++ b/chrome/renderer/render_thread.cc
@@ -58,7 +58,6 @@
#endif
#include "chrome/renderer/user_script_slave.h"
#include "ipc/ipc_message.h"
-#include "ipc/ipc_platform_file.h"
#include "third_party/tcmalloc/tcmalloc/src/google/malloc_extension.h"
#include "third_party/WebKit/WebKit/chromium/public/WebCache.h"
#include "third_party/WebKit/WebKit/chromium/public/WebColor.h"
@@ -661,12 +660,11 @@ void RenderThread::OnPurgePluginListCache(bool reload_pages) {
#if defined(SPELLCHECKER_IN_RENDERER)
void RenderThread::OnInitSpellChecker(
- IPC::PlatformFileForTransit bdict_file,
+ const base::FileDescriptor& bdict_fd,
const std::vector<std::string>& custom_words,
const std::string& language,
bool auto_spell_correct) {
- spellchecker_->Init(IPC::PlatformFileForTransitToPlatformFile(bdict_file),
- custom_words, language);
+ spellchecker_->Init(bdict_fd, custom_words, language);
spellchecker_->EnableAutoSpellCorrect(auto_spell_correct);
}
diff --git a/chrome/renderer/render_thread.h b/chrome/renderer/render_thread.h
index 44dc6ab..aadeafc 100644
--- a/chrome/renderer/render_thread.h
+++ b/chrome/renderer/render_thread.h
@@ -18,7 +18,6 @@
#include "chrome/common/dom_storage_type.h"
#include "chrome/renderer/renderer_histogram_snapshots.h"
#include "chrome/renderer/visitedlink_slave.h"
-#include "ipc/ipc_platform_file.h"
class AppCacheDispatcher;
class DBMessageFilter;
@@ -201,7 +200,7 @@ class RenderThread : public RenderThreadBase,
void OnPurgePluginListCache(bool reload_pages);
#if defined(SPELLCHECKER_IN_RENDERER)
- void OnInitSpellChecker(IPC::PlatformFileForTransit bdict_file,
+ void OnInitSpellChecker(const base::FileDescriptor& bdict_fd,
const std::vector<std::string>& custom_words,
const std::string& language,
bool auto_spell_correct);
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 7541ceb..aa8d86d 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -1505,13 +1505,9 @@ void RenderView::spellCheck(const WebString& text,
#if defined(SPELLCHECKER_IN_RENDERER)
string16 word(text);
- RenderThread* thread = RenderThread::current();
- // Will be NULL during unit tests.
- if (thread) {
- RenderThread::current()->spellchecker()->SpellCheckWord(
- word.c_str(), word.size(), document_tag_,
- &misspelled_offset, &misspelled_length, NULL);
- }
+ RenderThread::current()->spellchecker()->SpellCheckWord(
+ word.c_str(), word.size(), document_tag_,
+ &misspelled_offset, &misspelled_length, NULL);
#else
Send(new ViewHostMsg_SpellCheck(routing_id_, text, document_tag_,
&misspelled_offset, &misspelled_length));
@@ -1524,13 +1520,9 @@ WebString RenderView::autoCorrectWord(const WebKit::WebString& word) {
if (command_line.HasSwitch(switches::kExperimentalSpellcheckerFeatures)) {
EnsureDocumentTag();
#if defined(SPELLCHECKER_IN_RENDERER)
- RenderThread* thread = RenderThread::current();
- // Will be NULL during unit tests.
- if (thread) {
- autocorrect_word =
- RenderThread::current()->spellchecker()->GetAutoCorrectionWord(
- word, document_tag_);
- }
+ autocorrect_word =
+ RenderThread::current()->spellchecker()->GetAutoCorrectionWord(
+ word, document_tag_);
#else
Send(new ViewHostMsg_GetAutoCorrectWord(
routing_id_, word, document_tag_, &autocorrect_word));
diff --git a/chrome/renderer/spellchecker/spellcheck.cc b/chrome/renderer/spellchecker/spellcheck.cc
index 3b02b54..a565b08 100644
--- a/chrome/renderer/spellchecker/spellcheck.cc
+++ b/chrome/renderer/spellchecker/spellcheck.cc
@@ -16,8 +16,7 @@ static const int kMaxSuggestions = 5;
using base::TimeTicks;
SpellCheck::SpellCheck()
- : file_(base::kInvalidPlatformFileValue),
- auto_spell_correct_turned_on_(false),
+ : auto_spell_correct_turned_on_(false),
// TODO(estade): initialize this properly.
is_using_platform_spelling_engine_(false),
initialized_(false) {
@@ -27,13 +26,13 @@ SpellCheck::SpellCheck()
SpellCheck::~SpellCheck() {
}
-void SpellCheck::Init(base::PlatformFile file,
+void SpellCheck::Init(const base::FileDescriptor& fd,
const std::vector<std::string>& custom_words,
const std::string language) {
initialized_ = true;
hunspell_.reset();
bdict_file_.reset();
- file_ = file;
+ fd_ = fd;
character_attributes_.SetDefaultLanguage(language);
custom_words_.insert(custom_words_.end(),
@@ -58,7 +57,7 @@ bool SpellCheck::SpellCheckWord(
return true;
// Do nothing if spell checking is disabled.
- if (initialized_ && file_ == base::kInvalidPlatformFileValue)
+ if (initialized_ && fd_.fd == -1)
return true;
*misspelling_start = 0;
@@ -165,7 +164,7 @@ void SpellCheck::InitializeHunspell() {
bdict_file_.reset(new file_util::MemoryMappedFile);
- if (bdict_file_->Initialize(file_)) {
+ if (bdict_file_->Initialize(fd_)) {
TimeTicks start_time = TimeTicks::Now();
hunspell_.reset(
@@ -195,8 +194,7 @@ bool SpellCheck::InitializeIfNeeded() {
}
// Check if the platform spellchecker is being used.
- if (!is_using_platform_spelling_engine_ &&
- file_ != base::kInvalidPlatformFileValue) {
+ if (!is_using_platform_spelling_engine_ && fd_.fd != -1) {
// If it isn't, init hunspell.
InitializeHunspell();
}
diff --git a/chrome/renderer/spellchecker/spellcheck.h b/chrome/renderer/spellchecker/spellcheck.h
index ef194bd..b482770 100644
--- a/chrome/renderer/spellchecker/spellcheck.h
+++ b/chrome/renderer/spellchecker/spellcheck.h
@@ -10,7 +10,7 @@
#include <vector>
#include "app/l10n_util.h"
-#include "base/platform_file.h"
+#include "base/file_descriptor_posix.h"
#include "base/string16.h"
#include "base/time.h"
#include "chrome/renderer/spellchecker/spellcheck_worditerator.h"
@@ -18,6 +18,10 @@
class Hunspell;
+namespace base {
+class FileDescriptor;
+}
+
namespace file_util {
class MemoryMappedFile;
}
@@ -28,7 +32,7 @@ class SpellCheck {
~SpellCheck();
- void Init(base::PlatformFile file,
+ void Init(const base::FileDescriptor& bdict_fd,
const std::vector<std::string>& custom_words,
const std::string language);
@@ -97,7 +101,7 @@ class SpellCheck {
// The hunspell dictionary in use.
scoped_ptr<Hunspell> hunspell_;
- base::PlatformFile file_;
+ base::FileDescriptor fd_;
std::vector<std::string> custom_words_;
// Represents character attributes used for filtering out characters which