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

Unified Diff: Source/core/platform/text/LineBreakIteratorPoolICU.h

Issue 23618052: TextBreakIterator should use the C++ icu API instead of the C one (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 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: Source/core/platform/text/LineBreakIteratorPoolICU.h
diff --git a/Source/core/platform/text/LineBreakIteratorPoolICU.h b/Source/core/platform/text/LineBreakIteratorPoolICU.h
index b7a0f0b16be19d02828c4b6f336379b7bdd0f3eb..57a139ffdd179d7991c9c1f8b940d1d63a3df47b 100644
--- a/Source/core/platform/text/LineBreakIteratorPoolICU.h
+++ b/Source/core/platform/text/LineBreakIteratorPoolICU.h
@@ -48,9 +48,9 @@ public:
static PassOwnPtr<LineBreakIteratorPool> create() { return adoptPtr(new LineBreakIteratorPool); }
- UBreakIterator* take(const AtomicString& locale)
+ icu::BreakIterator* take(const AtomicString& locale)
{
- UBreakIterator* iterator = 0;
+ icu::BreakIterator* iterator = 0;
for (size_t i = 0; i < m_pool.size(); ++i) {
if (m_pool[i].first == locale) {
iterator = m_pool[i].second;
@@ -62,16 +62,16 @@ public:
if (!iterator) {
UErrorCode openStatus = U_ZERO_ERROR;
bool localeIsEmpty = locale.isEmpty();
- iterator = ubrk_open(UBRK_LINE, localeIsEmpty ? currentTextBreakLocaleID() : locale.string().utf8().data(), 0, 0, &openStatus);
+ iterator = icu::BreakIterator::createLineInstance(localeIsEmpty ? currentTextBreakLocaleID() : locale.string().utf8().data(), openStatus);
// locale comes from a web page and it can be invalid, leading ICU
// to fail, in which case we fall back to the default locale.
if (!localeIsEmpty && U_FAILURE(openStatus)) {
openStatus = U_ZERO_ERROR;
- iterator = ubrk_open(UBRK_LINE, currentTextBreakLocaleID(), 0, 0, &openStatus);
+ iterator = icu::BreakIterator::createLineInstance(currentTextBreakLocaleID(), openStatus);
}
if (U_FAILURE(openStatus)) {
- LOG_ERROR("ubrk_open failed with status %d", openStatus);
+ LOG_ERROR("BreakIterator construction failed with status %d", openStatus);
return 0;
}
}
@@ -81,12 +81,12 @@ public:
return iterator;
}
- void put(UBreakIterator* iterator)
+ void put(icu::BreakIterator* iterator)
{
ASSERT_ARG(iterator, m_vendedIterators.contains(iterator));
if (m_pool.size() == capacity) {
- ubrk_close(m_pool[0].second);
+ delete m_pool[0].second;
m_pool.remove(0);
}
@@ -98,10 +98,10 @@ private:
static const size_t capacity = 4;
- typedef pair<AtomicString, UBreakIterator*> Entry;
+ typedef pair<AtomicString, icu::BreakIterator*> Entry;
typedef Vector<Entry, capacity> Pool;
Pool m_pool;
- HashMap<UBreakIterator*, AtomicString> m_vendedIterators;
+ HashMap<icu::BreakIterator*, AtomicString> m_vendedIterators;
friend WTF::ThreadSpecific<LineBreakIteratorPool>::operator LineBreakIteratorPool*();
};

Powered by Google App Engine
This is Rietveld 408576698