Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1145)

Unified Diff: content/renderer/hyphenator/hyphenator.h

Issue 10854245: In-te-grate hy-phen-ator to con-tent. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/hyphenator/hyphenator.h
===================================================================
--- content/renderer/hyphenator/hyphenator.h (revision 152650)
+++ content/renderer/hyphenator/hyphenator.h (working copy)
@@ -8,6 +8,7 @@
#include <vector>
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/platform_file.h"
#include "base/string16.h"
#include "content/common/content_export.h"
@@ -19,6 +20,7 @@
typedef struct _HyphenDict HyphenDict;
namespace content {
+class RenderThread;
// A class that hyphenates a word. This class encapsulates the hyphen library
// and manages resources used by the library. When this class uses a huge
@@ -34,11 +36,27 @@
// hyphenation.
bool Initialize();
+ // Attaches this object to a render thread. This function adds a MessageFilter
+ // object to the specified render thread to listen hyphenator messages and
+ // sends a HyphenatorHostMsg_OpenDictionary message.
+ bool Attach(content::RenderThread* thread, const string16& locale);
jam 2012/08/23 21:34:29 ditto
Hironori Bono 2012/08/27 06:57:28 Done. Thanks for noticing this redundant comment.
jam 2012/08/27 16:31:10 I had meant the "content::"
+
+ // Returns whether this object can hyphenate words. When this object does not
+ // have a dictionary file attached, this function sends an IPC request to open
+ // the file.
+ bool CanHyphenate(const string16& locale);
+
// Returns the last hyphenation point, the position where we can insert a
// hyphen, before the given position. If there are not any hyphenation points,
// this function returns 0.
size_t ComputeLastHyphenLocation(const string16& word, size_t before_index);
+ // Sets a hyphenation dictionary to this object. This function is expected to
+ // be called when a MessageFilter object receives HyphenatorMsg_SetDictionary
+ // messages, i.e. when a browser opens the hyphenation dictionary requested by
+ // this object.
+ void SetDictionary(base::PlatformFile rule_file);
+
private:
// The dictionary used by the hyphen library.
HyphenDict* dictionary_;
@@ -46,6 +64,7 @@
// The dictionary file and its memory-mapping object. (Our copy of the hyphen
// library uses a memory-mapped file opened by a browser so renderers can use
// it without opening the file.)
+ string16 locale_;
base::PlatformFile rule_file_;
scoped_ptr<file_util::MemoryMappedFile> rule_map_;
@@ -58,6 +77,8 @@
bool result_;
std::vector<int> hyphen_offsets_;
+ base::WeakPtrFactory<Hyphenator> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(Hyphenator);
};

Powered by Google App Engine
This is Rietveld 408576698