Changeset 46502 in webkit


Ignore:
Timestamp:
Jul 28, 2009 3:26:16 PM (15 years ago)
Author:
jorlow@chromium.org
Message:

2009-07-28 Jeremy Orlow <jorlow@chromium.org>

Reviewed by Eric Seidel.

Misc cleanup in DOM Storage.
https://bugs.webkit.org/show_bug.cgi?id=27517

The StorageAreaImpl changes are all for Chromium. Because the DOM Storage implementation
runs in a different process from where the Frame object lives, Chromium passes in NULL
for the sourceFrame. This affects events and handling privateBrowsing. Chromium's
incognito mode does not use the private browsing setting, so that's not a concern. As for
events, I've decided to simply disable them for now.

The StorageNamespaceImpl changes get rid of a stale comment (path is .copy'ed for thread-
safety) and to add an assert that .copy is only ever called on a SessionStorage namespace.

Also cleaned up tailing whitespace in several parts of StorageAreaImpl.cpp

  • storage/StorageArea.cpp: Removed. (It was empty anyway.)
  • storage/StorageAreaImpl.cpp: (WebCore::privateBrowsingEnabled): Factored out the check. (WebCore::StorageAreaImpl::setItem): Make frame optional. (WebCore::StorageAreaImpl::removeItem): ditto (WebCore::StorageAreaImpl::clear): ditto (WebCore::StorageAreaImpl::dispatchStorageEvent): Disable in Chromium for now.
  • storage/StorageNamespaceImpl.cpp: (WebCore::StorageNamespaceImpl::StorageNamespaceImpl): Remove stale comment. (WebCore::StorageNamespaceImpl::copy): Add assert that it's SessionStorage.
Location:
trunk/WebCore
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r46501 r46502  
     12009-07-28  Jeremy Orlow  <jorlow@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Misc cleanup in DOM Storage.
     6        https://bugs.webkit.org/show_bug.cgi?id=27517
     7
     8        The StorageAreaImpl changes are all for Chromium.  Because the DOM Storage implementation
     9        runs in a different process from where the Frame object lives, Chromium passes in NULL
     10        for the sourceFrame.  This affects events and handling privateBrowsing.  Chromium's
     11        incognito mode does not use the private browsing setting, so that's not a concern.  As for
     12        events, I've decided to simply disable them for now.
     13
     14        The StorageNamespaceImpl changes get rid of a stale comment (path is .copy'ed for thread-
     15        safety) and to add an assert that .copy is only ever called on a SessionStorage namespace.
     16
     17        Also cleaned up tailing whitespace in several parts of StorageAreaImpl.cpp
     18
     19        * storage/StorageArea.cpp: Removed.  (It was empty anyway.)
     20        * storage/StorageAreaImpl.cpp:
     21        (WebCore::privateBrowsingEnabled): Factored out the check.
     22        (WebCore::StorageAreaImpl::setItem): Make frame optional.
     23        (WebCore::StorageAreaImpl::removeItem): ditto
     24        (WebCore::StorageAreaImpl::clear): ditto
     25        (WebCore::StorageAreaImpl::dispatchStorageEvent): Disable in Chromium for now.
     26        * storage/StorageNamespaceImpl.cpp:
     27        (WebCore::StorageNamespaceImpl::StorageNamespaceImpl): Remove stale comment.
     28        (WebCore::StorageNamespaceImpl::copy): Add assert that it's SessionStorage.
     29
    1302009-07-28  Alpha Lam  <hclam@google.com>
    231
  • trunk/WebCore/storage/StorageAreaImpl.cpp

    r46075 r46502  
    2121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2222 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2424 */
    25  
     25
    2626#include "config.h"
    2727#include "StorageAreaImpl.h"
     
    8888}
    8989
     90static bool privateBrowsingEnabled(Frame* frame)
     91{
     92#if PLATFORM(CHROMIUM)
     93    // The frame pointer can be NULL in Chromium since this call is made in a different
     94    // process from where the Frame object exists.  Luckily, private browseing is
     95    // implemented differently in Chromium, so it'd never return true anyway.
     96    ASSERT(!frame);
     97    return false;
     98#else
     99    return frame->page()->settings()->privateBrowsingEnabled();
     100#endif
     101}
     102
    90103unsigned StorageAreaImpl::length() const
    91104{
     
    98111    ASSERT(!m_isShutdown);
    99112    blockUntilImportComplete();
    100    
     113
    101114    String key;
    102    
     115
    103116    if (!m_storageMap->key(index, key)) {
    104117        ec = INDEX_SIZE_ERR;
    105118        return String();
    106119    }
    107        
     120
    108121    return key;
    109122}
     
    113126    ASSERT(!m_isShutdown);
    114127    blockUntilImportComplete();
    115    
     128
    116129    return m_storageMap->getItem(key);
    117130}
     
    122135    ASSERT(!value.isNull());
    123136    blockUntilImportComplete();
    124    
    125     if (frame->page()->settings()->privateBrowsingEnabled()) {
     137
     138    if (privateBrowsingEnabled(frame)) {
    126139        ec = QUOTA_EXCEEDED_ERR;
    127140        return;
     
    134147    //     return;
    135148    // }
    136    
    137     String oldValue;   
     149
     150    String oldValue;
    138151    RefPtr<StorageMap> newMap = m_storageMap->setItem(key, value, oldValue);
    139    
     152
    140153    if (newMap)
    141154        m_storageMap = newMap.release();
     
    153166    ASSERT(!m_isShutdown);
    154167    blockUntilImportComplete();
    155    
    156     if (frame->page()->settings()->privateBrowsingEnabled())
     168
     169    if (privateBrowsingEnabled(frame))
    157170        return;
    158171
     
    174187    ASSERT(!m_isShutdown);
    175188    blockUntilImportComplete();
    176    
    177     if (frame->page()->settings()->privateBrowsingEnabled())
    178         return;
    179    
     189
     190    if (privateBrowsingEnabled(frame))
     191        return;
     192
    180193    m_storageMap = StorageMap::create();
    181    
     194
    182195    if (m_storageAreaSync)
    183196        m_storageAreaSync->scheduleClear();
     
    189202    ASSERT(!m_isShutdown);
    190203    blockUntilImportComplete();
    191    
     204
    192205    return m_storageMap->contains(key);
    193206}
     
    222235void StorageAreaImpl::dispatchStorageEvent(const String& key, const String& oldValue, const String& newValue, Frame* sourceFrame)
    223236{
     237#if PLATFORM(CHROMIUM)
     238    // FIXME: Events are currently broken in Chromium.
     239    return;
     240#endif
     241
     242    Page* page = sourceFrame->page();
     243    if (!page)
     244        return;
     245
    224246    // We need to copy all relevant frames from every page to a vector since sending the event to one frame might mutate the frame tree
    225247    // of any given page in the group or mutate the page group itself.
    226248    Vector<RefPtr<Frame> > frames;
    227 
    228     // FIXME: When can this occur?
    229     Page* page = sourceFrame->page();
    230     if (!page)
    231         return;
    232 
    233249    if (m_storageType == SessionStorage) {
    234250        // Send events only to our page.
     
    237253                frames.append(frame);
    238254        }
    239        
     255
    240256        for (unsigned i = 0; i < frames.size(); ++i)
    241257            frames[i]->document()->dispatchWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->documentURI(), sourceFrame->domWindow(), frames[i]->domWindow()->sessionStorage()));
     
    250266            }
    251267        }
    252        
     268
    253269        for (unsigned i = 0; i < frames.size(); ++i)
    254270            frames[i]->document()->dispatchWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->documentURI(), sourceFrame->domWindow(), frames[i]->domWindow()->localStorage()));
    255     }       
     271    }
    256272}
    257273
  • trunk/WebCore/storage/StorageNamespaceImpl.cpp

    r46075 r46502  
    6565StorageNamespaceImpl::StorageNamespaceImpl(StorageType storageType, const String& path)
    6666    : m_storageType(storageType)
    67     , m_path(path.copy())  // FIXME: Is the .copy necessary?
     67    , m_path(path.copy())  // Copy makes it safe for our other thread to access the path.
    6868    , m_syncManager(0)
    6969#ifndef NDEBUG
     
    8989    ASSERT(isMainThread());
    9090    ASSERT(!m_isShutdown);
     91    ASSERT(m_storageType == SessionStorage);
    9192
    9293    StorageNamespaceImpl* newNamespace = new StorageNamespaceImpl(m_storageType, m_path);
Note: See TracChangeset for help on using the changeset viewer.