diff options
author | Ben Murdoch <benm@google.com> | 2011-05-13 16:23:25 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-05-16 11:35:02 +0100 |
commit | 65f03d4f644ce73618e5f4f50dd694b26f55ae12 (patch) | |
tree | f478babb801e720de7bfaee23443ffe029f58731 /WebKit/mac/Storage | |
parent | 47de4a2fb7262c7ebdb9cd133ad2c54c187454d0 (diff) | |
download | external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.zip external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.gz external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.bz2 |
Merge WebKit at r75993: Initial merge by git.
Change-Id: I602bbdc3974787a3b0450456a30a7868286921c3
Diffstat (limited to 'WebKit/mac/Storage')
-rw-r--r-- | WebKit/mac/Storage/WebDatabaseManager.mm | 149 | ||||
-rw-r--r-- | WebKit/mac/Storage/WebDatabaseManagerInternal.h | 33 | ||||
-rw-r--r-- | WebKit/mac/Storage/WebDatabaseManagerPrivate.h | 68 | ||||
-rw-r--r-- | WebKit/mac/Storage/WebDatabaseQuotaManager.h | 32 | ||||
-rw-r--r-- | WebKit/mac/Storage/WebDatabaseQuotaManager.mm | 78 | ||||
-rw-r--r-- | WebKit/mac/Storage/WebDatabaseTrackerClient.h | 44 | ||||
-rw-r--r-- | WebKit/mac/Storage/WebDatabaseTrackerClient.mm | 111 |
7 files changed, 0 insertions, 515 deletions
diff --git a/WebKit/mac/Storage/WebDatabaseManager.mm b/WebKit/mac/Storage/WebDatabaseManager.mm deleted file mode 100644 index 8c5e8a2..0000000 --- a/WebKit/mac/Storage/WebDatabaseManager.mm +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (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 "WebDatabaseManagerPrivate.h" -#import "WebDatabaseManagerInternal.h" - -#if ENABLE(DATABASE) - -#import "WebDatabaseTrackerClient.h" -#import "WebSecurityOriginInternal.h" - -#import <WebCore/DatabaseTracker.h> -#import <WebCore/SecurityOrigin.h> - -using namespace WebCore; - -NSString *WebDatabaseDirectoryDefaultsKey = @"WebDatabaseDirectory"; - -NSString *WebDatabaseDisplayNameKey = @"WebDatabaseDisplayNameKey"; -NSString *WebDatabaseExpectedSizeKey = @"WebDatabaseExpectedSizeKey"; -NSString *WebDatabaseUsageKey = @"WebDatabaseUsageKey"; - -NSString *WebDatabaseDidModifyOriginNotification = @"WebDatabaseDidModifyOriginNotification"; -NSString *WebDatabaseDidModifyDatabaseNotification = @"WebDatabaseDidModifyDatabaseNotification"; -NSString *WebDatabaseIdentifierKey = @"WebDatabaseIdentifierKey"; - -static NSString *databasesDirectoryPath(); - -@implementation WebDatabaseManager - -+ (WebDatabaseManager *) sharedWebDatabaseManager -{ - static WebDatabaseManager *sharedManager = [[WebDatabaseManager alloc] init]; - return sharedManager; -} - -- (NSArray *)origins -{ - Vector<RefPtr<SecurityOrigin> > coreOrigins; - DatabaseTracker::tracker().origins(coreOrigins); - NSMutableArray *webOrigins = [[NSMutableArray alloc] initWithCapacity:coreOrigins.size()]; - - for (unsigned i = 0; i < coreOrigins.size(); ++i) { - WebSecurityOrigin *webOrigin = [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:coreOrigins[i].get()]; - [webOrigins addObject:webOrigin]; - [webOrigin release]; - } - - return [webOrigins autorelease]; -} - -- (NSArray *)databasesWithOrigin:(WebSecurityOrigin *)origin -{ - Vector<String> nameVector; - if (!DatabaseTracker::tracker().databaseNamesForOrigin([origin _core], nameVector)) - return nil; - - NSMutableArray *names = [[NSMutableArray alloc] initWithCapacity:nameVector.size()]; - - for (unsigned i = 0; i < nameVector.size(); ++i) - [names addObject:(NSString *)nameVector[i]]; - - return [names autorelease]; -} - -- (NSDictionary *)detailsForDatabase:(NSString *)databaseIdentifier withOrigin:(WebSecurityOrigin *)origin -{ - static id keys[3] = {WebDatabaseDisplayNameKey, WebDatabaseExpectedSizeKey, WebDatabaseUsageKey}; - - DatabaseDetails details = DatabaseTracker::tracker().detailsForNameAndOrigin(databaseIdentifier, [origin _core]); - if (details.name().isNull()) - return nil; - - id objects[3]; - objects[0] = details.displayName().isEmpty() ? databaseIdentifier : (NSString *)details.displayName(); - objects[1] = [NSNumber numberWithUnsignedLongLong:details.expectedUsage()]; - objects[2] = [NSNumber numberWithUnsignedLongLong:details.currentUsage()]; - - return [[[NSDictionary alloc] initWithObjects:objects forKeys:keys count:3] autorelease]; -} - -- (void)deleteAllDatabases -{ - DatabaseTracker::tracker().deleteAllDatabases(); -} - -- (BOOL)deleteOrigin:(WebSecurityOrigin *)origin -{ - return DatabaseTracker::tracker().deleteOrigin([origin _core]); -} - -- (BOOL)deleteDatabase:(NSString *)databaseIdentifier withOrigin:(WebSecurityOrigin *)origin -{ - return DatabaseTracker::tracker().deleteDatabase([origin _core], databaseIdentifier); -} - -@end - -static NSString *databasesDirectoryPath() -{ - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSString *databasesDirectory = [defaults objectForKey:WebDatabaseDirectoryDefaultsKey]; - if (!databasesDirectory || ![databasesDirectory isKindOfClass:[NSString class]]) - databasesDirectory = @"~/Library/WebKit/Databases"; - - return [databasesDirectory stringByStandardizingPath]; -} - -void WebKitInitializeDatabasesIfNecessary() -{ - static BOOL initialized = NO; - if (initialized) - return; - - // Set the database root path in WebCore - DatabaseTracker::initializeTracker(databasesDirectoryPath()); - - // Set the DatabaseTrackerClient - DatabaseTracker::tracker().setClient(WebDatabaseTrackerClient::sharedWebDatabaseTrackerClient()); - - initialized = YES; -} - -#endif diff --git a/WebKit/mac/Storage/WebDatabaseManagerInternal.h b/WebKit/mac/Storage/WebDatabaseManagerInternal.h deleted file mode 100644 index 6a4ad1d..0000000 --- a/WebKit/mac/Storage/WebDatabaseManagerInternal.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if ENABLE(DATABASE) - -void WebKitInitializeDatabasesIfNecessary(); - -#endif diff --git a/WebKit/mac/Storage/WebDatabaseManagerPrivate.h b/WebKit/mac/Storage/WebDatabaseManagerPrivate.h deleted file mode 100644 index 94d8109..0000000 --- a/WebKit/mac/Storage/WebDatabaseManagerPrivate.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if ENABLE(DATABASE) - -extern NSString *WebDatabaseDirectoryDefaultsKey; - -extern NSString *WebDatabaseDisplayNameKey; -extern NSString *WebDatabaseExpectedSizeKey; -extern NSString *WebDatabaseUsageKey; - -// Posted with an origin is created from scratch, gets a new database, has a database deleted, has a quota change, etc -// The notification object will be a WebSecurityOrigin object corresponding to the origin. -extern NSString *WebDatabaseDidModifyOriginNotification; - -// Posted when a database is created, its size increases, its display name changes, or its estimated size changes, or the database is removed -// The notification object will be a WebSecurityOrigin object corresponding to the origin. -// The notification userInfo will have a WebDatabaseNameKey whose value is the database name. -extern NSString *WebDatabaseDidModifyDatabaseNotification; -extern NSString *WebDatabaseIdentifierKey; - -@class WebSecurityOrigin; - -@interface WebDatabaseManager : NSObject - -+ (WebDatabaseManager *)sharedWebDatabaseManager; - -// Will return an array of WebSecurityOrigin objects. -- (NSArray *)origins; - -// Will return an array of strings, the identifiers of each database in the given origin. -- (NSArray *)databasesWithOrigin:(WebSecurityOrigin *)origin; - -// Will return the dictionary describing everything about the database for the passed identifier and origin. -- (NSDictionary *)detailsForDatabase:(NSString *)databaseIdentifier withOrigin:(WebSecurityOrigin *)origin; - -- (void)deleteAllDatabases; // Deletes all databases and all origins. -- (BOOL)deleteOrigin:(WebSecurityOrigin *)origin; -- (BOOL)deleteDatabase:(NSString *)databaseIdentifier withOrigin:(WebSecurityOrigin *)origin; - -@end - -#endif diff --git a/WebKit/mac/Storage/WebDatabaseQuotaManager.h b/WebKit/mac/Storage/WebDatabaseQuotaManager.h deleted file mode 100644 index 8219da4..0000000 --- a/WebKit/mac/Storage/WebDatabaseQuotaManager.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2010 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (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 "WebQuotaManager.h" - -@interface WebDatabaseQuotaManager : NSObject <WebQuotaManager> { - WebSecurityOrigin *_origin; -} - -@end diff --git a/WebKit/mac/Storage/WebDatabaseQuotaManager.mm b/WebKit/mac/Storage/WebDatabaseQuotaManager.mm deleted file mode 100644 index e26ae33..0000000 --- a/WebKit/mac/Storage/WebDatabaseQuotaManager.mm +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2007, 2010 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (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 "WebDatabaseQuotaManager.h" - -#import "WebSecurityOriginInternal.h" -#import <WebCore/DatabaseTracker.h> - -using namespace WebCore; - -@implementation WebDatabaseQuotaManager - -- (id)initWithOrigin:(WebSecurityOrigin *)origin -{ - self = [super init]; - if (!self) - return nil; - - _origin = origin; - return self; -} - -- (WebSecurityOrigin *)origin -{ - return _origin; -} - -- (unsigned long long)usage -{ -#if ENABLE(DATABASE) - return DatabaseTracker::tracker().usageForOrigin([_origin _core]); -#else - return 0; -#endif -} - -- (unsigned long long)quota -{ -#if ENABLE(DATABASE) - return DatabaseTracker::tracker().quotaForOrigin([_origin _core]); -#else - return 0; -#endif -} - -// If the quota is set to a value lower than the current usage, that quota will -// "stick" but no data will be purged to meet the new quota. This will simply -// prevent new data from being added to databases in that origin. -- (void)setQuota:(unsigned long long)quota -{ -#if ENABLE(DATABASE) - DatabaseTracker::tracker().setQuota([_origin _core], quota); -#endif -} - -@end diff --git a/WebKit/mac/Storage/WebDatabaseTrackerClient.h b/WebKit/mac/Storage/WebDatabaseTrackerClient.h deleted file mode 100644 index cbb5eb7..0000000 --- a/WebKit/mac/Storage/WebDatabaseTrackerClient.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if ENABLE(DATABASE) - -#import <WebCore/DatabaseTrackerClient.h> - -class WebDatabaseTrackerClient : public WebCore::DatabaseTrackerClient { -public: - static WebDatabaseTrackerClient* sharedWebDatabaseTrackerClient(); - - virtual ~WebDatabaseTrackerClient(); - virtual void dispatchDidModifyOrigin(WebCore::SecurityOrigin*); - virtual void dispatchDidModifyDatabase(WebCore::SecurityOrigin*, const WTF::String& databaseIdentifier); -private: - WebDatabaseTrackerClient(); -}; - -#endif diff --git a/WebKit/mac/Storage/WebDatabaseTrackerClient.mm b/WebKit/mac/Storage/WebDatabaseTrackerClient.mm deleted file mode 100644 index 2913739..0000000 --- a/WebKit/mac/Storage/WebDatabaseTrackerClient.mm +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (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 "WebDatabaseTrackerClient.h" - -#if ENABLE(DATABASE) - -#import "WebDatabaseManagerPrivate.h" -#import "WebSecurityOriginInternal.h" -#import <wtf/MainThread.h> -#import <wtf/RetainPtr.h> -#import <WebCore/SecurityOrigin.h> - -using namespace WebCore; - -WebDatabaseTrackerClient* WebDatabaseTrackerClient::sharedWebDatabaseTrackerClient() -{ - static WebDatabaseTrackerClient* sharedClient = new WebDatabaseTrackerClient(); - return sharedClient; -} - -WebDatabaseTrackerClient::WebDatabaseTrackerClient() -{ -} - -WebDatabaseTrackerClient::~WebDatabaseTrackerClient() -{ -} - -class DidModifyOriginData : public Noncopyable { -public: - static void dispatchToMainThread(WebDatabaseTrackerClient* client, SecurityOrigin* origin) - { - DidModifyOriginData* context = new DidModifyOriginData(client, origin->threadsafeCopy()); - callOnMainThread(&DidModifyOriginData::dispatchDidModifyOriginOnMainThread, context); - } - -private: - DidModifyOriginData(WebDatabaseTrackerClient* client, PassRefPtr<SecurityOrigin> origin) - : client(client) - , origin(origin) - { - } - - static void dispatchDidModifyOriginOnMainThread(void* context) - { - ASSERT(isMainThread()); - DidModifyOriginData* info = static_cast<DidModifyOriginData*>(context); - info->client->dispatchDidModifyOrigin(info->origin.get()); - delete info; - } - - WebDatabaseTrackerClient* client; - RefPtr<SecurityOrigin> origin; -}; - -void WebDatabaseTrackerClient::dispatchDidModifyOrigin(SecurityOrigin* origin) -{ - if (!isMainThread()) { - DidModifyOriginData::dispatchToMainThread(this, origin); - return; - } - - RetainPtr<WebSecurityOrigin> webSecurityOrigin(AdoptNS, [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:origin]); - - [[NSNotificationCenter defaultCenter] postNotificationName:WebDatabaseDidModifyOriginNotification - object:webSecurityOrigin.get()]; -} - -void WebDatabaseTrackerClient::dispatchDidModifyDatabase(SecurityOrigin* origin, const String& databaseIdentifier) -{ - if (!isMainThread()) { - DidModifyOriginData::dispatchToMainThread(this, origin); - return; - } - - RetainPtr<WebSecurityOrigin> webSecurityOrigin(AdoptNS, [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:origin]); - RetainPtr<NSDictionary> userInfo(AdoptNS, [[NSDictionary alloc] - initWithObjectsAndKeys:(NSString *)databaseIdentifier, WebDatabaseIdentifierKey, nil]); - - [[NSNotificationCenter defaultCenter] postNotificationName:WebDatabaseDidModifyDatabaseNotification - object:webSecurityOrigin.get() - userInfo:userInfo.get()]; -} - -#endif |