Changeset 218753 in webkit


Ignore:
Timestamp:
Jun 23, 2017 11:05:22 AM (7 years ago)
Author:
Brent Fulgham
Message:

Avoid moving the same vector multiple times
https://bugs.webkit.org/show_bug.cgi?id=173748
<rdar://problem/32936804>

Reviewed by Chris Dumez.

We discovered that a Vector<String> was being moved inside a loop, causing it to be moved more than once.
We should never do this!

  • UIProcess/WebProcessProxy.cpp:

(WebKit::WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores):
Do not perform a move at each step of the iteration.

  • UIProcess/WebsiteData/WebsiteDataStore.cpp:

(WebKit::WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains): Receive vector of top privately
controlled domains as a const reference. Copy this vector into the completion handler. Do not move
origins out of the vector in the inner loop.
(WebKit::WebsiteDataStore::removeDataForTopPrivatelyControlledDomains): Receive vector of top privately
controlled domains as a const reference.

  • UIProcess/WebsiteData/WebsiteDataStore.h:
Location:
trunk/Source/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r218750 r218753  
     12017-06-23  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Avoid moving the same vector multiple times
     4        https://bugs.webkit.org/show_bug.cgi?id=173748
     5        <rdar://problem/32936804>
     6
     7        Reviewed by Chris Dumez.
     8
     9        We discovered that a Vector<String> was being moved inside a loop, causing it to be moved more than once.
     10        We should never do this!
     11
     12        * UIProcess/WebProcessProxy.cpp:
     13        (WebKit::WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores):
     14        Do not perform a move at each step of the iteration.
     15        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
     16        (WebKit::WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains): Receive vector of top privately
     17        controlled domains as a const reference. Copy this vector into the completion handler. Do not move
     18        origins out of the vector in the inner loop.
     19        (WebKit::WebsiteDataStore::removeDataForTopPrivatelyControlledDomains): Receive vector of top privately
     20        controlled domains as a const reference.
     21        * UIProcess/WebsiteData/WebsiteDataStore.h:
     22
    1232017-06-23  Alex Christensen  <achristensen@webkit.org>
    224
  • trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp

    r218506 r218753  
    258258        visitedSessionIDs.add(dataStore.sessionID());
    259259        callbackAggregator->addPendingCallback();
    260         dataStore.removeDataForTopPrivatelyControlledDomains(dataTypes, { }, WTFMove(topPrivatelyControlledDomains), [callbackAggregator, shouldNotifyPage, page](Vector<String>&& domainsWithDeletedWebsiteData) {
     260        dataStore.removeDataForTopPrivatelyControlledDomains(dataTypes, { }, topPrivatelyControlledDomains, [callbackAggregator, shouldNotifyPage, page](Vector<String>&& domainsWithDeletedWebsiteData) {
    261261            // When completing the task, we should be getting called on the main thread.
    262262            ASSERT(isMainThread());
  • trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp

    r218506 r218753  
    508508}
    509509
    510 void WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, Vector<String>&& topPrivatelyControlledDomains, Function<void(Vector<WebsiteDataRecord>&&, Vector<String>&&)>&& completionHandler)
    511 {
    512     fetchData(dataTypes, fetchOptions, [topPrivatelyControlledDomains = WTFMove(topPrivatelyControlledDomains), completionHandler = WTFMove(completionHandler)](auto&& existingDataRecords) {
     510void WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, const Vector<String>& topPrivatelyControlledDomains, Function<void(Vector<WebsiteDataRecord>&&, Vector<String>&&)>&& completionHandler)
     511{
     512    fetchData(dataTypes, fetchOptions, [topPrivatelyControlledDomains, completionHandler = WTFMove(completionHandler)](auto&& existingDataRecords) {
    513513        Vector<WebsiteDataRecord> matchingDataRecords;
    514514        Vector<String> domainsWithMatchingDataRecords;
    515515        for (auto&& dataRecord : existingDataRecords) {
    516             for (auto&& topPrivatelyControlledDomain : topPrivatelyControlledDomains) {
     516            for (auto& topPrivatelyControlledDomain : topPrivatelyControlledDomains) {
    517517                if (dataRecord.matchesTopPrivatelyControlledDomain(topPrivatelyControlledDomain)) {
    518518                    matchingDataRecords.append(WTFMove(dataRecord));
     
    10771077}
    10781078
    1079 void WebsiteDataStore::removeDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, Vector<String>&& topPrivatelyControlledDomains, Function<void(Vector<String>&&)>&& completionHandler)
    1080 {
    1081     fetchDataForTopPrivatelyControlledDomains(dataTypes, fetchOptions, WTFMove(topPrivatelyControlledDomains), [dataTypes, completionHandler = WTFMove(completionHandler), this, protectedThis = makeRef(*this)](Vector<WebsiteDataRecord>&& websiteDataRecords, Vector<String>&& domainsWithDataRecords) mutable {
     1079void WebsiteDataStore::removeDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, const Vector<String>& topPrivatelyControlledDomains, Function<void(Vector<String>&&)>&& completionHandler)
     1080{
     1081    fetchDataForTopPrivatelyControlledDomains(dataTypes, fetchOptions, topPrivatelyControlledDomains, [dataTypes, completionHandler = WTFMove(completionHandler), this, protectedThis = makeRef(*this)](Vector<WebsiteDataRecord>&& websiteDataRecords, Vector<String>&& domainsWithDataRecords) mutable {
    10821082        this->removeData(dataTypes, websiteDataRecords, [domainsWithDataRecords = WTFMove(domainsWithDataRecords), completionHandler = WTFMove(completionHandler)]() mutable {
    10831083            completionHandler(WTFMove(domainsWithDataRecords));
  • trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h

    r218457 r218753  
    9595
    9696    void fetchData(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, Function<void(Vector<WebsiteDataRecord>)>&& completionHandler);
    97     void fetchDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, Vector<String>&& topPrivatelyControlledDomains, Function<void(Vector<WebsiteDataRecord>&&, Vector<String>&&)>&& completionHandler);
     97    void fetchDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, const Vector<String>& topPrivatelyControlledDomains, Function<void(Vector<WebsiteDataRecord>&&, Vector<String>&&)>&& completionHandler);
    9898    void topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, Function<void(HashSet<String>&&)>&& completionHandler);
    9999    void removeData(OptionSet<WebsiteDataType>, std::chrono::system_clock::time_point modifiedSince, Function<void()>&& completionHandler);
    100100    void removeData(OptionSet<WebsiteDataType>, const Vector<WebsiteDataRecord>&, Function<void()>&& completionHandler);
    101     void removeDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, Vector<String>&& topPrivatelyControlledDomains, Function<void(Vector<String>&&)>&& completionHandler);
     101    void removeDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, const Vector<String>& topPrivatelyControlledDomains, Function<void(Vector<String>&&)>&& completionHandler);
    102102
    103103#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
Note: See TracChangeset for help on using the changeset viewer.