Changeset 144103 in webkit


Ignore:
Timestamp:
Feb 26, 2013, 1:54:50 PM (12 years ago)
Author:
andersca@apple.com
Message:

StorageMap can just import an entire map of items at once
https://bugs.webkit.org/show_bug.cgi?id=110904

Reviewed by Beth Dakin.

Instead of iterating over the map inside StorageAreaSync, just pass it directly
(through StorageAreaImpl) to StorageMap and iterate over it there.

  • storage/StorageAreaImpl.cpp:

(WebCore::StorageAreaImpl::importItems):

  • storage/StorageAreaImpl.h:

(StorageAreaImpl):

  • storage/StorageAreaSync.cpp:

(WebCore::StorageAreaSync::performImport):

  • storage/StorageMap.cpp:

(WebCore::StorageMap::importItems):

  • storage/StorageMap.h:

(StorageMap):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r144101 r144103  
     12013-02-26  Anders Carlsson  <andersca@apple.com>
     2
     3        StorageMap can just import an entire map of items at once
     4        https://bugs.webkit.org/show_bug.cgi?id=110904
     5
     6        Reviewed by Beth Dakin.
     7
     8        Instead of iterating over the map inside StorageAreaSync, just pass it directly
     9        (through StorageAreaImpl) to StorageMap and iterate over it there.
     10
     11        * storage/StorageAreaImpl.cpp:
     12        (WebCore::StorageAreaImpl::importItems):
     13        * storage/StorageAreaImpl.h:
     14        (StorageAreaImpl):
     15        * storage/StorageAreaSync.cpp:
     16        (WebCore::StorageAreaSync::performImport):
     17        * storage/StorageMap.cpp:
     18        (WebCore::StorageMap::importItems):
     19        * storage/StorageMap.h:
     20        (StorageMap):
     21
    1222013-02-26  CHAUDHARY VINEET  <rgf748@motorola.com>
    223
  • trunk/Source/WebCore/storage/StorageAreaImpl.cpp

    r143031 r144103  
    271271}
    272272
    273 void StorageAreaImpl::importItem(const String& key, const String& value)
    274 {
    275     ASSERT(!m_isShutdown);
    276     m_storageMap->importItem(key, value);
     273void StorageAreaImpl::importItems(const HashMap<String, String>& items)
     274{
     275    ASSERT(!m_isShutdown);
     276
     277    m_storageMap->importItems(items);
    277278}
    278279
  • trunk/Source/WebCore/storage/StorageAreaImpl.h

    r143031 r144103  
    3030#include "Timer.h"
    3131
     32#include <wtf/HashMap.h>
    3233#include <wtf/PassRefPtr.h>
    3334#include <wtf/RefPtr.h>
     
    6566
    6667        // Only called from a background thread.
    67         void importItem(const String& key, const String& value);
     68        void importItems(const HashMap<String, String>& items);
    6869
    6970        // Used to clear a StorageArea and close db before backing db file is deleted.
  • trunk/Source/WebCore/storage/StorageAreaSync.cpp

    r130612 r144103  
    342342    }
    343343
    344     HashMap<String, String>::iterator it = itemMap.begin();
    345     HashMap<String, String>::iterator end = itemMap.end();
    346 
    347     for (; it != end; ++it)
    348         m_storageArea->importItem(it->key, it->value);
     344    m_storageArea->importItems(itemMap);
    349345
    350346    markImported();
  • trunk/Source/WebCore/storage/StorageMap.cpp

    r130612 r144103  
    168168}
    169169
    170 void StorageMap::importItem(const String& key, const String& value)
     170void StorageMap::importItems(const HashMap<String, String>& items)
    171171{
    172     // Be sure to copy the keys/values as items imported on a background thread are destined
    173     // to cross a thread boundary
    174     HashMap<String, String>::AddResult result = m_map.add(key.isolatedCopy(), value.isolatedCopy());
    175     ASSERT_UNUSED(result, result.isNewEntry); // True if the key didn't exist previously.
     172    for (HashMap<String, String>::const_iterator it = items.begin(), end = items.end(); it != end; ++it) {
     173        const String& key = it->key;
     174        const String& value = it->value;
    176175
    177     ASSERT(m_currentLength + key.length() >= m_currentLength);
    178     m_currentLength += key.length();
    179     ASSERT(m_currentLength + value.length() >= m_currentLength);
    180     m_currentLength += value.length();
     176        HashMap<String, String>::AddResult result = m_map.add(key, value);
     177        ASSERT_UNUSED(result, result.isNewEntry); // True if the key didn't exist previously.
     178
     179        ASSERT(m_currentLength + key.length() >= m_currentLength);
     180        m_currentLength += key.length();
     181        ASSERT(m_currentLength + value.length() >= m_currentLength);
     182        m_currentLength += value.length();
     183    }
    181184}
    182185
  • trunk/Source/WebCore/storage/StorageMap.h

    r127757 r144103  
    4848        bool contains(const String& key) const;
    4949
    50         void importItem(const String& key, const String& value);
     50        void importItems(const HashMap<String, String>&);
    5151
    5252        unsigned quota() const { return m_quotaSize; }
Note: See TracChangeset for help on using the changeset viewer.