Title: [158245] trunk/Source
Revision
158245
Author
[email protected]
Date
2013-10-29 20:05:20 -0700 (Tue, 29 Oct 2013)

Log Message

StringImpl::isolatedCopy() should return PassRef.
<https://webkit.org/b/123484>

Make isolatedCopy() return a PassRef<StringImpl>.

Reviewed by Anders Carlsson.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (158244 => 158245)


--- trunk/Source/WTF/ChangeLog	2013-10-30 02:40:06 UTC (rev 158244)
+++ trunk/Source/WTF/ChangeLog	2013-10-30 03:05:20 UTC (rev 158245)
@@ -1,3 +1,12 @@
+2013-10-29  Andreas Kling  <[email protected]>
+
+        StringImpl::isolatedCopy() should return PassRef.
+        <https://webkit.org/b/123484>
+
+        Make isolatedCopy() return a PassRef<StringImpl>.
+
+        Reviewed by Anders Carlsson.
+
 2013-10-29  Jer Noble  <[email protected]>
 
         [MSE] [Mac] Enable MediaSource on the Mac

Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (158244 => 158245)


--- trunk/Source/WTF/wtf/text/StringImpl.cpp	2013-10-30 02:40:06 UTC (rev 158244)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp	2013-10-30 03:05:20 UTC (rev 158245)
@@ -161,20 +161,20 @@
     return createFromLiteral(characters, strlen(characters));
 }
 
-PassRefPtr<StringImpl> StringImpl::createWithoutCopying(const UChar* characters, unsigned length)
+PassRef<StringImpl> StringImpl::createWithoutCopying(const UChar* characters, unsigned length)
 {
     if (!length)
-        return empty();
+        return *empty();
 
-    return adoptRef(new StringImpl(characters, length, ConstructWithoutCopying));
+    return adoptRef(*new StringImpl(characters, length, ConstructWithoutCopying));
 }
 
-PassRefPtr<StringImpl> StringImpl::createWithoutCopying(const LChar* characters, unsigned length)
+PassRef<StringImpl> StringImpl::createWithoutCopying(const LChar* characters, unsigned length)
 {
     if (!length)
-        return empty();
+        return *empty();
 
-    return adoptRef(new StringImpl(characters, length, ConstructWithoutCopying));
+    return adoptRef(*new StringImpl(characters, length, ConstructWithoutCopying));
 }
 
 template <typename CharType>

Modified: trunk/Source/WTF/wtf/text/StringImpl.h (158244 => 158245)


--- trunk/Source/WTF/wtf/text/StringImpl.h	2013-10-30 02:40:06 UTC (rev 158244)
+++ trunk/Source/WTF/wtf/text/StringImpl.h	2013-10-30 03:05:20 UTC (rev 158245)
@@ -392,8 +392,8 @@
     WTF_EXPORT_STRING_API static PassRefPtr<StringImpl> createFromLiteral(const char* characters, unsigned length);
     WTF_EXPORT_STRING_API static PassRefPtr<StringImpl> createFromLiteral(const char* characters);
 
-    WTF_EXPORT_STRING_API static PassRefPtr<StringImpl> createWithoutCopying(const UChar* characters, unsigned length);
-    WTF_EXPORT_STRING_API static PassRefPtr<StringImpl> createWithoutCopying(const LChar* characters, unsigned length);
+    WTF_EXPORT_STRING_API static PassRef<StringImpl> createWithoutCopying(const UChar* characters, unsigned length);
+    WTF_EXPORT_STRING_API static PassRef<StringImpl> createWithoutCopying(const LChar* characters, unsigned length);
 
     WTF_EXPORT_STRING_API static PassRefPtr<StringImpl> createUninitialized(unsigned length, LChar*& data);
     WTF_EXPORT_STRING_API static PassRefPtr<StringImpl> createUninitialized(unsigned length, UChar*& data);
@@ -654,7 +654,7 @@
     // Some string features, like refcounting and the atomicity flag, are not
     // thread-safe. We achieve thread safety by isolation, giving each thread
     // its own copy of the string.
-    PassRefPtr<StringImpl> isolatedCopy() const;
+    PassRef<StringImpl> isolatedCopy() const;
 
     WTF_EXPORT_STRING_API PassRefPtr<StringImpl> substring(unsigned pos, unsigned len = UINT_MAX);
 
@@ -1332,7 +1332,7 @@
     return static_cast<unsigned>(length);
 }
 
-inline PassRefPtr<StringImpl> StringImpl::isolatedCopy() const
+inline PassRef<StringImpl> StringImpl::isolatedCopy() const
 {
     if (!requiresCopy()) {
         if (is8Bit())

Modified: trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabaseTracker.cpp (158244 => 158245)


--- trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabaseTracker.cpp	2013-10-30 02:40:06 UTC (rev 158244)
+++ trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabaseTracker.cpp	2013-10-30 03:05:20 UTC (rev 158245)
@@ -53,7 +53,9 @@
 void LocalStorageDatabaseTracker::setLocalStorageDirectory(const String& localStorageDirectory)
 {
     // FIXME: We should come up with a better idiom for safely copying strings across threads.
-    RefPtr<StringImpl> copiedLocalStorageDirectory = localStorageDirectory.impl() ? localStorageDirectory.impl()->isolatedCopy() : nullptr;
+    RefPtr<StringImpl> copiedLocalStorageDirectory;
+    if (localStorageDirectory.impl())
+        copiedLocalStorageDirectory = localStorageDirectory.impl()->isolatedCopy();
 
     m_queue->dispatch(bind(&LocalStorageDatabaseTracker::setLocalStorageDirectoryInternal, this, copiedLocalStorageDirectory.release()));
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to