Bug 135346

Summary: Make WKOriginDataManager actually operate on IndexedDatabases
Product: WebKit Reporter: Brady Eidson <beidson>
Component: WebKit2Assignee: Brady Eidson <beidson>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, ap, ddkilzer, jeffrey+webkit, ossy, sam, thorton
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 135029    
Attachments:
Description Flags
Patch v1
none
Patch v2 - Also added a new API we'll need very soon anyways sam: review+

Description Brady Eidson 2014-07-28 12:56:44 PDT
Make WKOriginDataManager correctly operate on IndexedDatabases

This patch will get the list of origins with databases by checking for their entries in the directory structure on disk.
It will also delete the database files (and any resulting empty directories) when requested.

<rdar://problem/15917314>
Comment 1 Brady Eidson 2014-07-28 12:59:55 PDT
In this patch, open handles to the database files on disk will not be notified and invalidated.

This is probably quite an acceptable situation for now. because:
    - For read-only operations, they will continue functioning as normal on the unlinked file.
    - For write operations, they will start producing errors as SQLite notices the missing backing store.

But it should still be fixed, and I filed https://bugs.webkit.org/show_bug.cgi?id=135347 to track that in a followup
Comment 2 Brady Eidson 2014-07-28 13:17:08 PDT
Created attachment 235611 [details]
Patch v1
Comment 3 Sam Weinig 2014-07-28 16:03:06 PDT
Comment on attachment 235611 [details]
Patch v1

View in context: https://bugs.webkit.org/attachment.cgi?id=235611&action=review

> Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp:60
> +    // FIXME (<rdar://problem/9127819>): Is there a more explicit way of doing this besides accessing the UTF8Encoding?

This should probably be a bugzilla bug.

> Source/WebKit2/UIProcess/WebOriginDataManagerProxy.cpp:116
> +    if (!callback) {
> +        LOG_ERROR("WebOriginDataManagerProxy::didGetOrigins - Invalid callback ID");
> +        return;
> +    }
> +

When can this happen?  Should this be a MESSAGE_CHECK()?

> Source/WebKit2/UIProcess/WebOriginDataManagerProxy.cpp:131
> +    if (!(types & kWKIndexedDatabaseData)) {
> +        callbackFunction(CallbackBase::Error::None);
>          return;
> +    }

This should probably have the same comment as above (or just move the one from below).

> Source/WebKit2/UIProcess/WebOriginDataManagerProxy.cpp:160
> +    if (!(types & kWKIndexedDatabaseData)) {
> +        callbackFunction(CallbackBase::Error::None);
>          return;
> +    }

This should probably have the same comment as above (or just move the one from below).

> Source/WebKit2/UIProcess/WebOriginDataManagerProxy.cpp:190
> +    if (!(types & kWKIndexedDatabaseData)) {
> +        callbackFunction(CallbackBase::Error::None);
>          return;
> +    }

This should probably have the same comment as above (or just move the one from below).
Comment 4 Brady Eidson 2014-07-28 16:07:27 PDT
(In reply to comment #3)
> (From update of attachment 235611 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=235611&action=review
> 
> > Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp:60
> > +    // FIXME (<rdar://problem/9127819>): Is there a more explicit way of doing this besides accessing the UTF8Encoding?
> 
> This should probably be a bugzilla bug.

Yah, probably!

> > Source/WebKit2/UIProcess/WebOriginDataManagerProxy.cpp:116
> > +    if (!callback) {
> > +        LOG_ERROR("WebOriginDataManagerProxy::didGetOrigins - Invalid callback ID");
> > +        return;
> > +    }
> > +
> 
> When can this happen?  Should this be a MESSAGE_CHECK()?

Shouldn't happen.  Should probably be a MESSAGE_CHECK.

> This should probably have the same comment as above (or just move the one from below).
...
> This should probably have the same comment as above (or just move the one from below).
...
> This should probably have the same comment as above (or just move the one from below).

Willdo
Comment 5 Brady Eidson 2014-07-28 16:12:37 PDT
Filed https://bugs.webkit.org/show_bug.cgi?id=135365 for that radar.  Will update the comment in the patch (as well as the comment in LocalStorageDatabaseTracker.cpp) before landing.
Comment 6 Brady Eidson 2014-07-28 16:26:58 PDT
(In reply to comment #4)
> (In reply to comment #3)
> 
> > > Source/WebKit2/UIProcess/WebOriginDataManagerProxy.cpp:116
> > > +    if (!callback) {
> > > +        LOG_ERROR("WebOriginDataManagerProxy::didGetOrigins - Invalid callback ID");
> > > +        return;
> > > +    }
> > > +
> > 
> > When can this happen?  Should this be a MESSAGE_CHECK()?
> 
> Shouldn't happen.  Should probably be a MESSAGE_CHECK.

MESSAGE_CHECK requires you know what Connection the current dispatched message came from.

Right now, that can only be the DatabaseProcess, so I can do it.

In the future, WebOriginDataManagerProxy will *not* know what Connection this message is coming from, so we'll have to deal with that later.
Comment 7 Brady Eidson 2014-07-28 16:40:50 PDT
(In reply to comment #6)
> (In reply to comment #4)
> > (In reply to comment #3)
> > 
> > > > Source/WebKit2/UIProcess/WebOriginDataManagerProxy.cpp:116
> > > > +    if (!callback) {
> > > > +        LOG_ERROR("WebOriginDataManagerProxy::didGetOrigins - Invalid callback ID");
> > > > +        return;
> > > > +    }
> > > > +
> > > 
> > > When can this happen?  Should this be a MESSAGE_CHECK()?
> > 
> > Shouldn't happen.  Should probably be a MESSAGE_CHECK.
> 
> MESSAGE_CHECK requires you know what Connection the current dispatched message came from.
> 
> Right now, that can only be the DatabaseProcess, so I can do it.
> 
> In the future, WebOriginDataManagerProxy will *not* know what Connection this message is coming from, so we'll have to deal with that later.

Actually with the magic of WantsConnection, we can do this.

New patch forthcoming.
Comment 8 Brady Eidson 2014-07-28 17:12:49 PDT
Created attachment 235647 [details]
Patch v2 - Also added a new API we'll need very soon anyways
Comment 9 Brady Eidson 2014-07-28 21:57:47 PDT
Sorry about the "Also added a new API we'll need very soon anyways" - That got in there from autocomplete history.

This V2 is basically V1 with review feedback addressed.
Comment 10 David Kilzer (:ddkilzer) 2014-07-29 09:42:37 PDT
Comment on attachment 235647 [details]
Patch v2 - Also added a new API we'll need very soon anyways

r=me on the parts of the patch that touch the filesystem.
Comment 11 Alex Christensen 2014-07-29 10:29:40 PDT
(In reply to comment #10)
> (From update of attachment 235647 [details])
> r=me on the parts of the patch that touch the filesystem.
me, too!
Comment 12 Brady Eidson 2014-07-29 10:38:30 PDT
http://trac.webkit.org/changeset/171749
Comment 13 Csaba Osztrogonác 2014-07-29 13:15:57 PDT
(In reply to comment #12)
> http://trac.webkit.org/changeset/171749

and the buildfix landed in http://trac.webkit.org/changeset/171753