Bug 141295

Summary: Switch to file backed buffer when resource is cached to disk
Product: WebKit Reporter: Antti Koivisto <koivisto>
Component: Page LoadingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, commit-queue, psolanki
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
patch cdumez: review+

Description Antti Koivisto 2015-02-05 10:48:51 PST
Wire the mechanism used with CFNetwork cache to the new disk cache.
Comment 1 Antti Koivisto 2015-02-05 12:31:54 PST
Created attachment 246121 [details]
patch
Comment 2 WebKit Commit Bot 2015-02-05 12:34:09 PST
Attachment 246121 [details] did not pass style-queue:


ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp:284:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCache.h:73:  Extra space before ( in function call  [whitespace/parens] [4]
Total errors found: 2 in 6 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Chris Dumez 2015-02-05 12:37:49 PST
Comment on attachment 246121 [details]
patch

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

> Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h:146
> +    typedef std::function<bool (std::unique_ptr<Entry>)> RetriveCompletionHandler;

"Retrieve"

> Source/WebKit2/NetworkProcess/cache/NetworkCacheStorageCocoa.mm:448
> +void NetworkCacheStorage::store(const NetworkCacheKey& key, const Entry& entry, StoreCompletionHandler completionHandler)

Since these std::function are passed by value, don't we want to WTF::move() them into the StoreOperation struct?
Comment 4 Chris Dumez 2015-02-05 12:40:46 PST
Comment on attachment 246121 [details]
patch

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

> Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp:342
> +            RefPtr<NetworkResourceLoader> loader(this);

Looks like this should be a Ref?
Comment 5 Chris Dumez 2015-02-05 12:56:02 PST
Comment on attachment 246121 [details]
patch

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

> Source/WebKit2/NetworkProcess/cache/NetworkCacheStorageCocoa.mm:257
> +    if (!map)

On failure mmap() returns MAP_FAILED which is (void*)-1, not 0.
Comment 6 Chris Dumez 2015-02-05 13:16:14 PST
Comment on attachment 246121 [details]
patch

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

r=me % a few comments.

>> Source/WebKit2/NetworkProcess/cache/NetworkCacheStorageCocoa.mm:448
>> +void NetworkCacheStorage::store(const NetworkCacheKey& key, const Entry& entry, StoreCompletionHandler completionHandler)
> 
> Since these std::function are passed by value, don't we want to WTF::move() them into the StoreOperation struct?

or pass them by const ref.
Comment 7 Antti Koivisto 2015-02-05 13:29:31 PST
> Looks like this should be a Ref?

Ref doesn't work with C++11 lambdas since it doesn't have copy-constructor.
Comment 8 Antti Koivisto 2015-02-05 13:29:52 PST
> On failure mmap() returns MAP_FAILED which is (void*)-1, not 0.

Good catch.
Comment 9 Chris Dumez 2015-02-05 13:31:37 PST
(In reply to comment #7)
> > Looks like this should be a Ref?
> 
> Ref doesn't work with C++11 lambdas since it doesn't have copy-constructor.

Right. never mind then.
Comment 10 Chris Dumez 2015-02-05 13:36:52 PST
(In reply to comment #5)
> Comment on attachment 246121 [details]
> patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=246121&action=review
> 
> > Source/WebKit2/NetworkProcess/cache/NetworkCacheStorageCocoa.mm:257
> > +    if (!map)
> 
> On failure mmap() returns MAP_FAILED which is (void*)-1, not 0.

BTW, it looks like we have the same bug in decodeEntry() already.
Comment 11 Antti Koivisto 2015-02-05 14:18:14 PST
https://trac.webkit.org/r179708