2011-02-22 Anders Carlsson <andersca@apple.com>
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Feb 2011 22:29:58 +0000 (22:29 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Feb 2011 22:29:58 +0000 (22:29 +0000)
        Reviewed by Darin Adler.

        Get rid of WebProcessManager::getAllWebProcessContexts
        https://bugs.webkit.org/show_bug.cgi?id=55000

        * Shared/WebURLRequest.cpp:
        (WebKit::WebURLRequest::setDefaultTimeoutInterval):
        Call WebContext::allContexts instead.

        * UIProcess/WebContext.cpp:
        * UIProcess/WebContext.h:
        Add a vector of WebContext objects. Update it when creating and destroying contexts.

        * UIProcess/WebProcessManager.cpp:
        * UIProcess/WebProcessManager.h:
        Remove WebProcessManager::getAllWebProcessContexts.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@79362 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebURLRequest.cpp
Source/WebKit2/UIProcess/WebContext.cpp
Source/WebKit2/UIProcess/WebContext.h
Source/WebKit2/UIProcess/WebProcessManager.cpp
Source/WebKit2/UIProcess/WebProcessManager.h

index 5dc499e..e3a7f1f 100644 (file)
@@ -1,3 +1,22 @@
+2011-02-22  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Darin Adler.
+
+        Get rid of WebProcessManager::getAllWebProcessContexts
+        https://bugs.webkit.org/show_bug.cgi?id=55000
+
+        * Shared/WebURLRequest.cpp:
+        (WebKit::WebURLRequest::setDefaultTimeoutInterval):
+        Call WebContext::allContexts instead.
+
+        * UIProcess/WebContext.cpp:
+        * UIProcess/WebContext.h:
+        Add a vector of WebContext objects. Update it when creating and destroying contexts.
+
+        * UIProcess/WebProcessManager.cpp:
+        * UIProcess/WebProcessManager.h:
+        Remove WebProcessManager::getAllWebProcessContexts.
+
 2011-02-22  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Anders Carlsson.
index 0525ea7..0e64184 100644 (file)
@@ -32,13 +32,13 @@ double WebURLRequest::defaultTimeoutInterval()
     return ResourceRequest::defaultTimeoutInterval();
 }
 
+// FIXME: This function should really be on WebContext.
 void WebURLRequest::setDefaultTimeoutInterval(double timeoutInterval)
 {
     ResourceRequest::setDefaultTimeoutInterval(timeoutInterval);
-    
-    Vector<WebContext*> contexts;
-    WebProcessManager::shared().getAllWebProcessContexts(contexts);
-    for (unsigned i = 0; i < contexts.size(); ++i)
+
+    const Vector<WebContext*>& contexts = WebContext::allContexts();
+    for (size_t i = 0; i < contexts.size(); ++i)
         contexts[i]->setDefaultRequestTimeoutInterval(timeoutInterval);
 }
 
index 3089e17..17d8fd1 100644 (file)
@@ -86,7 +86,19 @@ PassRefPtr<WebContext> WebContext::create(const String& injectedBundlePath)
     RunLoop::initializeMainRunLoop();
     return adoptRef(new WebContext(ProcessModelSecondaryProcess, injectedBundlePath));
 }
-    
+
+static Vector<WebContext*>& contexts()
+{
+    DEFINE_STATIC_LOCAL(Vector<WebContext*>, contexts, ());
+
+    return contexts;
+}
+
+const Vector<WebContext*>& WebContext::allContexts()
+{
+    return contexts();
+}
+
 WebContext::WebContext(ProcessModel processModel, const String& injectedBundlePath)
     : m_processModel(processModel)
     , m_defaultPageGroup(WebPageGroup::create())
@@ -106,6 +118,8 @@ WebContext::WebContext(ProcessModel processModel, const String& injectedBundlePa
     , m_shouldPaintNativeControls(true)
 #endif
 {
+    contexts().append(this);
+
     addLanguageChangeObserver(this, languageChanged);
 
     WebCore::InitializeLoggingChannelsIfNecessary();
@@ -117,6 +131,9 @@ WebContext::WebContext(ProcessModel processModel, const String& injectedBundlePa
 
 WebContext::~WebContext()
 {
+    ASSERT(contexts().find(this) != notFound);
+    contexts().remove(contexts().find(this));
+
     removeLanguageChangeObserver(this);
 
     WebProcessManager::shared().contextWasDestroyed(this);
index ff590f2..6485c5c 100644 (file)
@@ -62,6 +62,8 @@ public:
     static PassRefPtr<WebContext> create(const String& injectedBundlePath);
     virtual ~WebContext();
 
+    static const Vector<WebContext*>& allContexts();
+
     void initializeInjectedBundleClient(const WKContextInjectedBundleClient*);
     void initializeHistoryClient(const WKContextHistoryClient*);
     void initializeDownloadClient(const WKContextDownloadClient*);
index 0d44f8b..80e3c2d 100644 (file)
@@ -69,11 +69,6 @@ WebProcessProxy* WebProcessManager::getWebProcess(WebContext* context)
     return 0;
 }
 
-void WebProcessManager::getAllWebProcessContexts(Vector<WebContext*>& contexts)
-{
-    copyKeysToVector(m_processMap, contexts);
-}
-
 void WebProcessManager::processDidClose(WebProcessProxy* process, WebContext* context)
 {
     if (process == m_sharedProcess) {
index a636e5c..320829e 100644 (file)
@@ -41,8 +41,6 @@ public:
 
     void contextWasDestroyed(WebContext*);
 
-    void getAllWebProcessContexts(Vector<WebContext*>&);
-
 private:
     WebProcessManager();