Commit c58ff503 authored by darin@apple.com's avatar darin@apple.com
Browse files

2011-01-25 Darin Adler <darin@apple.com>

        Reviewed by Anders Carlsson.

        WebKit is using CSBackupSetItemExcluded incorrectly
        https://bugs.webkit.org/show_bug.cgi?id=53095
        rdar://problem/8790540

        * Misc/WebIconDatabase.mm:
        (importToWebCoreFormat): Removed code that was calling CSBackupSetItemExcluded.
        It was incorrect, and this responsibility has been moved to WebCore.
2011-01-25  Darin Adler  <darin@apple.com>

        Reviewed by Anders Carlsson.

        WebKit is using CSBackupSetItemExcluded incorrectly
        https://bugs.webkit.org/show_bug.cgi?id=53095
        rdar://problem/8790540

        * loader/icon/IconDatabase.cpp:
        (WebCore::IconDatabase::performOpenInitialization): Added code to
        exclude the database from backup one time, and record inside the
        database that this has been done.
        (WebCore::IconDatabase::wasExcludedFromBackup): Added.
        (WebCore::IconDatabase::setWasExcludedFromBackup): Added.
        * loader/icon/IconDatabase.h: Added new functions above.

        * platform/FileSystem.cpp:
        (WebCore::canExcludeFromBackup): Added.
        (WebCore::excludeFromBackup): Added.

        * platform/FileSystem.h: Added canExcludeFromBackup, excludeFromBackup,
        and pathAsURL functions. Cleaned up ifdefs and comments a bit and sorted
        things alphabetically, particularly platform-specific sections.

        * platform/cf/FileSystemCF.cpp:
        (WebCore::pathAsURL): Added.

        * platform/mac/FileSystemMac.mm:
        (WebCore::canExcludeFromBackup): Added.
        (WebCore::excludeFromBackup): Added.

        * platform/network/cf/FormDataStreamCFNet.cpp:
        (WebCore::advanceCurrentStream): Changed to call pathAsURL.
        * platform/network/mac/FormDataStreamMac.mm:
        (WebCore::advanceCurrentStream): Ditto.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76614 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1c65d548
2011-01-25 Darin Adler <darin@apple.com>
Reviewed by Anders Carlsson.
WebKit is using CSBackupSetItemExcluded incorrectly
https://bugs.webkit.org/show_bug.cgi?id=53095
rdar://problem/8790540
* loader/icon/IconDatabase.cpp:
(WebCore::IconDatabase::performOpenInitialization): Added code to
exclude the database from backup one time, and record inside the
database that this has been done.
(WebCore::IconDatabase::wasExcludedFromBackup): Added.
(WebCore::IconDatabase::setWasExcludedFromBackup): Added.
* loader/icon/IconDatabase.h: Added new functions above.
* platform/FileSystem.cpp:
(WebCore::canExcludeFromBackup): Added.
(WebCore::excludeFromBackup): Added.
* platform/FileSystem.h: Added canExcludeFromBackup, excludeFromBackup,
and pathAsURL functions. Cleaned up ifdefs and comments a bit and sorted
things alphabetically, particularly platform-specific sections.
* platform/cf/FileSystemCF.cpp:
(WebCore::pathAsURL): Added.
* platform/mac/FileSystemMac.mm:
(WebCore::canExcludeFromBackup): Added.
(WebCore::excludeFromBackup): Added.
* platform/network/cf/FormDataStreamCFNet.cpp:
(WebCore::advanceCurrentStream): Changed to call pathAsURL.
* platform/network/mac/FormDataStreamMac.mm:
(WebCore::advanceCurrentStream): Ditto.
2011-01-25 Helder Correia <helder@sencha.com>
 
Reviewed by Dirk Schulze.
/*
* Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserved.
* Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com)
*
* Redistribution and use in source and binary forms, with or without
......@@ -1051,7 +1051,6 @@ static int databaseVersionNumber(SQLiteDatabase& db)
static bool isValidDatabase(SQLiteDatabase& db)
{
// These four tables should always exist in a valid db
if (!db.tableExists("IconInfo") || !db.tableExists("IconData") || !db.tableExists("PageURL") || !db.tableExists("IconDatabaseInfo"))
return false;
......@@ -1155,6 +1154,13 @@ void IconDatabase::performOpenInitialization()
// Reduce sqlite RAM cache size from default 2000 pages (~1.5kB per page). 3MB of cache for icon database is overkill
if (!SQLiteStatement(m_syncDB, "PRAGMA cache_size = 200;").executeCommand())
LOG_ERROR("SQLite database could not set cache_size");
// Tell backup software (i.e., Time Machine) to never back up the icon database, because
// it's a large file that changes frequently, thus using a lot of backup disk space, and
// it's unlikely that many users would be upset about it not being backed up. We could
// make this configurable on a per-client basis some day if some clients don't want this.
if (canExcludeFromBackup() && !wasExcludedFromBackup() && excludeFromBackup(m_completeDatabasePath))
setWasExcludedFromBackup();
}
bool IconDatabase::checkIntegrity()
......@@ -2086,6 +2092,20 @@ void IconDatabase::writeIconSnapshotToSQLDatabase(const IconSnapshot& snapshot)
}
}
bool IconDatabase::wasExcludedFromBackup()
{
ASSERT_ICON_SYNC_THREAD();
return SQLiteStatement(m_syncDB, "SELECT value FROM IconDatabaseInfo WHERE key = 'ExcludedFromBackup';").getColumnInt(0);
}
void IconDatabase::setWasExcludedFromBackup()
{
ASSERT_ICON_SYNC_THREAD();
SQLiteStatement(m_syncDB, "INSERT INTO IconDatabaseInfo (key, value) VALUES ('ExcludedFromBackup', 1)").executeCommand();
}
} // namespace WebCore
#endif // ENABLE(ICONDATABASE)
......@@ -199,6 +199,9 @@ private:
bool imported();
void setImported(bool);
bool wasExcludedFromBackup();
void setWasExcludedFromBackup();
bool m_initialPruningComplete;
void setIconURLForPageURLInSQLDatabase(const String&, const String&);
......
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
* Copyright (C) 2007, 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -101,4 +101,18 @@ String encodeForFileName(const String& inputStr)
return String(buffer.data(), p - buffer.data());
}
#if !PLATFORM(MAC)
bool canExcludeFromBackup()
{
return false;
}
bool excludeFromBackup(const String&)
{
return false;
}
#endif
} // namespace WebCore
/*
* Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved.
* Copyright (C) 2008 Collabora, Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......@@ -30,6 +30,15 @@
#ifndef FileSystem_h
#define FileSystem_h
#include "PlatformString.h"
#include <time.h>
#include <wtf/Forward.h>
#include <wtf/Vector.h>
#if PLATFORM(CF)
#include <wtf/RetainPtr.h>
#endif
#if PLATFORM(QT)
#include <QFile>
#include <QLibrary>
......@@ -39,15 +48,9 @@
#endif
#if PLATFORM(CF) || (PLATFORM(QT) && defined(Q_WS_MAC))
#include <CoreFoundation/CFBundle.h>
#endif
#include "PlatformString.h"
#include <time.h>
#include <wtf/Forward.h>
#include <wtf/Vector.h>
typedef struct __CFBundle* CFBundleRef;
typedef const struct __CFData* CFDataRef;
#endif
#if OS(WINDOWS)
// These are to avoid including <winbase.h> in a header for Chromium
......@@ -122,8 +125,6 @@ const PlatformFileHandle invalidPlatformFileHandle = reinterpret_cast<HANDLE>(-1
#elif PLATFORM(BREWMP)
typedef IFile* PlatformFileHandle;
const PlatformFileHandle invalidPlatformFileHandle = 0;
typedef void* PlatformModule;
typedef unsigned PlatformModuleVersion;
#elif PLATFORM(GTK)
typedef GFileIOStream* PlatformFileHandle;
const PlatformFileHandle invalidPlatformFileHandle = 0;
......@@ -161,6 +162,9 @@ String homeDirectoryPath();
String pathGetFileName(const String&);
String directoryName(const String&);
bool canExcludeFromBackup(); // Returns true if any file can ever be excluded from backup.
bool excludeFromBackup(const String&); // Returns true if successful.
Vector<String> listDirectory(const String& path, const String& filter = String());
CString fileSystemRepresentation(const String&);
......@@ -179,17 +183,18 @@ int writeToFile(PlatformFileHandle, const char* data, int length);
// Returns number of bytes actually written if successful, -1 otherwise.
int readFromFile(PlatformFileHandle, char* data, int length);
// Methods for dealing with loadable modules
// Functions for working with loadable modules.
bool unloadModule(PlatformModule);
// Encode a string for use within a file name.
String encodeForFileName(const String&);
#if PLATFORM(WIN)
String localUserSpecificStorageDirectory();
String roamingUserSpecificStorageDirectory();
#if PLATFORM(CF)
RetainPtr<CFURLRef> pathAsURL(const String&);
#endif
bool safeCreateFile(const String&, CFDataRef);
#if PLATFORM(CHROMIUM)
String pathGetDisplayFileName(const String&);
#endif
#if PLATFORM(GTK)
......@@ -198,8 +203,10 @@ String filenameForDisplay(const String&);
CString applicationDirectoryPath();
#endif
#if PLATFORM(CHROMIUM)
String pathGetDisplayFileName(const String&);
#if PLATFORM(WIN)
String localUserSpecificStorageDirectory();
String roamingUserSpecificStorageDirectory();
bool safeCreateFile(const String&, CFDataRef);
#endif
} // namespace WebCore
......
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
* Copyright (C) 2007, 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -25,12 +25,13 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "config.h"
#import "FileSystem.h"
#import "PlatformString.h"
#import <wtf/text/CString.h>
#import <wtf/RetainPtr.h>
#import <wtf/text/CString.h>
namespace WebCore {
......@@ -54,4 +55,16 @@ CString fileSystemRepresentation(const String& path)
return string;
}
RetainPtr<CFURLRef> pathAsURL(const String& path)
{
CFURLPathStyle pathStyle;
#if PLATFORM(WIN)
pathStyle = kCFURLWindowsPathStyle;
#else
pathStyle = kCFURLPOSIXPathStyle;
#endif
return RetainPtr<CFURLRef>(AdoptCF, CFURLCreateWithFileSystemPath(0,
RetainPtr<CFStringRef>(AdoptCF, path.createCFString()).get(), pathStyle, FALSE));
}
} // namespace WebCore
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
* Copyright (C) 2007, 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -25,10 +25,12 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "config.h"
#import "FileSystem.h"
#import "PlatformString.h"
#import <wtf/RetainPtr.h>
#import <wtf/text/CString.h>
namespace WebCore {
......@@ -62,4 +64,25 @@ CString openTemporaryFile(const char* prefix, PlatformFileHandle& platformFileHa
return CString(temporaryFilePath.data());
}
bool canExcludeFromBackup()
{
#ifdef BUILDING_ON_TIGER
return false;
#else
return true;
#endif
}
bool excludeFromBackup(const String& path)
{
#ifdef BUILDING_ON_TIGER
UNUSED_PARAM(path);
return false;
#else
// It is critical to pass FALSE for excludeByPath because excluding by path requires root privileges.
CSBackupSetItemExcluded(pathAsURL(path).get(), TRUE, FALSE);
return true;
#endif
}
} // namespace WebCore
......@@ -145,17 +145,8 @@ static void advanceCurrentStream(FormStreamFields *form)
char* data = nextInput.m_data.releaseBuffer();
form->currentStream = CFReadStreamCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(data), size, kCFAllocatorNull);
form->currentData = data;
} else {
CFStringRef filename = nextInput.m_filename.createCFString();
#if PLATFORM(WIN)
CFURLRef fileURL = CFURLCreateWithFileSystemPath(0, filename, kCFURLWindowsPathStyle, FALSE);
#else
CFURLRef fileURL = CFURLCreateWithFileSystemPath(0, filename, kCFURLPOSIXPathStyle, FALSE);
#endif
CFRelease(filename);
form->currentStream = CFReadStreamCreateWithFile(0, fileURL);
CFRelease(fileURL);
}
} else
form->currentStream = CFReadStreamCreateWithFile(0, pathAsURL(nextInput.m_filename).get());
form->remainingElements.removeLast();
// Set up the callback.
......
......@@ -185,9 +185,7 @@ static bool advanceCurrentStream(FormStreamFields* form)
}
#endif
const String& path = nextInput.m_shouldGenerateFile ? nextInput.m_generatedFilename : nextInput.m_filename;
RetainPtr<CFStringRef> filename(AdoptCF, path.createCFString());
RetainPtr<CFURLRef> fileURL(AdoptCF, CFURLCreateWithFileSystemPath(0, filename.get(), kCFURLPOSIXPathStyle, FALSE));
form->currentStream = CFReadStreamCreateWithFile(0, fileURL.get());
form->currentStream = CFReadStreamCreateWithFile(0, pathAsURL(path).get());
if (!form->currentStream) {
// The file must have been removed or become unreadable.
return false;
......
2011-01-25 Darin Adler <darin@apple.com>
Reviewed by Anders Carlsson.
WebKit is using CSBackupSetItemExcluded incorrectly
https://bugs.webkit.org/show_bug.cgi?id=53095
rdar://problem/8790540
* Misc/WebIconDatabase.mm:
(importToWebCoreFormat): Removed code that was calling CSBackupSetItemExcluded.
It was incorrect, and this responsibility has been moved to WebCore.
2011-01-24 Chris Marrin <cmarrin@apple.com>
Reviewed by Eric Seidel.
......
......@@ -590,24 +590,6 @@ bool importToWebCoreFormat()
[ThreadEnabler enableThreading];
ASSERT([NSThread isMultiThreaded]);
#ifndef BUILDING_ON_TIGER
// Tell backup software (i.e., Time Machine) to never back up the icon database, because
// it's a large file that changes frequently, thus using a lot of backup disk space, and
// it's unlikely that many users would be upset about it not being backed up. We do this
// here because this code is only executed once for each icon database instance. We could
// make this configurable on a per-client basis someday if that seemed useful.
// See <rdar://problem/5320208>.
// FIXME: This has nothing to do with importing from the old to the new database format and should be moved elsewhere,
// especially because we might eventually delete all of this legacy importing code and we shouldn't delete this.
CFStringRef databasePath = iconDatabase()->databasePath().createCFString();
if (databasePath) {
CFURLRef databasePathURL = CFURLCreateWithFileSystemPath(0, databasePath, kCFURLPOSIXPathStyle, FALSE);
CFRelease(databasePath);
CSBackupSetItemExcluded(databasePathURL, true, true);
CFRelease(databasePathURL);
}
#endif
// Get the directory the old icon database *should* be in
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *databaseDirectory = [defaults objectForKey:WebIconDatabaseImportDirectoryDefaultsKey];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment