Changeset 76614 in webkit


Ignore:
Timestamp:
Jan 25, 2011 11:03:16 AM (13 years ago)
Author:
Darin Adler
Message:

2011-01-25 Darin Adler <Darin Adler>

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 Adler>

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.
Location:
trunk/Source
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r76612 r76614  
     12011-01-25  Darin Adler  <darin@apple.com>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        WebKit is using CSBackupSetItemExcluded incorrectly
     6        https://bugs.webkit.org/show_bug.cgi?id=53095
     7        rdar://problem/8790540
     8
     9        * loader/icon/IconDatabase.cpp:
     10        (WebCore::IconDatabase::performOpenInitialization): Added code to
     11        exclude the database from backup one time, and record inside the
     12        database that this has been done.
     13        (WebCore::IconDatabase::wasExcludedFromBackup): Added.
     14        (WebCore::IconDatabase::setWasExcludedFromBackup): Added.
     15        * loader/icon/IconDatabase.h: Added new functions above.
     16
     17        * platform/FileSystem.cpp:
     18        (WebCore::canExcludeFromBackup): Added.
     19        (WebCore::excludeFromBackup): Added.
     20
     21        * platform/FileSystem.h: Added canExcludeFromBackup, excludeFromBackup,
     22        and pathAsURL functions. Cleaned up ifdefs and comments a bit and sorted
     23        things alphabetically, particularly platform-specific sections.
     24
     25        * platform/cf/FileSystemCF.cpp:
     26        (WebCore::pathAsURL): Added.
     27
     28        * platform/mac/FileSystemMac.mm:
     29        (WebCore::canExcludeFromBackup): Added.
     30        (WebCore::excludeFromBackup): Added.
     31
     32        * platform/network/cf/FormDataStreamCFNet.cpp:
     33        (WebCore::advanceCurrentStream): Changed to call pathAsURL.
     34        * platform/network/mac/FormDataStreamMac.mm:
     35        (WebCore::advanceCurrentStream): Ditto.
     36
    1372011-01-25  Helder Correia  <helder@sencha.com>
    238
  • trunk/Source/WebCore/loader/icon/IconDatabase.cpp

    r67619 r76614  
    11/*
    2  * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserved.
    33 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com)
    44 *
     
    10521052static bool isValidDatabase(SQLiteDatabase& db)
    10531053{
    1054 
    10551054    // These four tables should always exist in a valid db
    10561055    if (!db.tableExists("IconInfo") || !db.tableExists("IconData") || !db.tableExists("PageURL") || !db.tableExists("IconDatabaseInfo"))
     
    11561155    if (!SQLiteStatement(m_syncDB, "PRAGMA cache_size = 200;").executeCommand())         
    11571156        LOG_ERROR("SQLite database could not set cache_size");
     1157
     1158    // Tell backup software (i.e., Time Machine) to never back up the icon database, because 
     1159    // it's a large file that changes frequently, thus using a lot of backup disk space, and
     1160    // it's unlikely that many users would be upset about it not being backed up. We could
     1161    // make this configurable on a per-client basis some day if some clients don't want this.
     1162    if (canExcludeFromBackup() && !wasExcludedFromBackup() && excludeFromBackup(m_completeDatabasePath))
     1163        setWasExcludedFromBackup();
    11581164}
    11591165
     
    20872093}
    20882094
     2095bool IconDatabase::wasExcludedFromBackup()
     2096{
     2097    ASSERT_ICON_SYNC_THREAD();
     2098
     2099    return SQLiteStatement(m_syncDB, "SELECT value FROM IconDatabaseInfo WHERE key = 'ExcludedFromBackup';").getColumnInt(0);
     2100}
     2101
     2102void IconDatabase::setWasExcludedFromBackup()
     2103{
     2104    ASSERT_ICON_SYNC_THREAD();
     2105
     2106    SQLiteStatement(m_syncDB, "INSERT INTO IconDatabaseInfo (key, value) VALUES ('ExcludedFromBackup', 1)").executeCommand();
     2107}
     2108
    20892109} // namespace WebCore
    20902110
  • trunk/Source/WebCore/loader/icon/IconDatabase.h

    r76248 r76614  
    200200    void setImported(bool);
    201201   
     202    bool wasExcludedFromBackup();
     203    void setWasExcludedFromBackup();
     204
    202205    bool m_initialPruningComplete;
    203206       
  • trunk/Source/WebCore/platform/FileSystem.cpp

    r65509 r76614  
    11/*
    2  * Copyright (C) 2007 Apple Inc. All rights reserved.
     2 * Copyright (C) 2007, 2011 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    102102}
    103103
     104#if !PLATFORM(MAC)
     105
     106bool canExcludeFromBackup()
     107{
     108    return false;
     109}
     110
     111bool excludeFromBackup(const String&)
     112{
     113    return false;
     114}
     115
     116#endif
     117
    104118} // namespace WebCore
  • trunk/Source/WebCore/platform/FileSystem.h

    r75347 r76614  
    11/*
    2  * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved.
    33 * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
    44 *
     
    3131#define FileSystem_h
    3232
     33#include "PlatformString.h"
     34#include <time.h>
     35#include <wtf/Forward.h>
     36#include <wtf/Vector.h>
     37
     38#if PLATFORM(CF)
     39#include <wtf/RetainPtr.h>
     40#endif
     41
    3342#if PLATFORM(QT)
    3443#include <QFile>
     
    4049
    4150#if PLATFORM(CF) || (PLATFORM(QT) && defined(Q_WS_MAC))
    42 #include <CoreFoundation/CFBundle.h>
    43 #endif
    44 
    45 #include "PlatformString.h"
    46 #include <time.h>
    47 #include <wtf/Forward.h>
    48 #include <wtf/Vector.h>
    49 
     51typedef struct __CFBundle* CFBundleRef;
    5052typedef const struct __CFData* CFDataRef;
     53#endif
    5154
    5255#if OS(WINDOWS)
     
    123126typedef IFile* PlatformFileHandle;
    124127const PlatformFileHandle invalidPlatformFileHandle = 0;
    125 typedef void* PlatformModule;
    126 typedef unsigned PlatformModuleVersion;
    127128#elif PLATFORM(GTK)
    128129typedef GFileIOStream* PlatformFileHandle;
     
    162163String directoryName(const String&);
    163164
     165bool canExcludeFromBackup(); // Returns true if any file can ever be excluded from backup.
     166bool excludeFromBackup(const String&); // Returns true if successful.
     167
    164168Vector<String> listDirectory(const String& path, const String& filter = String());
    165169
     
    180184int readFromFile(PlatformFileHandle, char* data, int length);
    181185
    182 // Methods for dealing with loadable modules
     186// Functions for working with loadable modules.
    183187bool unloadModule(PlatformModule);
    184188
     
    186190String encodeForFileName(const String&);
    187191
    188 #if PLATFORM(WIN)
    189 String localUserSpecificStorageDirectory();
    190 String roamingUserSpecificStorageDirectory();
    191 
    192 bool safeCreateFile(const String&, CFDataRef);
     192#if PLATFORM(CF)
     193RetainPtr<CFURLRef> pathAsURL(const String&);
     194#endif
     195
     196#if PLATFORM(CHROMIUM)
     197String pathGetDisplayFileName(const String&);
    193198#endif
    194199
     
    199204#endif
    200205
    201 #if PLATFORM(CHROMIUM)
    202 String pathGetDisplayFileName(const String&);
     206#if PLATFORM(WIN)
     207String localUserSpecificStorageDirectory();
     208String roamingUserSpecificStorageDirectory();
     209bool safeCreateFile(const String&, CFDataRef);
    203210#endif
    204211
  • trunk/Source/WebCore/platform/cf/FileSystemCF.cpp

    r56825 r76614  
    11/*
    2  * Copyright (C) 2007 Apple Inc. All rights reserved.
     2 * Copyright (C) 2007, 2011 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
     28
    2829#import "config.h"
    2930#import "FileSystem.h"
    3031
    3132#import "PlatformString.h"
     33#import <wtf/RetainPtr.h>
    3234#import <wtf/text/CString.h>
    33 #import <wtf/RetainPtr.h>
    3435
    3536namespace WebCore {
     
    5556}
    5657
     58RetainPtr<CFURLRef> pathAsURL(const String& path)
     59{
     60    CFURLPathStyle pathStyle;
     61#if PLATFORM(WIN)
     62    pathStyle = kCFURLWindowsPathStyle;
     63#else
     64    pathStyle = kCFURLPOSIXPathStyle;
     65#endif
     66    return RetainPtr<CFURLRef>(AdoptCF, CFURLCreateWithFileSystemPath(0,
     67        RetainPtr<CFStringRef>(AdoptCF, path.createCFString()).get(), pathStyle, FALSE));
     68}
     69
    5770} // namespace WebCore
  • trunk/Source/WebCore/platform/mac/FileSystemMac.mm

    r63704 r76614  
    11/*
    2  * Copyright (C) 2007 Apple Inc. All rights reserved.
     2 * Copyright (C) 2007, 2011 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
     28
    2829#import "config.h"
    2930#import "FileSystem.h"
    3031
    3132#import "PlatformString.h"
     33#import <wtf/RetainPtr.h>
    3234#import <wtf/text/CString.h>
    3335
     
    6365}
    6466
     67bool canExcludeFromBackup()
     68{
     69#ifdef BUILDING_ON_TIGER
     70    return false;
     71#else
     72    return true;
     73#endif
     74}
     75
     76bool excludeFromBackup(const String& path)
     77{
     78#ifdef BUILDING_ON_TIGER
     79    UNUSED_PARAM(path);
     80    return false;
     81#else
     82    // It is critical to pass FALSE for excludeByPath because excluding by path requires root privileges.
     83    CSBackupSetItemExcluded(pathAsURL(path).get(), TRUE, FALSE);
     84    return true;
     85#endif
     86}
     87
    6588} // namespace WebCore
  • trunk/Source/WebCore/platform/network/cf/FormDataStreamCFNet.cpp

    r74943 r76614  
    146146        form->currentStream = CFReadStreamCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(data), size, kCFAllocatorNull);
    147147        form->currentData = data;
    148     } else {
    149         CFStringRef filename = nextInput.m_filename.createCFString();
    150 #if PLATFORM(WIN)
    151         CFURLRef fileURL = CFURLCreateWithFileSystemPath(0, filename, kCFURLWindowsPathStyle, FALSE);
    152 #else
    153         CFURLRef fileURL = CFURLCreateWithFileSystemPath(0, filename, kCFURLPOSIXPathStyle, FALSE);
    154 #endif
    155         CFRelease(filename);
    156         form->currentStream = CFReadStreamCreateWithFile(0, fileURL);
    157         CFRelease(fileURL);
    158     }
     148    } else
     149        form->currentStream = CFReadStreamCreateWithFile(0, pathAsURL(nextInput.m_filename).get());
    159150    form->remainingElements.removeLast();
    160151
  • trunk/Source/WebCore/platform/network/mac/FormDataStreamMac.mm

    r74952 r76614  
    186186#endif
    187187        const String& path = nextInput.m_shouldGenerateFile ? nextInput.m_generatedFilename : nextInput.m_filename;
    188         RetainPtr<CFStringRef> filename(AdoptCF, path.createCFString());
    189         RetainPtr<CFURLRef> fileURL(AdoptCF, CFURLCreateWithFileSystemPath(0, filename.get(), kCFURLPOSIXPathStyle, FALSE));
    190         form->currentStream = CFReadStreamCreateWithFile(0, fileURL.get());
     188        form->currentStream = CFReadStreamCreateWithFile(0, pathAsURL(path).get());
    191189        if (!form->currentStream) {
    192190            // The file must have been removed or become unreadable.
  • trunk/Source/WebKit/mac/ChangeLog

    r76600 r76614  
     12011-01-25  Darin Adler  <darin@apple.com>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        WebKit is using CSBackupSetItemExcluded incorrectly
     6        https://bugs.webkit.org/show_bug.cgi?id=53095
     7        rdar://problem/8790540
     8
     9        * Misc/WebIconDatabase.mm:
     10        (importToWebCoreFormat): Removed code that was calling CSBackupSetItemExcluded.
     11        It was incorrect, and this responsibility has been moved to WebCore.
     12
    1132011-01-24  Chris Marrin  <cmarrin@apple.com>
    214
  • trunk/Source/WebKit/mac/Misc/WebIconDatabase.mm

    r63632 r76614  
    591591    ASSERT([NSThread isMultiThreaded]);   
    592592   
    593 #ifndef BUILDING_ON_TIGER
    594     // Tell backup software (i.e., Time Machine) to never back up the icon database, because 
    595     // it's a large file that changes frequently, thus using a lot of backup disk space, and
    596     // it's unlikely that many users would be upset about it not being backed up. We do this
    597     // here because this code is only executed once for each icon database instance. We could
    598     // make this configurable on a per-client basis someday if that seemed useful.
    599     // See <rdar://problem/5320208>.
    600     // FIXME: This has nothing to do with importing from the old to the new database format and should be moved elsewhere,
    601     // especially because we might eventually delete all of this legacy importing code and we shouldn't delete this.
    602     CFStringRef databasePath = iconDatabase()->databasePath().createCFString();
    603     if (databasePath) {
    604         CFURLRef databasePathURL = CFURLCreateWithFileSystemPath(0, databasePath, kCFURLPOSIXPathStyle, FALSE);
    605         CFRelease(databasePath);
    606         CSBackupSetItemExcluded(databasePathURL, true, true);
    607         CFRelease(databasePathURL);
    608     }
    609 #endif
    610 
    611593    // Get the directory the old icon database *should* be in
    612594    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
Note: See TracChangeset for help on using the changeset viewer.