Title: [184567] trunk/Source
- Revision
- 184567
- Author
- [email protected]
- Date
- 2015-05-19 09:37:11 -0700 (Tue, 19 May 2015)
Log 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 <[email protected]> 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:
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (184566 => 184567)
--- trunk/Source/WTF/ChangeLog 2015-05-19 16:29:37 UTC (rev 184566)
+++ trunk/Source/WTF/ChangeLog 2015-05-19 16:37:11 UTC (rev 184567)
@@ -1,3 +1,15 @@
+2015-05-19 Ting-Wei Lan <[email protected]>
+
+ [SOUP] Use st_birthtime to get creation time of files on systems support it
+ https://bugs.webkit.org/show_bug.cgi?id=144989
+
+ Reviewed by Carlos Garcia Campos.
+
+ Define HAVE(STAT_BIRTHTIME) as 1 on operating systems supporting
+ getting creation time of files using st_birthtime in stat.
+
+ * wtf/Platform.h:
+
2015-05-19 Chris Dumez <[email protected]>
Mark static variables as const when possible
Modified: trunk/Source/WTF/wtf/Platform.h (184566 => 184567)
--- trunk/Source/WTF/wtf/Platform.h 2015-05-19 16:29:37 UTC (rev 184566)
+++ trunk/Source/WTF/wtf/Platform.h 2015-05-19 16:37:11 UTC (rev 184567)
@@ -605,6 +605,10 @@
#endif
#endif
+#if OS(DARWIN) || OS(FREEBSD) || OS(NETBSD)
+#define HAVE_STAT_BIRTHTIME 1
+#endif
+
#if !OS(WINDOWS) && !OS(SOLARIS)
#define HAVE_TM_GMTOFF 1
#define HAVE_TM_ZONE 1
Modified: trunk/Source/WebKit2/ChangeLog (184566 => 184567)
--- trunk/Source/WebKit2/ChangeLog 2015-05-19 16:29:37 UTC (rev 184566)
+++ trunk/Source/WebKit2/ChangeLog 2015-05-19 16:37:11 UTC (rev 184567)
@@ -1,3 +1,20 @@
+2015-05-19 Ting-Wei Lan <[email protected]>
+
+ [SOUP] Use st_birthtime to get creation time of files on systems support it
+ https://bugs.webkit.org/show_bug.cgi?id=144989
+
+ Reviewed by Carlos Garcia Campos.
+
+ 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):
+
2015-05-19 Chris Dumez <[email protected]>
Mark static variables as const when possible
Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheFileSystemPosix.h (184566 => 184567)
--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheFileSystemPosix.h 2015-05-19 16:29:37 UTC (rev 184566)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheFileSystemPosix.h 2015-05-19 16:37:11 UTC (rev 184567)
@@ -77,13 +77,12 @@
inline FileTimes fileTimes(const String& path)
{
-#if PLATFORM(COCOA)
+#if HAVE(STAT_BIRTHTIME)
struct stat fileInfo;
if (stat(WebCore::fileSystemRepresentation(path).data(), &fileInfo))
return { };
return { std::chrono::system_clock::from_time_t(fileInfo.st_birthtime), std::chrono::system_clock::from_time_t(fileInfo.st_mtime) };
-#endif
-#if USE(SOUP)
+#elif USE(SOUP)
// There's no st_birthtime in some operating systems like Linux, so we use xattrs to set/get the creation time.
GRefPtr<GFile> file = adoptGRef(g_file_new_for_path(WebCore::fileSystemRepresentation(path).data()));
GRefPtr<GFileInfo> fileInfo = adoptGRef(g_file_query_info(file.get(), "xattr::birthtime,time::modified", G_FILE_QUERY_INFO_NONE, nullptr, nullptr));
Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp (184566 => 184567)
--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp 2015-05-19 16:29:37 UTC (rev 184566)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp 2015-05-19 16:37:11 UTC (rev 184567)
@@ -49,8 +49,10 @@
g_file_delete(file.get(), nullptr, nullptr);
m_outputStream = adoptGRef(G_OUTPUT_STREAM(g_file_create(file.get(), static_cast<GFileCreateFlags>(G_FILE_CREATE_PRIVATE), nullptr, nullptr)));
ASSERT(m_outputStream);
+#if !HAVE(STAT_BIRTHTIME)
GUniquePtr<char> birthtimeString(g_strdup_printf("%" G_GUINT64_FORMAT, std::chrono::system_clock::to_time_t(std::chrono::system_clock::now())));
g_file_set_attribute_string(file.get(), "xattr::birthtime", birthtimeString.get(), G_FILE_QUERY_INFO_NONE, nullptr, nullptr);
+#endif
break;
}
case Type::Write: {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes