diff options
author | Ben Murdoch <benm@google.com> | 2010-10-22 13:02:20 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-10-26 15:21:41 +0100 |
commit | a94275402997c11dd2e778633dacf4b7e630a35d (patch) | |
tree | e66f56c67e3b01f22c9c23cd932271ee9ac558ed /WebKit/mac/Storage | |
parent | 09e26c78506587b3f5d930d7bc72a23287ffbec0 (diff) | |
download | external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.zip external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.tar.gz external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.tar.bz2 |
Merge WebKit at r70209: Initial merge by Git
Change-Id: Id23a68efa36e9d1126bcce0b137872db00892c8e
Diffstat (limited to 'WebKit/mac/Storage')
-rw-r--r-- | WebKit/mac/Storage/WebDatabaseTrackerClient.mm | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/WebKit/mac/Storage/WebDatabaseTrackerClient.mm b/WebKit/mac/Storage/WebDatabaseTrackerClient.mm index 89626fb..2913739 100644 --- a/WebKit/mac/Storage/WebDatabaseTrackerClient.mm +++ b/WebKit/mac/Storage/WebDatabaseTrackerClient.mm @@ -32,6 +32,7 @@ #import "WebDatabaseManagerPrivate.h" #import "WebSecurityOriginInternal.h" +#import <wtf/MainThread.h> #import <wtf/RetainPtr.h> #import <WebCore/SecurityOrigin.h> @@ -50,10 +51,42 @@ 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) { - RetainPtr<WebSecurityOrigin> webSecurityOrigin(AdoptNS, [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:origin]); + if (!isMainThread()) { + DidModifyOriginData::dispatchToMainThread(this, origin); + return; + } + + RetainPtr<WebSecurityOrigin> webSecurityOrigin(AdoptNS, [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:origin]); [[NSNotificationCenter defaultCenter] postNotificationName:WebDatabaseDidModifyOriginNotification object:webSecurityOrigin.get()]; @@ -61,6 +94,11 @@ void WebDatabaseTrackerClient::dispatchDidModifyOrigin(SecurityOrigin* origin) 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]); |