Bug 236611 - Migrate IndexedDB and LocalStorage data to GeneralStorageDirectory
Summary: Migrate IndexedDB and LocalStorage data to GeneralStorageDirectory
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Website Storage (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Sihui Liu
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-02-14 14:54 PST by Sihui Liu
Modified: 2022-02-22 16:44 PST (History)
6 users (show)

See Also:


Attachments
Patch (54.56 KB, patch)
2022-02-14 15:24 PST, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch for landing (54.71 KB, patch)
2022-02-15 20:35 PST, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch for landing (54.71 KB, patch)
2022-02-15 20:35 PST, Sihui Liu
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sihui Liu 2022-02-14 14:54:37 PST
...
Comment 1 Sihui Liu 2022-02-14 15:24:11 PST
Created attachment 451947 [details]
Patch
Comment 2 Chris Dumez 2022-02-15 14:41:13 PST
Comment on attachment 451947 [details]
Patch

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

> Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp:181
>          auto files = FileSystem::listDirectory(m_rootPath);

Can we please add an assertion that this is called off the main thread given that it does file system operations?

> Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp:193
> +        FileSystem::deleteEmptyDirectory(currentIDBStoragePath);

I will say it is fishy that a function called "isEmpty()" tries to remove a directory on disk (even an empty one).

> Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp:247
> +        if (!m_resolvedIDBStoragePath.isNull())

Can we please add an assertion that this is called off the main thread given that it does file system operations?

> Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp:251
> +            ASSERT(!(m_customIDBStoragePath.isEmpty() ^ m_rootPath.isEmpty()));

Odd to be using ^ here. Would this be identical:
`ASSERT(m_customIDBStoragePath.isEmpty() == m_rootPath.isEmpty()));` ?

> Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp:359
> +            ASSERT(!(m_customLocalStoragePath.isEmpty() ^ m_rootPath.isEmpty()));

Ditto. Not very readable.

> Source/WebKit/NetworkProcess/storage/OriginStorageManager.h:79
> +    bool m_useCustomPaths;

Can we move all the booleans together and at the end for better packing?

> Source/WebKit/Shared/WebsiteDataStoreParameters.cpp:165
> +    parameters.useCustomStoragePaths = WTFMove(*useCustomStoragePaths);

No WTFMove() for a boolean.

> Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:135
> +    bool useCustomStoragePaths() const { return m_useCustomStoragePaths; }

This is not a good name for a getter, this is why we usually have prefixes for getters in Webkit.
For example, I think we would usually name this `shouldUseCustomStoragePaths`. Alternatively, at the WebKit API layer, we also use things like "usesCustomStoragePaths()". "useCustomStoragePage()" for a getter is confusing though.

> Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:210
> +    bool m_useCustomStoragePaths { true };

Ditto about naming.

> Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:851
> +        configuration = nil;

These 3 commands should not be needed since they are scope local and we're about to go out of scope.

> Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:934
> +        configuration = nil;

ditto.
Comment 3 Sihui Liu 2022-02-15 15:43:13 PST
Comment on attachment 451947 [details]
Patch

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

>> Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp:181
>>          auto files = FileSystem::listDirectory(m_rootPath);
> 
> Can we please add an assertion that this is called off the main thread given that it does file system operations?

Sure.

>> Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp:193
>> +        FileSystem::deleteEmptyDirectory(currentIDBStoragePath);
> 
> I will say it is fishy that a function called "isEmpty()" tries to remove a directory on disk (even an empty one).

I will change it to check if the idb directory has any files in it.

>> Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp:247
>> +        if (!m_resolvedIDBStoragePath.isNull())
> 
> Can we please add an assertion that this is called off the main thread given that it does file system operations?

Sure.

>> Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp:251
>> +            ASSERT(!(m_customIDBStoragePath.isEmpty() ^ m_rootPath.isEmpty()));
> 
> Odd to be using ^ here. Would this be identical:
> `ASSERT(m_customIDBStoragePath.isEmpty() == m_rootPath.isEmpty()));` ?

Sure.

>> Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp:359
>> +            ASSERT(!(m_customLocalStoragePath.isEmpty() ^ m_rootPath.isEmpty()));
> 
> Ditto. Not very readable.

Will change.

>> Source/WebKit/NetworkProcess/storage/OriginStorageManager.h:79
>> +    bool m_useCustomPaths;
> 
> Can we move all the booleans together and at the end for better packing?

Okay.

>> Source/WebKit/Shared/WebsiteDataStoreParameters.cpp:165
>> +    parameters.useCustomStoragePaths = WTFMove(*useCustomStoragePaths);
> 
> No WTFMove() for a boolean.

Will remove.

>> Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:135
>> +    bool useCustomStoragePaths() const { return m_useCustomStoragePaths; }
> 
> This is not a good name for a getter, this is why we usually have prefixes for getters in Webkit.
> For example, I think we would usually name this `shouldUseCustomStoragePaths`. Alternatively, at the WebKit API layer, we also use things like "usesCustomStoragePaths()". "useCustomStoragePage()" for a getter is confusing though.

Will change to shouldUseCustomStoragePaths.

>> Source/WebKit/UIProcess/WebsiteData/WebsiteDataStoreConfiguration.h:210
>> +    bool m_useCustomStoragePaths { true };
> 
> Ditto about naming.

Will change.

>> Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:851
>> +        configuration = nil;
> 
> These 3 commands should not be needed since they are scope local and we're about to go out of scope.

Sure.

>> Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:934
>> +        configuration = nil;
> 
> ditto.

Sure.
Comment 4 Sihui Liu 2022-02-15 20:35:19 PST
Created attachment 452130 [details]
Patch for landing
Comment 5 Sihui Liu 2022-02-15 20:35:57 PST
Created attachment 452131 [details]
Patch for landing
Comment 6 EWS 2022-02-15 22:49:17 PST
Committed r289878 (247316@main): <https://commits.webkit.org/247316@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 452131 [details].
Comment 7 Radar WebKit Bug Importer 2022-02-15 22:50:17 PST
<rdar://problem/89008688>