Changeset 91931 in webkit


Ignore:
Timestamp:
Jul 28, 2011, 8:32:40 AM (14 years ago)
Author:
beidson@apple.com
Message:

<rdar://problem/9714337> and https://bugs.webkit.org/show_bug.cgi?id=65306
WebKitInitializeStorageIfNecessary() can take awhile performing i/o, isn't necessary for every WebView

Source/WebCore:

Move the heavy lifting done in StorageTracker::initializeTracker() until when the global tracker is actually
accessed, therefore deferring it until a web page actually uses LocalStorage or the app uses the API.

Reviewed by Maciej Stachowiak.

No new tests. (Not possible to test this API implementation detail)

  • WebCore.exp.in:
  • storage/StorageAreaImpl.cpp:

(WebCore::StorageAreaImpl::StorageAreaImpl): Access the global StorageTracker to indicate that a web page

is actually using the storage APIs.

  • storage/StorageTracker.cpp:

(WebCore::StorageTracker::initializeTracker): Moved the potentially hefty work from here...
(WebCore::StorageTracker::internalInitialize): ...to here.
(WebCore::StorageTracker::tracker): If the global tracker hasn't had internalInitialize() called, do so.
(WebCore::StorageTracker::StorageTracker):

  • storage/StorageTracker.h:

Source/WebKit/mac:

Reviewed by Maciej Stachowiak.

  • Storage/WebStorageManager.mm:

(WebKitInitializeStorageIfNecessary): Pass the client along in initializeTracker().

Source/WebKit2:

Reviewed by Maciej Stachowiak.

  • WebProcess/WebProcess.cpp:

(WebKit::WebProcess::initializeWebProcess): Pass a null client pointer in the new form of initializeTracker()

Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r91929 r91931  
     12011-07-28  Brady Eidson  <beidson@apple.com>
     2
     3        <rdar://problem/9714337> and https://bugs.webkit.org/show_bug.cgi?id=65306
     4        WebKitInitializeStorageIfNecessary() can take awhile performing i/o, isn't necessary for every WebView
     5
     6        Move the heavy lifting done in StorageTracker::initializeTracker() until when the global tracker is actually
     7        accessed, therefore deferring it until a web page actually uses LocalStorage or the app uses the API.
     8
     9        Reviewed by Maciej Stachowiak.
     10
     11        No new tests. (Not possible to test this API implementation detail)
     12
     13        * WebCore.exp.in:
     14
     15        * storage/StorageAreaImpl.cpp:
     16        (WebCore::StorageAreaImpl::StorageAreaImpl): Access the global StorageTracker to indicate that a web page
     17          is actually using the storage APIs.
     18
     19        * storage/StorageTracker.cpp:
     20        (WebCore::StorageTracker::initializeTracker): Moved the potentially hefty work from here...
     21        (WebCore::StorageTracker::internalInitialize): ...to here.
     22        (WebCore::StorageTracker::tracker): If the global tracker hasn't had internalInitialize() called, do so.
     23        (WebCore::StorageTracker::StorageTracker):
     24        * storage/StorageTracker.h:
     25
    1262011-07-28  Carlos Garcia Campos  <cgarcia@igalia.com>
    227
  • trunk/Source/WebCore/WebCore.exp.in

    r91777 r91931  
    14371437__ZN7WebCore14StorageTracker16deleteAllOriginsEv
    14381438__ZN7WebCore14StorageTracker16syncLocalStorageEv
    1439 __ZN7WebCore14StorageTracker17initializeTrackerERKN3WTF6StringE
     1439__ZN7WebCore14StorageTracker17initializeTrackerERKN3WTF6StringEPNS_20StorageTrackerClientE
    14401440__ZN7WebCore14StorageTracker18diskUsageForOriginEPNS_14SecurityOriginE
    14411441__ZN7WebCore14StorageTracker32syncFileSystemAndTrackerDatabaseEv
  • trunk/Source/WebCore/storage/StorageAreaImpl.cpp

    r87597 r91931  
    3838#include "StorageMap.h"
    3939#include "StorageSyncManager.h"
     40#include "StorageTracker.h"
    4041
    4142namespace WebCore {
     
    5859    ASSERT(m_securityOrigin);
    5960    ASSERT(m_storageMap);
     61   
     62    // Accessing the shared global StorageTracker when a StorageArea is created
     63    // ensures that the tracker is properly initialized before anyone actually needs to use it.
     64    StorageTracker::tracker();
    6065}
    6166
  • trunk/Source/WebCore/storage/StorageTracker.cpp

    r86772 r91931  
    4949static StorageTracker* storageTracker = 0;
    5050
    51 void StorageTracker::initializeTracker(const String& storagePath)
     51void StorageTracker::initializeTracker(const String& storagePath, StorageTrackerClient* client)
    5252{
    5353    ASSERT(isMainThread());
     
    5757        storageTracker = new StorageTracker(storagePath);
    5858   
     59    storageTracker->m_client = client;
     60}
     61
     62void StorageTracker::internalInitialize()
     63{
     64    ASSERT(isMainThread());
     65
    5966    // Make sure text encoding maps have been built on the main thread, as the StorageTracker thread might try to do it there instead.
    6067    // FIXME (<rdar://problem/9127819>): Is there a more explicit way of doing this besides accessing the UTF8Encoding?
     
    6572    storageTracker->m_thread->start(); 
    6673    storageTracker->importOriginIdentifiers();
     74   
     75    m_isInitialized = true;
    6776}
    6877
     
    7180    if (!storageTracker)
    7281        storageTracker = new StorageTracker("");
     82    if (!storageTracker->m_isInitialized)
     83        storageTracker->internalInitialize();
    7384   
    7485    return *storageTracker;
     
    7687
    7788StorageTracker::StorageTracker(const String& storagePath)
    78     : m_client(0)
     89    : m_storageDirectoryPath(storagePath.threadsafeCopy())
     90    , m_client(0)
    7991    , m_thread(LocalStorageThread::create())
    8092    , m_isActive(false)
    81 {
    82     setStorageDirectoryPath(storagePath);
    83 }
    84 
    85 void StorageTracker::setStorageDirectoryPath(const String& path)
    86 {
    87     MutexLocker lockDatabase(m_databaseGuard);
    88     ASSERT(!m_database.isOpen());
    89    
    90     m_storageDirectoryPath = path.threadsafeCopy();
     93    , m_isInitialized(false)
     94{
    9195}
    9296
  • trunk/Source/WebCore/storage/StorageTracker.h

    r86205 r91931  
    4747    WTF_MAKE_FAST_ALLOCATED;
    4848public:
    49     static void initializeTracker(const String& storagePath);
     49    static void initializeTracker(const String& storagePath, StorageTrackerClient*);
    5050    static StorageTracker& tracker();
    51     static void scheduleTask(void*);
    5251
    53     void importOriginIdentifiers();
    5452    void setOriginDetails(const String& originIdentifier, const String& databaseFile);
    5553   
     
    7775private:
    7876    StorageTracker(const String& storagePath);
     77    static void scheduleTask(void*);
     78
     79    void internalInitialize();
    7980
    8081    String trackerDatabasePath();
    8182    void openTrackerDatabase(bool createIfDoesNotExist);
    8283
    83     void setStorageDirectoryPath(const String&);
    84 
     84    void importOriginIdentifiers();
     85   
    8586    void deleteTrackerFiles();
    8687    String databasePathForOrigin(const String& originIdentifier);
     
    112113   
    113114    bool m_isActive;
     115    bool m_isInitialized;
    114116};
    115117   
  • trunk/Source/WebKit/mac/ChangeLog

    r91903 r91931  
     12011-07-28  Brady Eidson  <beidson@apple.com>
     2
     3        <rdar://problem/9714337> and https://bugs.webkit.org/show_bug.cgi?id=65306
     4        WebKitInitializeStorageIfNecessary() can take awhile performing i/o, isn't necessary for every WebView
     5
     6        Reviewed by Maciej Stachowiak.
     7
     8        * Storage/WebStorageManager.mm:
     9        (WebKitInitializeStorageIfNecessary): Pass the client along in initializeTracker().
     10
    1112011-07-27  Mark Hahnenberg  <mhahnenberg@apple.com>
    212
  • trunk/Source/WebKit/mac/Storage/WebStorageManager.mm

    r86205 r91931  
    107107        return;
    108108   
    109     StorageTracker::initializeTracker(storageDirectoryPath());
    110    
    111     StorageTracker::tracker().setClient(WebStorageTrackerClient::sharedWebStorageTrackerClient());
    112    
     109    StorageTracker::initializeTracker(storageDirectoryPath(), WebStorageTrackerClient::sharedWebStorageTrackerClient());
     110       
    113111    initialized = YES;
    114112}
  • trunk/Source/WebKit2/ChangeLog

    r91903 r91931  
     12011-07-28  Brady Eidson  <beidson@apple.com>
     2
     3        <rdar://problem/9714337> and https://bugs.webkit.org/show_bug.cgi?id=65306
     4        WebKitInitializeStorageIfNecessary() can take awhile performing i/o, isn't necessary for every WebView
     5
     6        Reviewed by Maciej Stachowiak.
     7
     8        * WebProcess/WebProcess.cpp:
     9        (WebKit::WebProcess::initializeWebProcess): Pass a null client pointer in the new form of initializeTracker()
     10
    1112011-07-27  Mark Hahnenberg  <mhahnenberg@apple.com>
    212
  • trunk/Source/WebKit2/WebProcess/WebProcess.cpp

    r89706 r91931  
    193193
    194194#if ENABLE(DOM_STORAGE)
    195     StorageTracker::initializeTracker(parameters.localStorageDirectory);
     195    StorageTracker::initializeTracker(parameters.localStorageDirectory, 0);
    196196    m_localStorageDirectory = parameters.localStorageDirectory;
    197197#endif
Note: See TracChangeset for help on using the changeset viewer.