Changeset 184567 in webkit


Ignore:
Timestamp:
May 19, 2015 9:37:11 AM (9 years ago)
Author:
commit-queue@webkit.org
Message:

[SOUP] Use st_birthtime to get creation time of files on systems support it
https://bugs.webkit.org/show_bug.cgi?id=144989

Patch by Ting-Wei Lan <Ting-Wei Lan> on 2015-05-19
Reviewed by Carlos Garcia Campos.

Source/WebKit2:

FreeBSD and NetBSD have either st_birthtime field or compatiblity macro
with the same name in stat. It is better to use it instead of manually
setting xattr, which is unreliable because both operating systems and
file systems support are required.

  • NetworkProcess/cache/NetworkCacheFileSystemPosix.h:

(WebKit::NetworkCache::fileTimes):

  • NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp:

(WebKit::NetworkCache::IOChannel::IOChannel):

Source/WTF:

Define HAVE(STAT_BIRTHTIME) as 1 on operating systems supporting
getting creation time of files using st_birthtime in stat.

  • wtf/Platform.h:
Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r184555 r184567  
     12015-05-19  Ting-Wei Lan  <lantw44@gmail.com>
     2
     3        [SOUP] Use st_birthtime to get creation time of files on systems support it
     4        https://bugs.webkit.org/show_bug.cgi?id=144989
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Define HAVE(STAT_BIRTHTIME) as 1 on operating systems supporting
     9        getting creation time of files using st_birthtime in stat.
     10
     11        * wtf/Platform.h:
     12
    1132015-05-19  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/Source/WTF/wtf/Platform.h

    r183936 r184567  
    606606#endif
    607607
     608#if OS(DARWIN) || OS(FREEBSD) || OS(NETBSD)
     609#define HAVE_STAT_BIRTHTIME 1
     610#endif
     611
    608612#if !OS(WINDOWS) && !OS(SOLARIS)
    609613#define HAVE_TM_GMTOFF 1
  • trunk/Source/WebKit2/ChangeLog

    r184555 r184567  
     12015-05-19  Ting-Wei Lan  <lantw44@gmail.com>
     2
     3        [SOUP] Use st_birthtime to get creation time of files on systems support it
     4        https://bugs.webkit.org/show_bug.cgi?id=144989
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        FreeBSD and NetBSD have either st_birthtime field or compatiblity macro
     9        with the same name in stat. It is better to use it instead of manually
     10        setting xattr, which is unreliable because both operating systems and
     11        file systems support are required.
     12
     13        * NetworkProcess/cache/NetworkCacheFileSystemPosix.h:
     14        (WebKit::NetworkCache::fileTimes):
     15        * NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp:
     16        (WebKit::NetworkCache::IOChannel::IOChannel):
     17
    1182015-05-19  Chris Dumez  <cdumez@apple.com>
    219
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheFileSystemPosix.h

    r184330 r184567  
    7878inline FileTimes fileTimes(const String& path)
    7979{
    80 #if PLATFORM(COCOA)
     80#if HAVE(STAT_BIRTHTIME)
    8181    struct stat fileInfo;
    8282    if (stat(WebCore::fileSystemRepresentation(path).data(), &fileInfo))
    8383        return { };
    8484    return { std::chrono::system_clock::from_time_t(fileInfo.st_birthtime), std::chrono::system_clock::from_time_t(fileInfo.st_mtime) };
    85 #endif
    86 #if USE(SOUP)
     85#elif USE(SOUP)
    8786    // There's no st_birthtime in some operating systems like Linux, so we use xattrs to set/get the creation time.
    8887    GRefPtr<GFile> file = adoptGRef(g_file_new_for_path(WebCore::fileSystemRepresentation(path).data()));
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp

    r183801 r184567  
    5050        m_outputStream = adoptGRef(G_OUTPUT_STREAM(g_file_create(file.get(), static_cast<GFileCreateFlags>(G_FILE_CREATE_PRIVATE), nullptr, nullptr)));
    5151        ASSERT(m_outputStream);
     52#if !HAVE(STAT_BIRTHTIME)
    5253        GUniquePtr<char> birthtimeString(g_strdup_printf("%" G_GUINT64_FORMAT, std::chrono::system_clock::to_time_t(std::chrono::system_clock::now())));
    5354        g_file_set_attribute_string(file.get(), "xattr::birthtime", birthtimeString.get(), G_FILE_QUERY_INFO_NONE, nullptr, nullptr);
     55#endif
    5456        break;
    5557    }
Note: See TracChangeset for help on using the changeset viewer.