Changeset 64612 in webkit


Ignore:
Timestamp:
Aug 3, 2010 6:50:10 PM (14 years ago)
Author:
Joseph Pecoraro
Message:

2010-08-03 Joseph Pecoraro <Joseph Pecoraro>

Reviewed by David Kilzer.

WebKit:

2010-08-03 Joseph Pecoraro <Joseph Pecoraro>

Limit ApplicationCache Total and Per-Origin Storage Capacity (Quotas)
https://bugs.webkit.org/show_bug.cgi?id=40627

Part 5 - Refactor Quota Management in WebSecurityOrigin into Managers

  • WebKit.xcodeproj/project.pbxproj: Add new Quota Managers, remove old SecurityOrigin subclasses.

WebKit/mac:

2010-08-03 Joseph Pecoraro <Joseph Pecoraro>

Reviewed by David Kilzer.

Limit ApplicationCache Total and Per-Origin Storage Capacity (Quotas)
https://bugs.webkit.org/show_bug.cgi?id=40627

Part 5 - Refactor Quota Management in WebSecurityOrigin into Managers

Per-Origin quotas exist for Databases and Application Caches. Clients
given a WebSecurityOrigin have the ability to set the quota for any
per-origin quota type. This puts quota management into an interface
and WebSecurityOrigin allows access to quota managers for the
different types of quotas.

This also deprecates the old methods on WebSecurityOrigin. They are
left in for now to prevent breaking older clients.

The WebQuotaManager interface allows querying and modifying a
per-origin quota. This is implemented for both Databases and
Application Caches.

  • Misc/WebQuotaManager.h: Added. Interface for quota management (usage, quota, setQuota).
  • Storage/WebDatabaseQuotaManager.h: Added.
  • Storage/WebDatabaseQuotaManager.mm: Added. (-[WebDatabaseQuotaManager origin]): (-[WebDatabaseQuotaManager usage]): (-[WebDatabaseQuotaManager quota]): (-[WebDatabaseQuotaManager setQuota:]):
  • Storage/WebDatabaseSecurityOrigin.h: Removed.
  • Storage/WebDatabaseSecurityOrigin.mm: Removed.
  • WebCoreSupport/WebApplicationCacheQuotaManager.h: Added.
  • WebCoreSupport/WebApplicationCacheQuotaManager.mm: Added. (-[WebApplicationCacheQuotaManager origin]): (-[WebApplicationCacheQuotaManager usage]): (-[WebApplicationCacheQuotaManager quota]): (-[WebApplicationCacheQuotaManager setQuota:]):
  • WebCoreSupport/WebSecurityOriginPrivate.h: Added a category to access managers. Deprecated old methods.

Remove the WebSecurityOrigin sub-classes. Managers are better.

  • WebCoreSupport/WebApplicationCacheSecurityOrigin.h: Removed.
  • WebCoreSupport/WebApplicationCacheSecurityOrigin.mm: Removed.

Create the managers lazily. Change old style calls to make use
of the managers.

  • WebCoreSupport/WebChromeClient.mm: (WebChromeClient::exceededDatabaseQuota): (WebChromeClient::reachedApplicationCacheOriginQuota):
  • WebCoreSupport/WebSecurityOrigin.mm: (-[WebSecurityOrigin applicationCacheQuotaManager]): (-[WebSecurityOrigin databaseQuotaManager]): (-[WebSecurityOrigin dealloc]): release the managers if they exist.

WebKitTools:

2010-08-03 Joseph Pecoraro <Joseph Pecoraro>

Limit ApplicationCache Total and Per-Origin Storage Capacity (Quotas)
https://bugs.webkit.org/show_bug.cgi?id=40627

Part 5 - Refactor Quota Management in WebSecurityOrigin into Managers

Change old style calls to make use of the managers.

  • DumpRenderTree/mac/LayoutTestControllerMac.mm: (LayoutTestController::setDatabaseQuota):
  • DumpRenderTree/mac/UIDelegate.mm: (-[UIDelegate webView:frame:exceededDatabaseQuotaForSecurityOrigin:database:]):
Location:
trunk
Files:
1 added
9 edited
4 moved

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/ChangeLog

    r64428 r64612  
     12010-08-03  Joseph Pecoraro  <joepeck@webkit.org>
     2
     3        Reviewed by David Kilzer.
     4
     5        Limit ApplicationCache Total and Per-Origin Storage Capacity (Quotas)
     6        https://bugs.webkit.org/show_bug.cgi?id=40627
     7
     8        Part 5 - Refactor Quota Management in WebSecurityOrigin into Managers
     9
     10        * WebKit.xcodeproj/project.pbxproj: Add new Quota Managers, remove old SecurityOrigin subclasses.
     11
    1122010-07-31  David Kilzer  <ddkilzer@apple.com>
    213
  • trunk/WebKit/WebKit.xcodeproj/project.pbxproj

    r64428 r64612  
    314314                93EB178F09F88D510091F8FF /* WebSystemInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 93EB178E09F88D510091F8FF /* WebSystemInterface.h */; };
    315315                93FDE9330D79CAF30074F029 /* WebHistoryInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 93FDE9320D79CAF30074F029 /* WebHistoryInternal.h */; };
     316                A57E2F24120749E600048DF3 /* WebQuotaManager.h in Headers */ = {isa = PBXBuildFile; fileRef = A57E2F22120749E600048DF3 /* WebQuotaManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
    316317                A5DEFC0A11D5331C00885273 /* WebSecurityOrigin.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5DEFC0711D5331C00885273 /* WebSecurityOrigin.mm */; };
    317318                A5DEFC0B11D5331C00885273 /* WebSecurityOriginInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = A5DEFC0811D5331C00885273 /* WebSecurityOriginInternal.h */; };
    318319                A5DEFC0C11D5331C00885273 /* WebSecurityOriginPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = A5DEFC0911D5331C00885273 /* WebSecurityOriginPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
    319                 A5DEFC0F11D5343E00885273 /* WebDatabaseSecurityOrigin.h in Headers */ = {isa = PBXBuildFile; fileRef = A5DEFC0D11D5343E00885273 /* WebDatabaseSecurityOrigin.h */; };
    320                 A5DEFC1011D5343E00885273 /* WebDatabaseSecurityOrigin.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5DEFC0E11D5343E00885273 /* WebDatabaseSecurityOrigin.mm */; };
    321                 A5DEFC1311D5344B00885273 /* WebApplicationCacheSecurityOrigin.h in Headers */ = {isa = PBXBuildFile; fileRef = A5DEFC1111D5344B00885273 /* WebApplicationCacheSecurityOrigin.h */; };
    322                 A5DEFC1411D5344B00885273 /* WebApplicationCacheSecurityOrigin.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5DEFC1211D5344B00885273 /* WebApplicationCacheSecurityOrigin.mm */; };
     320                A5DEFC0F11D5343E00885273 /* WebDatabaseQuotaManager.h in Headers */ = {isa = PBXBuildFile; fileRef = A5DEFC0D11D5343E00885273 /* WebDatabaseQuotaManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
     321                A5DEFC1011D5343E00885273 /* WebDatabaseQuotaManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5DEFC0E11D5343E00885273 /* WebDatabaseQuotaManager.mm */; };
     322                A5DEFC1311D5344B00885273 /* WebApplicationCacheQuotaManager.h in Headers */ = {isa = PBXBuildFile; fileRef = A5DEFC1111D5344B00885273 /* WebApplicationCacheQuotaManager.h */; };
     323                A5DEFC1411D5344B00885273 /* WebApplicationCacheQuotaManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5DEFC1211D5344B00885273 /* WebApplicationCacheQuotaManager.mm */; };
    323324                A70936AF0B5608DC00CDB48E /* WebDragClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A70936AD0B5608DC00CDB48E /* WebDragClient.h */; };
    324325                A70936B00B5608DC00CDB48E /* WebDragClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = A70936AE0B5608DC00CDB48E /* WebDragClient.mm */; };
     
    609610                9CE1F8A302A5C6F30ECA2ACD /* WebImageRendererFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebImageRendererFactory.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    610611                9CF0E249021361B00ECA16EA /* WebFramePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebFramePrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
     612                A57E2F22120749E600048DF3 /* WebQuotaManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebQuotaManager.h; sourceTree = "<group>"; };
    611613                A5DEFC0711D5331C00885273 /* WebSecurityOrigin.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebSecurityOrigin.mm; sourceTree = "<group>"; };
    612614                A5DEFC0811D5331C00885273 /* WebSecurityOriginInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSecurityOriginInternal.h; sourceTree = "<group>"; };
    613615                A5DEFC0911D5331C00885273 /* WebSecurityOriginPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSecurityOriginPrivate.h; sourceTree = "<group>"; };
    614                 A5DEFC0D11D5343E00885273 /* WebDatabaseSecurityOrigin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebDatabaseSecurityOrigin.h; sourceTree = "<group>"; };
    615                 A5DEFC0E11D5343E00885273 /* WebDatabaseSecurityOrigin.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebDatabaseSecurityOrigin.mm; sourceTree = "<group>"; };
    616                 A5DEFC1111D5344B00885273 /* WebApplicationCacheSecurityOrigin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebApplicationCacheSecurityOrigin.h; sourceTree = "<group>"; };
    617                 A5DEFC1211D5344B00885273 /* WebApplicationCacheSecurityOrigin.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebApplicationCacheSecurityOrigin.mm; sourceTree = "<group>"; };
     616                A5DEFC0D11D5343E00885273 /* WebDatabaseQuotaManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebDatabaseQuotaManager.h; sourceTree = "<group>"; };
     617                A5DEFC0E11D5343E00885273 /* WebDatabaseQuotaManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebDatabaseQuotaManager.mm; sourceTree = "<group>"; };
     618                A5DEFC1111D5344B00885273 /* WebApplicationCacheQuotaManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebApplicationCacheQuotaManager.h; sourceTree = "<group>"; };
     619                A5DEFC1211D5344B00885273 /* WebApplicationCacheQuotaManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebApplicationCacheQuotaManager.mm; sourceTree = "<group>"; };
    618620                A70936AD0B5608DC00CDB48E /* WebDragClient.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebDragClient.h; sourceTree = "<group>"; };
    619621                A70936AE0B5608DC00CDB48E /* WebDragClient.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebDragClient.mm; sourceTree = "<group>"; };
     
    970972                                9345DDAE0365FB27008635CE /* WebNSWindowExtras.h */,
    971973                                9345DDAF0365FB27008635CE /* WebNSWindowExtras.m */,
     974                                A57E2F22120749E600048DF3 /* WebQuotaManager.h */,
    972975                                F59668C802AD2923018635CA /* WebStringTruncator.h */,
    973976                                F59668C902AD2923018635CA /* WebStringTruncator.mm */,
     
    10211024                                51AEDEF00CECF45700854328 /* WebDatabaseManagerInternal.h */,
    10221025                                511F3FD20CECC88F00852565 /* WebDatabaseManagerPrivate.h */,
    1023                                 A5DEFC0D11D5343E00885273 /* WebDatabaseSecurityOrigin.h */,
    1024                                 A5DEFC0E11D5343E00885273 /* WebDatabaseSecurityOrigin.mm */,
     1026                                A5DEFC0D11D5343E00885273 /* WebDatabaseQuotaManager.h */,
     1027                                A5DEFC0E11D5343E00885273 /* WebDatabaseQuotaManager.mm */,
    10251028                                511F3FD30CECC88F00852565 /* WebDatabaseTrackerClient.h */,
    10261029                                511F3FD40CECC88F00852565 /* WebDatabaseTrackerClient.mm */,
     
    12391242                                B68049710FFBCEC1009F7F62 /* WebApplicationCache.h */,
    12401243                                B68049720FFBCEC1009F7F62 /* WebApplicationCache.mm */,
    1241                                 A5DEFC1111D5344B00885273 /* WebApplicationCacheSecurityOrigin.h */,
    1242                                 A5DEFC1211D5344B00885273 /* WebApplicationCacheSecurityOrigin.mm */,
     1244                                A5DEFC1111D5344B00885273 /* WebApplicationCacheQuotaManager.h */,
     1245                                A5DEFC1211D5344B00885273 /* WebApplicationCacheQuotaManager.mm */,
    12431246                                51CBFCAC0D10E6C5002DBF51 /* WebCachedFramePlatformData.h */,
    12441247                                14D8252D0AF955090004F057 /* WebChromeClient.h */,
     
    15701573                                A5DEFC0B11D5331C00885273 /* WebSecurityOriginInternal.h in Headers */,
    15711574                                A5DEFC0C11D5331C00885273 /* WebSecurityOriginPrivate.h in Headers */,
    1572                                 A5DEFC0F11D5343E00885273 /* WebDatabaseSecurityOrigin.h in Headers */,
    1573                                 A5DEFC1311D5344B00885273 /* WebApplicationCacheSecurityOrigin.h in Headers */,
     1575                                A5DEFC0F11D5343E00885273 /* WebDatabaseQuotaManager.h in Headers */,
     1576                                A5DEFC1311D5344B00885273 /* WebApplicationCacheQuotaManager.h in Headers */,
     1577                                A57E2F24120749E600048DF3 /* WebQuotaManager.h in Headers */,
    15741578                        );
    15751579                        runOnlyForDeploymentPostprocessing = 0;
     
    19311935                                41F4485010338E8C0030E55E /* WebWorkersPrivate.mm in Sources */,
    19321936                                A5DEFC0A11D5331C00885273 /* WebSecurityOrigin.mm in Sources */,
    1933                                 A5DEFC1011D5343E00885273 /* WebDatabaseSecurityOrigin.mm in Sources */,
    1934                                 A5DEFC1411D5344B00885273 /* WebApplicationCacheSecurityOrigin.mm in Sources */,
     1937                                A5DEFC1011D5343E00885273 /* WebDatabaseQuotaManager.mm in Sources */,
     1938                                A5DEFC1411D5344B00885273 /* WebApplicationCacheQuotaManager.mm in Sources */,
    19351939                        );
    19361940                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebKit/mac/ChangeLog

    r64589 r64612  
     12010-08-03  Joseph Pecoraro  <joepeck@webkit.org>
     2
     3        Reviewed by David Kilzer.
     4
     5        Limit ApplicationCache Total and Per-Origin Storage Capacity (Quotas)
     6        https://bugs.webkit.org/show_bug.cgi?id=40627
     7
     8        Part 5 - Refactor Quota Management in WebSecurityOrigin into Managers
     9
     10        Per-Origin quotas exist for Databases and Application Caches. Clients
     11        given a WebSecurityOrigin have the ability to set the quota for any
     12        per-origin quota type. This puts quota management into an interface
     13        and WebSecurityOrigin allows access to quota managers for the
     14        different types of quotas.
     15
     16        This also deprecates the old methods on WebSecurityOrigin. They are
     17        left in for now to prevent breaking older clients.
     18
     19          The WebQuotaManager interface allows querying and modifying a
     20          per-origin quota. This is implemented for both Databases and
     21          Application Caches.
     22
     23        * Misc/WebQuotaManager.h: Added. Interface for quota management (usage, quota, setQuota).
     24        * Storage/WebDatabaseQuotaManager.h: Added.
     25        * Storage/WebDatabaseQuotaManager.mm: Added.
     26        (-[WebDatabaseQuotaManager origin]):
     27        (-[WebDatabaseQuotaManager usage]):
     28        (-[WebDatabaseQuotaManager quota]):
     29        (-[WebDatabaseQuotaManager setQuota:]):
     30        * Storage/WebDatabaseSecurityOrigin.h: Removed.
     31        * Storage/WebDatabaseSecurityOrigin.mm: Removed.
     32        * WebCoreSupport/WebApplicationCacheQuotaManager.h: Added.
     33        * WebCoreSupport/WebApplicationCacheQuotaManager.mm: Added.
     34        (-[WebApplicationCacheQuotaManager origin]):
     35        (-[WebApplicationCacheQuotaManager usage]):
     36        (-[WebApplicationCacheQuotaManager quota]):
     37        (-[WebApplicationCacheQuotaManager setQuota:]):
     38        * WebCoreSupport/WebSecurityOriginPrivate.h: Added a category to access managers. Deprecated old methods.
     39
     40          Remove the WebSecurityOrigin sub-classes. Managers are better.
     41
     42        * WebCoreSupport/WebApplicationCacheSecurityOrigin.h: Removed.
     43        * WebCoreSupport/WebApplicationCacheSecurityOrigin.mm: Removed.
     44
     45          Create the managers lazily. Change old style calls to make use
     46          of the managers.
     47
     48        * WebCoreSupport/WebChromeClient.mm:
     49        (WebChromeClient::exceededDatabaseQuota):
     50        (WebChromeClient::reachedApplicationCacheOriginQuota):
     51        * WebCoreSupport/WebSecurityOrigin.mm:
     52        (-[WebSecurityOrigin applicationCacheQuotaManager]):
     53        (-[WebSecurityOrigin databaseQuotaManager]):
     54        (-[WebSecurityOrigin dealloc]): release the managers if they exist.
     55
    1562010-08-03  Alex Milowski  <alex@milowski.com>
    257
  • trunk/WebKit/mac/Storage/WebDatabaseQuotaManager.h

    r64611 r64612  
    2424 */
    2525
    26 #import "WebSecurityOriginInternal.h"
     26#import "WebQuotaManager.h"
    2727
    28 @interface WebApplicationCacheSecurityOrigin : WebSecurityOrigin
     28@interface WebDatabaseQuotaManager : NSObject <WebQuotaManager> {
     29    WebSecurityOrigin *_origin;
     30}
     31
    2932@end
  • trunk/WebKit/mac/Storage/WebDatabaseQuotaManager.mm

    r64611 r64612  
    2424 */
    2525
    26 #import "WebDatabaseSecurityOrigin.h"
    27 #import <WebCore/SecurityOrigin.h>
     26#import "WebDatabaseQuotaManager.h"
     27
     28#import "WebSecurityOriginInternal.h"
     29#import <WebCore/DatabaseTracker.h>
    2830
    2931using namespace WebCore;
    3032
    31 @implementation WebDatabaseSecurityOrigin
     33@implementation WebDatabaseQuotaManager
    3234
    33 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=40627
    34 // Proper steps should be taken to have subclass implementations of SecurityOrigin's
    35 // origin, quota, and setQuota methods.
     35- (id)initWithOrigin:(WebSecurityOrigin *)origin
     36{
     37    self = [super init];
     38    if (!self)
     39        return nil;
     40
     41    _origin = origin;
     42    return self;
     43}
     44
     45- (WebSecurityOrigin *)origin
     46{
     47    return _origin;
     48}
     49
     50- (unsigned long long)usage
     51{
     52#if ENABLE(DATABASE)
     53    return DatabaseTracker::tracker().usageForOrigin([_origin _core]);
     54#else
     55    return 0;
     56#endif
     57}
     58
     59- (unsigned long long)quota
     60{
     61#if ENABLE(DATABASE)
     62    return DatabaseTracker::tracker().quotaForOrigin([_origin _core]);
     63#else
     64    return 0;
     65#endif
     66}
     67
     68// If the quota is set to a value lower than the current usage, that quota will
     69// "stick" but no data will be purged to meet the new quota. This will simply
     70// prevent new data from being added to databases in that origin.
     71- (void)setQuota:(unsigned long long)quota
     72{
     73#if ENABLE(DATABASE)
     74    DatabaseTracker::tracker().setQuota([_origin _core], quota);
     75#endif
     76}
    3677
    3778@end
  • trunk/WebKit/mac/WebCoreSupport/WebApplicationCacheQuotaManager.h

    r64611 r64612  
    2424 */
    2525
    26 #import "WebSecurityOriginInternal.h"
     26#import "WebQuotaManager.h"
    2727
    28 @interface WebDatabaseSecurityOrigin : WebSecurityOrigin
     28@interface WebApplicationCacheQuotaManager : NSObject <WebQuotaManager> {
     29    WebSecurityOrigin *_origin;
     30}
     31
    2932@end
  • trunk/WebKit/mac/WebCoreSupport/WebApplicationCacheQuotaManager.mm

    r64611 r64612  
    2424 */
    2525
    26 #import "WebApplicationCacheSecurityOrigin.h"
     26#import "WebApplicationCacheQuotaManager.h"
    2727
     28#import "WebSecurityOriginInternal.h"
    2829#import <WebCore/ApplicationCacheStorage.h>
    2930
    3031using namespace WebCore;
    3132
    32 @implementation WebApplicationCacheSecurityOrigin
     33@implementation WebApplicationCacheQuotaManager
     34
     35- (id)initWithOrigin:(WebSecurityOrigin *)origin
     36{
     37    self = [super init];
     38    if (!self)
     39        return nil;
     40
     41    _origin = origin;
     42    return self;
     43}
     44
     45- (WebSecurityOrigin *)origin
     46{
     47    return _origin;
     48}
    3349
    3450- (unsigned long long)usage
     
    3652#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    3753    long long usage;
    38     if (cacheStorage().usageForOrigin(reinterpret_cast<SecurityOrigin*>(_private), usage))
     54    if (cacheStorage().usageForOrigin([_origin _core], usage))
    3955        return usage;
    4056    return 0;
     
    4864#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    4965    long long quota;
    50     if (cacheStorage().quotaForOrigin(reinterpret_cast<SecurityOrigin*>(_private), quota))
     66    if (cacheStorage().quotaForOrigin([_origin _core], quota))
    5167        return quota;
    5268    return 0;
     
    5975{
    6076#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    61     cacheStorage().storeUpdatedQuotaForOrigin(reinterpret_cast<SecurityOrigin*>(_private), quota);
     77    cacheStorage().storeUpdatedQuotaForOrigin([_origin _core], quota);
    6278#endif
    6379}
  • trunk/WebKit/mac/WebCoreSupport/WebChromeClient.mm

    r64513 r64612  
    3131
    3232#import "DOMNodeInternal.h"
    33 #import "WebApplicationCacheSecurityOrigin.h"
    34 #import "WebDatabaseSecurityOrigin.h"
    3533#import "WebDefaultUIDelegate.h"
    3634#import "WebDelegateImplementationCaching.h"
     
    4442#import "WebNSURLRequestExtras.h"
    4543#import "WebPlugin.h"
     44#import "WebQuotaManager.h"
    4645#import "WebSecurityOriginInternal.h"
    4746#import "WebUIDelegatePrivate.h"
     
    560559    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    561560
    562     WebDatabaseSecurityOrigin *webOrigin = [[WebDatabaseSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:frame->document()->securityOrigin()];
     561    WebSecurityOrigin *webOrigin = [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:frame->document()->securityOrigin()];
    563562    // FIXME: remove this workaround once shipping Safari has the necessary delegate implemented.
    564563    if (WKAppVersionCheckLessThan(@"com.apple.Safari", -1, 3.1)) {
    565564        const unsigned long long defaultQuota = 5 * 1024 * 1024; // 5 megabytes should hopefully be enough to test storage support.
    566         [webOrigin setQuota:defaultQuota];
     565        [[webOrigin databaseQuotaManager] setQuota:defaultQuota];
    567566    } else
    568567        CallUIDelegate(m_webView, @selector(webView:frame:exceededDatabaseQuotaForSecurityOrigin:database:), kit(frame), webOrigin, (NSString *)databaseName);
     
    583582    BEGIN_BLOCK_OBJC_EXCEPTIONS;
    584583
    585     WebApplicationCacheSecurityOrigin *webOrigin = [[WebApplicationCacheSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:origin];
     584    WebSecurityOrigin *webOrigin = [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:origin];
    586585    CallUIDelegate(m_webView, @selector(webView:exceededApplicationCacheOriginQuotaForSecurityOrigin:), webOrigin);
    587586    [webOrigin release];
  • trunk/WebKit/mac/WebCoreSupport/WebSecurityOrigin.mm

    r64403 r64612  
    2929#import "WebSecurityOriginInternal.h"
    3030
     31#import "WebApplicationCacheQuotaManager.h"
     32#import "WebDatabaseQuotaManager.h"
     33#import "WebQuotaManager.h"
    3134#import <WebCore/KURL.h>
     35#import <WebCore/DatabaseTracker.h>
    3236#import <WebCore/SecurityOrigin.h>
    33 #import <WebCore/DatabaseTracker.h>
    3437
    3538using namespace WebCore;
     
    7073}
    7174
    72 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=40627
    73 // Proper steps should be taken to have subclass implementations of SecurityOrigin's
    74 // origin, quota, and setQuota methods.
    75 
    76 - (unsigned long long)usage
    77 {
    78 #if ENABLE(DATABASE)
    79     return DatabaseTracker::tracker().usageForOrigin(reinterpret_cast<SecurityOrigin*>(_private));
    80 #else
    81     return 0;
    82 #endif
    83 }
    84 
    85 - (unsigned long long)quota
    86 {
    87 #if ENABLE(DATABASE)
    88     return DatabaseTracker::tracker().quotaForOrigin(reinterpret_cast<SecurityOrigin*>(_private));
    89 #else
    90     return 0;
    91 #endif
    92 }
    93 
    94 // If the quota is set to a value lower than the current usage, that quota will
    95 // "stick" but no data will be purged to meet the new quota. This will simply
    96 // prevent new data from being added to databases in that origin
    97 - (void)setQuota:(unsigned long long)quota
    98 {
    99 #if ENABLE(DATABASE)
    100     DatabaseTracker::tracker().setQuota(reinterpret_cast<SecurityOrigin*>(_private), quota);
    101 #endif
    102 }
    103 
    10475- (BOOL)isEqual:(id)anObject
    10576{
     
    11586    if (_private)
    11687        reinterpret_cast<SecurityOrigin*>(_private)->deref();
     88    if (_applicationCacheQuotaManager)
     89        [(NSObject *)_applicationCacheQuotaManager release];
     90    if (_databaseQuotaManager)
     91        [(NSObject *)_databaseQuotaManager release];
    11792    [super dealloc];
    11893}
     
    148123
    149124@end
     125
     126
     127#pragma mark -
     128#pragma mark WebQuotaManagers
     129
     130@implementation WebSecurityOrigin (WebQuotaManagers)
     131
     132- (id<WebQuotaManager>)applicationCacheQuotaManager
     133{
     134    if (!_applicationCacheQuotaManager)
     135        _applicationCacheQuotaManager = [[WebApplicationCacheQuotaManager alloc] initWithOrigin:self];
     136    return _applicationCacheQuotaManager;
     137}
     138
     139- (id<WebQuotaManager>)databaseQuotaManager
     140{
     141    if (!_databaseQuotaManager)
     142        _databaseQuotaManager = [[WebDatabaseQuotaManager alloc] initWithOrigin:self];
     143    return _databaseQuotaManager;
     144}
     145
     146@end
     147
     148
     149#pragma mark -
     150#pragma mark Deprecated
     151
     152// FIXME: The following methods are deprecated and should removed later.
     153// Clients should instead get a WebQuotaManager, and query / set the quota via the Manager.
     154// NOTE: the <WebCore/DatabaseTracker.h> #include should be removed as well.
     155
     156@implementation WebSecurityOrigin (Deprecated)
     157
     158- (unsigned long long)usage
     159{
     160#if ENABLE(DATABASE)
     161    return DatabaseTracker::tracker().usageForOrigin(reinterpret_cast<SecurityOrigin*>(_private));
     162#else
     163    return 0;
     164#endif
     165}
     166
     167- (unsigned long long)quota
     168{
     169#if ENABLE(DATABASE)
     170    return DatabaseTracker::tracker().quotaForOrigin(reinterpret_cast<SecurityOrigin*>(_private));
     171#else
     172    return 0;
     173#endif
     174}
     175
     176- (void)setQuota:(unsigned long long)quota
     177{
     178#if ENABLE(DATABASE)
     179    DatabaseTracker::tracker().setQuota(reinterpret_cast<SecurityOrigin*>(_private), quota);
     180#endif
     181}
     182
     183@end
  • trunk/WebKit/mac/WebCoreSupport/WebSecurityOriginPrivate.h

    r64403 r64612  
    11/*
    2  * Copyright (C) 2007 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2007, 2010 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828
    2929@class WebSecurityOriginPrivate;
     30@protocol WebQuotaManager;
    3031
    3132@interface WebSecurityOrigin : NSObject {
    3233    WebSecurityOriginPrivate *_private;
     34    id<WebQuotaManager> _applicationCacheQuotaManager;
     35    id<WebQuotaManager> _databaseQuotaManager;
    3336}
    3437
     
    4144- (unsigned short)port;
    4245
    43 // Meant to be implemented in a subclass.
    44 // Returns the current total usage of all relevant items in this security origin in bytes.
     46@end
     47
     48@interface WebSecurityOrigin (WebQuotaManagers)
     49- (id<WebQuotaManager>)applicationCacheQuotaManager;
     50- (id<WebQuotaManager>)databaseQuotaManager;
     51@end
     52
     53// FIXME: The following methods are deprecated and should removed later.
     54// Clients should instead get a WebQuotaManager, and query / set the quota via the Manager.
     55@interface WebSecurityOrigin (Deprecated)
    4556- (unsigned long long)usage;
    46 
    47 // Meant to be implemented in a subclass.
    48 // Returns the quota of this security origin in bytes.
    4957- (unsigned long long)quota;
    50 
    51 // Meant to be implemented in a subclass.
    52 // Sets the storage quota in bytes.
    5358- (void)setQuota:(unsigned long long)quota;
    54 
    5559@end
  • trunk/WebKitTools/ChangeLog

    r64606 r64612  
     12010-08-03  Joseph Pecoraro  <joepeck@webkit.org>
     2
     3        Reviewed by David Kilzer.
     4
     5        Limit ApplicationCache Total and Per-Origin Storage Capacity (Quotas)
     6        https://bugs.webkit.org/show_bug.cgi?id=40627
     7
     8        Part 5 - Refactor Quota Management in WebSecurityOrigin into Managers
     9
     10          Change old style calls to make use of the managers.
     11
     12        * DumpRenderTree/mac/LayoutTestControllerMac.mm:
     13        (LayoutTestController::setDatabaseQuota):
     14        * DumpRenderTree/mac/UIDelegate.mm:
     15        (-[UIDelegate webView:frame:exceededDatabaseQuotaForSecurityOrigin:database:]):
     16
    1172010-08-03  Mark Rowe  <mrowe@apple.com>
    218
  • trunk/WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm

    r64356 r64612  
    6161#import <WebKit/WebPreferences.h>
    6262#import <WebKit/WebPreferencesPrivate.h>
     63#import <WebKit/WebQuotaManager.h>
    6364#import <WebKit/WebScriptWorld.h>
    6465#import <WebKit/WebSecurityOriginPrivate.h>
     
    311312{   
    312313    WebSecurityOrigin *origin = [[WebSecurityOrigin alloc] initWithURL:[NSURL URLWithString:@"file:///"]];
    313     [origin setQuota:quota];
     314    [[origin databaseQuotaManager] setQuota:quota];
    314315    [origin release];
    315316}
  • trunk/WebKitTools/DumpRenderTree/mac/UIDelegate.mm

    r62875 r64612  
    3636#import <WebKit/WebFramePrivate.h>
    3737#import <WebKit/WebHTMLViewPrivate.h>
     38#import <WebKit/WebQuotaManager.h>
    3839#import <WebKit/WebSecurityOriginPrivate.h>
    3940#import <WebKit/WebUIDelegatePrivate.h>
     
    161162
    162163    static const unsigned long long defaultQuota = 5 * 1024 * 1024;   
    163     [origin setQuota:defaultQuota];
     164    [[origin databaseQuotaManager] setQuota:defaultQuota];
    164165}
    165166
Note: See TracChangeset for help on using the changeset viewer.