Changeset 142150 in webkit


Ignore:
Timestamp:
Feb 7, 2013 10:24:09 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[BlackBerry] Cookie database isn't loaded into memory in some rare cases
https://bugs.webkit.org/show_bug.cgi?id=109202
PR 286189

Patch by Otto Derek Cheung <otcheung@rim.com> on 2013-02-07
Reviewed by Yong Li.
Internally Reviewed by Konrad Piascik.

If a get/setCookie call is made before the database is loaded, or if there's some
kind of error that causes the loading of the database to fail in the constructor
of CookieManager, the browser will get into a state where it seems like cookie is
permanenty disabled.

Instead of logging the errors and redispatching the setCookie, we should do a force sync
to load the cookie database before continuing.

Since the bug is so difficult to reproduce (I never did so myself), I did the follow test
to make sure the code path is correct:
1) Make sure original implementation is retained - open and loading done in the constructor
2) Removed opening and loading in constructor, the new calls in get/setcookies loaded the db just fine (although with
an initial lag because we are blocking WKT while performing SQLite options).
3) Removed loading in constructor, the new calls loaded the db just fine.

  • platform/blackberry/CookieDatabaseBackingStore/CookieDatabaseBackingStore.cpp:

(WebCore::CookieDatabaseBackingStore::openAndLoadDatabaseSynchronously):
(WebCore):

  • platform/blackberry/CookieDatabaseBackingStore/CookieDatabaseBackingStore.h:

(CookieDatabaseBackingStore):

  • platform/blackberry/CookieManager.cpp:

(WebCore::CookieManager::setCookies):
(WebCore::CookieManager::getCookie):
(WebCore::CookieManager::generateHtmlFragmentForCookies):
(WebCore::CookieManager::getRawCookies):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r142149 r142150  
     12013-02-07  Otto Derek Cheung  <otcheung@rim.com>
     2
     3        [BlackBerry] Cookie database isn't loaded into memory in some rare cases
     4        https://bugs.webkit.org/show_bug.cgi?id=109202
     5        PR 286189
     6
     7        Reviewed by Yong Li.
     8        Internally Reviewed by Konrad Piascik.
     9
     10        If a get/setCookie call is made before the database is loaded, or if there's some
     11        kind of error that causes the loading of the database to fail in the constructor
     12        of CookieManager, the browser will get into a state where it seems like cookie is
     13        permanenty disabled.
     14
     15        Instead of logging the errors and redispatching the setCookie, we should do a force sync
     16        to load the cookie database before continuing.
     17
     18        Since the bug is so difficult to reproduce (I never did so myself), I did the follow test
     19        to make sure the code path is correct:
     20        1) Make sure original implementation is retained - open and loading done in the constructor
     21        2) Removed opening and loading in constructor, the new calls in get/setcookies loaded the db just fine (although with
     22        an initial lag because we are blocking WKT while performing SQLite options).
     23        3) Removed loading in constructor, the new calls loaded the db just fine.
     24
     25        * platform/blackberry/CookieDatabaseBackingStore/CookieDatabaseBackingStore.cpp:
     26        (WebCore::CookieDatabaseBackingStore::openAndLoadDatabaseSynchronously):
     27        (WebCore):
     28        * platform/blackberry/CookieDatabaseBackingStore/CookieDatabaseBackingStore.h:
     29        (CookieDatabaseBackingStore):
     30        * platform/blackberry/CookieManager.cpp:
     31        (WebCore::CookieManager::setCookies):
     32        (WebCore::CookieManager::getCookie):
     33        (WebCore::CookieManager::generateHtmlFragmentForCookies):
     34        (WebCore::CookieManager::getRawCookies):
     35
    1362013-02-07  Max Vujovic  <mvujovic@adobe.com>
    237
  • trunk/Source/WebCore/platform/blackberry/CookieDatabaseBackingStore/CookieDatabaseBackingStore.cpp

    r137814 r142150  
    312312}
    313313
     314void CookieDatabaseBackingStore::openAndLoadDatabaseSynchronously(const String& cookieJar)
     315{
     316    CookieLog("CookieBackingStore - loading database into CookieManager immediately");
     317
     318    if (m_db.isOpen()) {
     319        if (isCurrentThread())
     320            BlackBerry::Platform::webKitThreadMessageClient()->dispatchSyncMessage(createMethodCallMessage(&CookieManager::getBackingStoreCookies, &cookieManager()));
     321        else
     322            cookieManager().getBackingStoreCookies();
     323    } else {
     324        if (isCurrentThread())
     325            invokeOpen(cookieJar);
     326        else
     327            dispatchSyncMessage(createMethodCallMessage(&CookieDatabaseBackingStore::invokeOpen, this, cookieJar));
     328    }
     329}
     330
    314331void CookieDatabaseBackingStore::sendChangesToDatabaseSynchronously()
    315332{
  • trunk/Source/WebCore/platform/blackberry/CookieDatabaseBackingStore/CookieDatabaseBackingStore.h

    r132944 r142150  
    6060    void getCookiesFromDatabase(Vector<ParsedCookie*>& stackOfCookies, unsigned int limit = 0);
    6161
     62    void openAndLoadDatabaseSynchronously(const String& cookieJar);
    6263    void sendChangesToDatabaseSynchronously();
    6364
  • trunk/Source/WebCore/platform/blackberry/CookieManager.cpp

    r138568 r142150  
    127127void CookieManager::setCookies(const KURL& url, const String& value, CookieFilter filter)
    128128{
    129     // Dispatch the message because the database cookies are not loaded in memory yet.
    130     if (!m_syncedWithDatabase && !m_privateMode) {
    131         typedef void (WebCore::CookieManager::*FunctionType)(const KURL&, const String&, CookieFilter);
    132 
    133         BlackBerry::Platform::webKitThreadMessageClient()->dispatchMessage(
    134             BlackBerry::Platform::createMethodCallMessage<FunctionType, CookieManager, const KURL, const String, CookieFilter>(
    135                 &CookieManager::setCookies, this, url, value, filter));
    136         return;
    137     }
     129    // If the database hasn't been sync-ed at this point, force a sync load
     130    if (!m_syncedWithDatabase && !m_privateMode)
     131        m_cookieBackingStore->openAndLoadDatabaseSynchronously(cookieJar());
    138132
    139133    CookieLog("CookieManager - Setting cookies");
     
    149143void CookieManager::setCookies(const KURL& url, const Vector<String>& cookies, CookieFilter filter)
    150144{
    151     // Dispatch the message because the database cookies are not loaded in memory yet.
    152     if (!m_syncedWithDatabase && !m_privateMode) {
    153         typedef void (WebCore::CookieManager::*FunctionType)(const KURL&, const Vector<String>&, CookieFilter);
    154         BlackBerry::Platform::webKitThreadMessageClient()->dispatchMessage(
    155             BlackBerry::Platform::createMethodCallMessage<FunctionType, CookieManager, const KURL, const Vector<String>, CookieFilter>(
    156                 &CookieManager::setCookies, this, url, cookies, filter));
    157         return;
    158     }
     145    // If the database hasn't been sync-ed at this point, force a sync load
     146    if (!m_syncedWithDatabase && !m_privateMode)
     147        m_cookieBackingStore->openAndLoadDatabaseSynchronously(cookieJar());
    159148
    160149    CookieLog("CookieManager - Setting cookies");
     
    169158String CookieManager::getCookie(const KURL& url, CookieFilter filter) const
    170159{
    171     if (!m_syncedWithDatabase && !m_privateMode) {
    172         LOG_ERROR("CookieManager is calling getCookies before database values are loaded.");
    173         return String();
    174     }
     160    // If the database hasn't been sync-ed at this point, force a sync load
     161    if (!m_syncedWithDatabase && !m_privateMode)
     162        m_cookieBackingStore->openAndLoadDatabaseSynchronously(cookieJar());
    175163
    176164    Vector<ParsedCookie*> rawCookies;
     
    199187String CookieManager::generateHtmlFragmentForCookies()
    200188{
    201     if (!m_syncedWithDatabase && !m_privateMode) {
    202         LOG_ERROR("CookieManager is calling generateHtmlFragmentForCookies before database values are loaded.");
    203         return String();
    204     }
     189    // If the database hasn't been sync-ed at this point, force a sync load
     190    if (!m_syncedWithDatabase && !m_privateMode)
     191        m_cookieBackingStore->openAndLoadDatabaseSynchronously(cookieJar());
    205192
    206193    CookieLog("CookieManager - generateHtmlFragmentForCookies\n");
     
    239226void CookieManager::getRawCookies(Vector<ParsedCookie*> &stackOfCookies, const KURL& requestURL, CookieFilter filter) const
    240227{
    241     if (!m_syncedWithDatabase && !m_privateMode) {
    242         LOG_ERROR("CookieManager is calling getRawCookies before database values are loaded.");
    243         return;
    244     }
     228    // Force a sync load of the database
     229    if (!m_syncedWithDatabase && !m_privateMode)
     230        m_cookieBackingStore->openAndLoadDatabaseSynchronously(cookieJar());
    245231
    246232    CookieLog("CookieManager - getRawCookies - processing url with domain - %s & protocol: %s & path: %s\n", requestURL.host().utf8().data(), requestURL.protocol().utf8().data(), requestURL.path().utf8().data());
Note: See TracChangeset for help on using the changeset viewer.