Bug 48064

Summary: Quota for IndexedDB should be per origin not per database
Product: WebKit Reporter: Jeremy Orlow <jorlow>
Component: New BugsAssignee: Jeremy Orlow <jorlow>
Status: RESOLVED FIXED    
Severity: Normal CC: andreip, dglazkov, eric, joepeck, steveblock
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Other   
OS: OS X 10.5   
Attachments:
Description Flags
fix
none
oops
none
Patch
none
Patch none

Description Jeremy Orlow 2010-10-21 05:49:31 PDT
Quota for IndexedDB should be per origin not per database
Comment 1 Jeremy Orlow 2010-10-21 06:05:55 PDT
Created attachment 71428 [details]
fix
Comment 2 Jeremy Orlow 2010-10-21 06:06:10 PDT
Please review.
Comment 3 Jeremy Orlow 2010-10-21 06:07:52 PDT
Created attachment 71429 [details]
oops
Comment 4 Andrei Popescu 2010-10-22 13:32:03 PDT
Looks good, some small nits below:


> WebCore/manual-tests/indexeddb-persists.html
> var result = event.result.transaction([]).objectStore("test").get("key");

You don't need to pass the [] array. Not passing anything at all is equivalent.

> WebCore/storage/IDBDatabaseBackendImpl.cpp
> if (databaseQuery.prepare() != SQLResultOk)
>        ASSERT_NOT_REACHED();

why this and not (also) return false like we do in other error cases?

>   if (databaseQuery.step() == SQLResultRow)

ditto

>  if (query.prepare() != SQLResultOk)
>         ASSERT_NOT_REACHED();

ditto

>  , m_id(-1)

Make this a constant like we've done everywhere else?
Comment 5 Eric Seidel (no email) 2010-10-23 15:45:46 PDT
Attachment 71429 [details] did not build on chromium:
Build output: http://queues.webkit.org/results/4718053
Comment 6 Jeremy Orlow 2010-10-25 09:07:57 PDT
(In reply to comment #4)
> Looks good, some small nits below:
> 
> 
> > WebCore/manual-tests/indexeddb-persists.html
> > var result = event.result.transaction([]).objectStore("test").get("key");
> 
> You don't need to pass the [] array. Not passing anything at all is equivalent.

As specced today, I believe null implies dynamic transaction, which is not what we're looking for here.  Hopefully we get this sorted out next week at TPAC.
 
> > WebCore/storage/IDBDatabaseBackendImpl.cpp
> > if (databaseQuery.prepare() != SQLResultOk)
> >        ASSERT_NOT_REACHED();

Done.
 
> why this and not (also) return false like we do in other error cases?
> 
> >   if (databaseQuery.step() == SQLResultRow)
> 
> ditto

Because this isn't fatal.  It's hardly even worth the check.

> >  if (query.prepare() != SQLResultOk)
> >         ASSERT_NOT_REACHED();
> 
> ditto

Done.
 
> >  , m_id(-1)
> 
> Make this a constant like we've done everywhere else?

Will do.
Comment 7 Jeremy Orlow 2010-10-25 09:28:59 PDT
Created attachment 71761 [details]
Patch
Comment 8 Andrei Popescu 2010-10-26 04:38:54 PDT
(In reply to comment #7)
> Created an attachment (id=71761) [details]
> Patch

LGTM
Comment 9 Steve Block 2010-10-26 05:43:05 PDT
Comment on attachment 71761 [details]
Patch

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

> WebCore/ChangeLog:23
> +

Add a comment about the map by db name not origin?

> WebCore/storage/IDBFactoryBackendImpl.cpp:122
> +    String uniqueIdentifier = fileIdentifier + "_" + name;

Use @ for safety?
Comment 10 Steve Block 2010-10-26 06:37:49 PDT
Comment on attachment 71761 [details]
Patch

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

>> WebCore/storage/IDBFactoryBackendImpl.cpp:122
>> +    String uniqueIdentifier = fileIdentifier + "_" + name;
> 
> Use @ for safety?

If we allow underscores in the domain name, I think it's unsafe to use an underscore to join the two components, since databaseIdentifier() doesn't escape underscores ...

http://www.foo.com, ".com_80_name" -> http_www.foo.com_80_.com_80_name
http://www.foo.com_80_.com, "name" -> http_www.foo.com_80_.com_80_name

Using '@' avoids the problem as the hostname can't contain an '@'.
Comment 11 Jeremy Orlow 2010-10-26 06:46:12 PDT
Created attachment 71869 [details]
Patch
Comment 12 Jeremy Orlow 2010-10-26 06:47:43 PDT
(In reply to comment #10)
> (From update of attachment 71761 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=71761&action=review
> 
> >> WebCore/storage/IDBFactoryBackendImpl.cpp:122
> >> +    String uniqueIdentifier = fileIdentifier + "_" + name;
> > 
> > Use @ for safety?
> 
> If we allow underscores in the domain name, I think it's unsafe to use an underscore to join the two components, since databaseIdentifier() doesn't escape underscores ...
> 
> http://www.foo.com, ".com_80_name" -> http_www.foo.com_80_.com_80_name
> http://www.foo.com_80_.com, "name" -> http_www.foo.com_80_.com_80_name
> 
> Using '@' avoids the problem as the hostname can't contain an '@'.

I agree this is better.  Fixed other issue.  Please take another look?
Comment 13 Steve Block 2010-10-26 06:54:07 PDT
Comment on attachment 71869 [details]
Patch

r=me
Comment 14 Jeremy Orlow 2010-10-26 08:21:50 PDT
Comment on attachment 71869 [details]
Patch

Clearing flags on attachment: 71869

Committed r70522: <http://trac.webkit.org/changeset/70522>
Comment 15 Jeremy Orlow 2010-10-26 08:22:01 PDT
All reviewed patches have been landed.  Closing bug.