Bug 225435

Summary: Drop some unnecessary code in LocalStorageDatabase
Product: WebKit Reporter: Sihui Liu <sihui_liu>
Component: WebKit2Assignee: Sihui Liu <sihui_liu>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, kkinnunen, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Sihui Liu 2021-05-05 23:25:40 PDT
...
Comment 1 Sihui Liu 2021-05-05 23:28:38 PDT
Created attachment 427851 [details]
Patch
Comment 2 youenn fablet 2021-05-06 00:37:10 PDT
Comment on attachment 427851 [details]
Patch

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

> Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp:-83
> -        m_tracker->didOpenDatabaseWithOrigin(m_securityOrigin);

didOpenDatabaseWithOrigin callback is no longer called.
It does not seem that it does much right now but maybe it will in the future?

> Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp:296
> +        SQLiteFileSystem::deleteDatabaseFile(m_databasePath);

Ditto here. Should we remove deleteDatabaseWithOrigin?

> Source/WebKit/NetworkProcess/WebStorage/StorageArea.cpp:183
> +        m_localStorageDatabase = LocalStorageDatabase::create(databasePath, m_quotaInBytes);

Could use WTFMove and take a String&&
Comment 3 youenn fablet 2021-05-06 00:40:08 PDT
Might be good to provide additional details in change log as well
Comment 4 Chris Dumez 2021-05-06 08:00:51 PDT
Comment on attachment 427851 [details]
Patch

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

> Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp:-151
> -        transaction.rollback();

Why are we dropping this? This seems like a potential change in behavior but the ChangeLog says nothing about this.

> Source/WebKit/NetworkProcess/WebStorage/StorageArea.cpp:181
> +        auto* localStorageDatabaseTracker = m_localStorageNamespace->storageManager()->localStorageDatabaseTracker();

The previous code used to assume his was non-null but now you are null-checking it. Which is right?
Comment 5 Sihui Liu 2021-05-06 09:20:09 PDT
(In reply to youenn fablet from comment #2)
> Comment on attachment 427851 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=427851&action=review
> 
> > Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp:-83
> > -        m_tracker->didOpenDatabaseWithOrigin(m_securityOrigin);
> 
> didOpenDatabaseWithOrigin callback is no longer called.
> It does not seem that it does much right now but maybe it will in the future?
> 

The function is a no-op, and LocalStorageDatabaseTracker does not have client (like the comment in LocalStorageDatabaseTracker::didOpenDatabaseWithOrigin). LocalStorageDatabaseTracker used to track all origins in memory so we had the function, but it does not any more. We may just remove that function in LocalStorageDatabaseTracker but want to limit this patch to LocalStorageDatabase.

> > Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp:296
> > +        SQLiteFileSystem::deleteDatabaseFile(m_databasePath);
> 
> Ditto here. Should we remove deleteDatabaseWithOrigin?
> 

Since LocalStorageDatabaseTracker always traverses file folder for origins and data, I It seems Okay to untie LocalStorageDatabaseTracker and LocalStorageDatabase.

> > Source/WebKit/NetworkProcess/WebStorage/StorageArea.cpp:183
> > +        m_localStorageDatabase = LocalStorageDatabase::create(databasePath, m_quotaInBytes);
> 
> Could use WTFMove and take a String&&

Sure.
Comment 6 Sihui Liu 2021-05-06 09:29:12 PDT
(In reply to Chris Dumez from comment #4)
> Comment on attachment 427851 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=427851&action=review
> 
> > Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp:-151
> > -        transaction.rollback();
> 
> Why are we dropping this? This seems like a potential change in behavior but
> the ChangeLog says nothing about this.
> 

~SQLiteTransaction will do the rollback. Will update changeling.

> > Source/WebKit/NetworkProcess/WebStorage/StorageArea.cpp:181
> > +        auto* localStorageDatabaseTracker = m_localStorageNamespace->storageManager()->localStorageDatabaseTracker();
> 
> The previous code used to assume his was non-null but now you are
> null-checking it. Which is right?

Technically it should be non-null. I just add the safe check because it returns a raw pointer; will change it back.
Comment 7 Sihui Liu 2021-05-06 09:38:42 PDT
Created attachment 427893 [details]
Patch
Comment 8 Chris Dumez 2021-05-06 09:43:27 PDT
Comment on attachment 427893 [details]
Patch

r=me
Comment 9 EWS 2021-05-06 12:09:25 PDT
Committed r277106 (237408@main): <https://commits.webkit.org/237408@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 427893 [details].
Comment 10 Radar WebKit Bug Importer 2021-05-06 12:10:19 PDT
<rdar://problem/77619330>