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

Unified Diff: third_party/WebKit/Source/platform/text/LocaleICU.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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: third_party/WebKit/Source/platform/text/LocaleICU.cpp
diff --git a/third_party/WebKit/Source/platform/text/LocaleICU.cpp b/third_party/WebKit/Source/platform/text/LocaleICU.cpp
index 7bed850a96b1f5ff061d7bd82008ce59c250bba2..300416ecf8b39f4a0538e0ff7c65a8cb00047ecd 100644
--- a/third_party/WebKit/Source/platform/text/LocaleICU.cpp
+++ b/third_party/WebKit/Source/platform/text/LocaleICU.cpp
@@ -30,20 +30,21 @@
#include "platform/text/LocaleICU.h"
-#include <unicode/udatpg.h>
-#include <unicode/udisplaycontext.h>
-#include <unicode/uloc.h>
-#include <limits>
#include "wtf/DateMath.h"
-#include "wtf/PassOwnPtr.h"
+#include "wtf/PtrUtil.h"
#include "wtf/text/StringBuffer.h"
#include "wtf/text/StringBuilder.h"
+#include <limits>
+#include <memory>
+#include <unicode/udatpg.h>
+#include <unicode/udisplaycontext.h>
+#include <unicode/uloc.h>
using namespace icu;
namespace blink {
-PassOwnPtr<Locale> Locale::create(const String& locale)
+std::unique_ptr<Locale> Locale::create(const String& locale)
{
return LocaleICU::create(locale.utf8().data());
}
@@ -69,9 +70,9 @@ LocaleICU::~LocaleICU()
udat_close(m_shortTimeFormat);
}
-PassOwnPtr<LocaleICU> LocaleICU::create(const char* localeString)
+std::unique_ptr<LocaleICU> LocaleICU::create(const char* localeString)
{
- return adoptPtr(new LocaleICU(localeString));
+ return wrapUnique(new LocaleICU(localeString));
}
String LocaleICU::decimalSymbol(UNumberFormatSymbol symbol)
@@ -180,14 +181,14 @@ static String getDateFormatPattern(const UDateFormat* dateFormat)
return String::adopt(buffer);
}
-PassOwnPtr<Vector<String>> LocaleICU::createLabelVector(const UDateFormat* dateFormat, UDateFormatSymbolType type, int32_t startIndex, int32_t size)
+std::unique_ptr<Vector<String>> LocaleICU::createLabelVector(const UDateFormat* dateFormat, UDateFormatSymbolType type, int32_t startIndex, int32_t size)
{
if (!dateFormat)
- return PassOwnPtr<Vector<String>>();
+ return std::unique_ptr<Vector<String>>();
if (udat_countSymbols(dateFormat, type) != startIndex + size)
- return PassOwnPtr<Vector<String>>();
+ return std::unique_ptr<Vector<String>>();
- OwnPtr<Vector<String>> labels = adoptPtr(new Vector<String>());
+ std::unique_ptr<Vector<String>> labels = wrapUnique(new Vector<String>());
labels->reserveCapacity(size);
bool isStandAloneMonth = (type == UDAT_STANDALONE_MONTHS) || (type == UDAT_STANDALONE_SHORT_MONTHS);
for (int32_t i = 0; i < size; ++i) {
@@ -201,7 +202,7 @@ PassOwnPtr<Vector<String>> LocaleICU::createLabelVector(const UDateFormat* dateF
length = udat_getSymbols(dateFormat, type, startIndex + i, 0, 0, &status);
}
if (status != U_BUFFER_OVERFLOW_ERROR)
- return PassOwnPtr<Vector<String>>();
+ return std::unique_ptr<Vector<String>>();
StringBuffer<UChar> buffer(length);
status = U_ZERO_ERROR;
if (isStandAloneMonth) {
@@ -210,15 +211,15 @@ PassOwnPtr<Vector<String>> LocaleICU::createLabelVector(const UDateFormat* dateF
udat_getSymbols(dateFormat, type, startIndex + i, buffer.characters(), length, &status);
}
if (U_FAILURE(status))
- return PassOwnPtr<Vector<String>>();
+ return std::unique_ptr<Vector<String>>();
labels->append(String::adopt(buffer));
}
return labels;
}
-static PassOwnPtr<Vector<String>> createFallbackWeekDayShortLabels()
+static std::unique_ptr<Vector<String>> createFallbackWeekDayShortLabels()
{
- OwnPtr<Vector<String>> labels = adoptPtr(new Vector<String>());
+ std::unique_ptr<Vector<String>> labels = wrapUnique(new Vector<String>());
labels->reserveCapacity(7);
labels->append("Sun");
labels->append("Mon");
@@ -247,9 +248,9 @@ void LocaleICU::initializeCalendar()
m_weekDayShortLabels = createFallbackWeekDayShortLabels();
}
-static PassOwnPtr<Vector<String>> createFallbackMonthLabels()
+static std::unique_ptr<Vector<String>> createFallbackMonthLabels()
{
- OwnPtr<Vector<String>> labels = adoptPtr(new Vector<String>());
+ std::unique_ptr<Vector<String>> labels = wrapUnique(new Vector<String>());
labels->reserveCapacity(WTF_ARRAY_LENGTH(WTF::monthFullName));
for (unsigned i = 0; i < WTF_ARRAY_LENGTH(WTF::monthFullName); ++i)
labels->append(WTF::monthFullName[i]);
@@ -287,9 +288,9 @@ bool LocaleICU::isRTL()
return uloc_getCharacterOrientation(m_locale.data(), &status) == ULOC_LAYOUT_RTL;
}
-static PassOwnPtr<Vector<String>> createFallbackAMPMLabels()
+static std::unique_ptr<Vector<String>> createFallbackAMPMLabels()
{
- OwnPtr<Vector<String>> labels = adoptPtr(new Vector<String>());
+ std::unique_ptr<Vector<String>> labels = wrapUnique(new Vector<String>());
labels->reserveCapacity(2);
labels->append("AM");
labels->append("PM");
@@ -318,7 +319,7 @@ void LocaleICU::initializeDateTimeFormat()
m_dateTimeFormatWithoutSeconds = getDateFormatPattern(dateTimeFormatWithoutSeconds);
udat_close(dateTimeFormatWithoutSeconds);
- OwnPtr<Vector<String>> timeAMPMLabels = createLabelVector(m_mediumTimeFormat, UDAT_AM_PMS, UCAL_AM, 2);
+ std::unique_ptr<Vector<String>> timeAMPMLabels = createLabelVector(m_mediumTimeFormat, UDAT_AM_PMS, UCAL_AM, 2);
if (!timeAMPMLabels)
timeAMPMLabels = createFallbackAMPMLabels();
m_timeAMPMLabels = *timeAMPMLabels;
@@ -405,7 +406,7 @@ const Vector<String>& LocaleICU::shortMonthLabels()
if (!m_shortMonthLabels.isEmpty())
return m_shortMonthLabels;
if (initializeShortDateFormat()) {
- if (OwnPtr<Vector<String>> labels = createLabelVector(m_shortDateFormat, UDAT_SHORT_MONTHS, UCAL_JANUARY, 12)) {
+ if (std::unique_ptr<Vector<String>> labels = createLabelVector(m_shortDateFormat, UDAT_SHORT_MONTHS, UCAL_JANUARY, 12)) {
m_shortMonthLabels = *labels;
return m_shortMonthLabels;
}
@@ -422,7 +423,7 @@ const Vector<String>& LocaleICU::standAloneMonthLabels()
return m_standAloneMonthLabels;
UDateFormat* monthFormatter = openDateFormatForStandAloneMonthLabels(false);
if (monthFormatter) {
- if (OwnPtr<Vector<String>> labels = createLabelVector(monthFormatter, UDAT_STANDALONE_MONTHS, UCAL_JANUARY, 12)) {
+ if (std::unique_ptr<Vector<String>> labels = createLabelVector(monthFormatter, UDAT_STANDALONE_MONTHS, UCAL_JANUARY, 12)) {
m_standAloneMonthLabels = *labels;
udat_close(monthFormatter);
return m_standAloneMonthLabels;
@@ -439,7 +440,7 @@ const Vector<String>& LocaleICU::shortStandAloneMonthLabels()
return m_shortStandAloneMonthLabels;
UDateFormat* monthFormatter = openDateFormatForStandAloneMonthLabels(true);
if (monthFormatter) {
- if (OwnPtr<Vector<String>> labels = createLabelVector(monthFormatter, UDAT_STANDALONE_SHORT_MONTHS, UCAL_JANUARY, 12)) {
+ if (std::unique_ptr<Vector<String>> labels = createLabelVector(monthFormatter, UDAT_STANDALONE_SHORT_MONTHS, UCAL_JANUARY, 12)) {
m_shortStandAloneMonthLabels = *labels;
udat_close(monthFormatter);
return m_shortStandAloneMonthLabels;
« no previous file with comments | « third_party/WebKit/Source/platform/text/LocaleICU.h ('k') | third_party/WebKit/Source/platform/text/LocaleICUTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698