Title: [91931] trunk/Source
Revision
91931
Author
[email protected]
Date
2011-07-28 08:32:40 -0700 (Thu, 28 Jul 2011)

Log 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()

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (91930 => 91931)


--- trunk/Source/WebCore/ChangeLog	2011-07-28 15:25:03 UTC (rev 91930)
+++ trunk/Source/WebCore/ChangeLog	2011-07-28 15:32:40 UTC (rev 91931)
@@ -1,3 +1,28 @@
+2011-07-28  Brady Eidson  <[email protected]>
+
+        <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
+
+        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:
+
 2011-07-28  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Copy and paste is broken in WebKit2

Modified: trunk/Source/WebCore/WebCore.exp.in (91930 => 91931)


--- trunk/Source/WebCore/WebCore.exp.in	2011-07-28 15:25:03 UTC (rev 91930)
+++ trunk/Source/WebCore/WebCore.exp.in	2011-07-28 15:32:40 UTC (rev 91931)
@@ -1436,7 +1436,7 @@
 __ZN7WebCore14StorageTracker12deleteOriginEPNS_14SecurityOriginE
 __ZN7WebCore14StorageTracker16deleteAllOriginsEv
 __ZN7WebCore14StorageTracker16syncLocalStorageEv
-__ZN7WebCore14StorageTracker17initializeTrackerERKN3WTF6StringE
+__ZN7WebCore14StorageTracker17initializeTrackerERKN3WTF6StringEPNS_20StorageTrackerClientE
 __ZN7WebCore14StorageTracker18diskUsageForOriginEPNS_14SecurityOriginE
 __ZN7WebCore14StorageTracker32syncFileSystemAndTrackerDatabaseEv
 #endif

Modified: trunk/Source/WebCore/storage/StorageAreaImpl.cpp (91930 => 91931)


--- trunk/Source/WebCore/storage/StorageAreaImpl.cpp	2011-07-28 15:25:03 UTC (rev 91930)
+++ trunk/Source/WebCore/storage/StorageAreaImpl.cpp	2011-07-28 15:32:40 UTC (rev 91931)
@@ -37,6 +37,7 @@
 #include "StorageEventDispatcher.h"
 #include "StorageMap.h"
 #include "StorageSyncManager.h"
+#include "StorageTracker.h"
 
 namespace WebCore {
 
@@ -57,6 +58,10 @@
     ASSERT(isMainThread());
     ASSERT(m_securityOrigin);
     ASSERT(m_storageMap);
+    
+    // Accessing the shared global StorageTracker when a StorageArea is created 
+    // ensures that the tracker is properly initialized before anyone actually needs to use it.
+    StorageTracker::tracker();
 }
 
 PassRefPtr<StorageAreaImpl> StorageAreaImpl::create(StorageType storageType, PassRefPtr<SecurityOrigin> origin, PassRefPtr<StorageSyncManager> syncManager, unsigned quota)

Modified: trunk/Source/WebCore/storage/StorageTracker.cpp (91930 => 91931)


--- trunk/Source/WebCore/storage/StorageTracker.cpp	2011-07-28 15:25:03 UTC (rev 91930)
+++ trunk/Source/WebCore/storage/StorageTracker.cpp	2011-07-28 15:32:40 UTC (rev 91931)
@@ -48,7 +48,7 @@
 
 static StorageTracker* storageTracker = 0;
 
-void StorageTracker::initializeTracker(const String& storagePath)
+void StorageTracker::initializeTracker(const String& storagePath, StorageTrackerClient* client)
 {
     ASSERT(isMainThread());
     ASSERT(!storageTracker);
@@ -56,6 +56,13 @@
     if (!storageTracker)
         storageTracker = new StorageTracker(storagePath);
     
+    storageTracker->m_client = client;
+}
+
+void StorageTracker::internalInitialize()
+{
+    ASSERT(isMainThread());
+
     // Make sure text encoding maps have been built on the main thread, as the StorageTracker thread might try to do it there instead.
     // FIXME (<rdar://problem/9127819>): Is there a more explicit way of doing this besides accessing the UTF8Encoding?
     UTF8Encoding();
@@ -64,32 +71,29 @@
     storageTracker->setIsActive(true);
     storageTracker->m_thread->start();  
     storageTracker->importOriginIdentifiers();
+    
+    m_isInitialized = true;
 }
 
 StorageTracker& StorageTracker::tracker()
 {
     if (!storageTracker)
         storageTracker = new StorageTracker("");
+    if (!storageTracker->m_isInitialized)
+        storageTracker->internalInitialize();
     
     return *storageTracker;
 }
 
 StorageTracker::StorageTracker(const String& storagePath)
-    : m_client(0)
+    : m_storageDirectoryPath(storagePath.threadsafeCopy())
+    , m_client(0)
     , m_thread(LocalStorageThread::create())
     , m_isActive(false)
+    , m_isInitialized(false)
 {
-    setStorageDirectoryPath(storagePath);
 }
 
-void StorageTracker::setStorageDirectoryPath(const String& path)
-{
-    MutexLocker lockDatabase(m_databaseGuard);
-    ASSERT(!m_database.isOpen());
-    
-    m_storageDirectoryPath = path.threadsafeCopy();
-}
-
 String StorageTracker::trackerDatabasePath()
 {
     ASSERT(!m_databaseGuard.tryLock());

Modified: trunk/Source/WebCore/storage/StorageTracker.h (91930 => 91931)


--- trunk/Source/WebCore/storage/StorageTracker.h	2011-07-28 15:25:03 UTC (rev 91930)
+++ trunk/Source/WebCore/storage/StorageTracker.h	2011-07-28 15:32:40 UTC (rev 91931)
@@ -46,11 +46,9 @@
     WTF_MAKE_NONCOPYABLE(StorageTracker);
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    static void initializeTracker(const String& storagePath);
+    static void initializeTracker(const String& storagePath, StorageTrackerClient*);
     static StorageTracker& tracker();
-    static void scheduleTask(void*);
 
-    void importOriginIdentifiers();
     void setOriginDetails(const String& originIdentifier, const String& databaseFile);
     
     void deleteAllOrigins();
@@ -76,12 +74,15 @@
 
 private:
     StorageTracker(const String& storagePath);
+    static void scheduleTask(void*);
 
+    void internalInitialize();
+
     String trackerDatabasePath();
     void openTrackerDatabase(bool createIfDoesNotExist);
 
-    void setStorageDirectoryPath(const String&);
-
+    void importOriginIdentifiers();
+    
     void deleteTrackerFiles();
     String databasePathForOrigin(const String& originIdentifier);
 
@@ -111,6 +112,7 @@
     OwnPtr<LocalStorageThread> m_thread;
     
     bool m_isActive;
+    bool m_isInitialized;
 };
     
 } // namespace WebCore

Modified: trunk/Source/WebKit/mac/ChangeLog (91930 => 91931)


--- trunk/Source/WebKit/mac/ChangeLog	2011-07-28 15:25:03 UTC (rev 91930)
+++ trunk/Source/WebKit/mac/ChangeLog	2011-07-28 15:32:40 UTC (rev 91931)
@@ -1,3 +1,13 @@
+2011-07-28  Brady Eidson  <[email protected]>
+
+        <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
+
+        Reviewed by Maciej Stachowiak.
+
+        * Storage/WebStorageManager.mm:
+        (WebKitInitializeStorageIfNecessary): Pass the client along in initializeTracker().
+
 2011-07-27  Mark Hahnenberg  <[email protected]>
 
         Remove operator new from JSCell

Modified: trunk/Source/WebKit/mac/Storage/WebStorageManager.mm (91930 => 91931)


--- trunk/Source/WebKit/mac/Storage/WebStorageManager.mm	2011-07-28 15:25:03 UTC (rev 91930)
+++ trunk/Source/WebKit/mac/Storage/WebStorageManager.mm	2011-07-28 15:32:40 UTC (rev 91931)
@@ -106,10 +106,8 @@
     if (initialized)
         return;
     
-    StorageTracker::initializeTracker(storageDirectoryPath());
-    
-    StorageTracker::tracker().setClient(WebStorageTrackerClient::sharedWebStorageTrackerClient());
-    
+    StorageTracker::initializeTracker(storageDirectoryPath(), WebStorageTrackerClient::sharedWebStorageTrackerClient());
+        
     initialized = YES;
 }
 

Modified: trunk/Source/WebKit2/ChangeLog (91930 => 91931)


--- trunk/Source/WebKit2/ChangeLog	2011-07-28 15:25:03 UTC (rev 91930)
+++ trunk/Source/WebKit2/ChangeLog	2011-07-28 15:32:40 UTC (rev 91931)
@@ -1,3 +1,13 @@
+2011-07-28  Brady Eidson  <[email protected]>
+
+        <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
+
+        Reviewed by Maciej Stachowiak.
+
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::initializeWebProcess): Pass a null client pointer in the new form of initializeTracker()
+
 2011-07-27  Mark Hahnenberg  <[email protected]>
 
         Remove operator new from JSCell

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (91930 => 91931)


--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2011-07-28 15:25:03 UTC (rev 91930)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2011-07-28 15:32:40 UTC (rev 91931)
@@ -192,7 +192,7 @@
 #endif
 
 #if ENABLE(DOM_STORAGE)
-    StorageTracker::initializeTracker(parameters.localStorageDirectory);
+    StorageTracker::initializeTracker(parameters.localStorageDirectory, 0);
     m_localStorageDirectory = parameters.localStorageDirectory;
 #endif
     
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to