Change ResourceRequestBase::addHTTPHeaderFields to setHTTPHeaderFields instead
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Jun 2014 20:33:46 +0000 (20:33 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Jun 2014 20:33:46 +0000 (20:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=133925

Reviewed by Sam Weinig.

Source/WebCore:
* WebCore.exp.in:
* platform/network/ResourceRequestBase.cpp:
(WebCore::ResourceRequestBase::setHTTPHeaderFields):
(WebCore::ResourceRequestBase::addHTTPHeaderFields): Deleted.
* platform/network/ResourceRequestBase.h:
* plugins/PluginView.cpp:
(WebCore::PluginView::handlePost):
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::createRequest):

Source/WebKit2:
* PluginProcess/PluginControllerProxy.h:
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<ResourceRequest>::decode):
* WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
(WebKit::NPN_PostURL):
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::loadURL):
* WebProcess/Plugins/PluginView.h:

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

14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/platform/network/ResourceRequestBase.cpp
Source/WebCore/platform/network/ResourceRequestBase.h
Source/WebCore/plugins/PluginView.cpp
Source/WebCore/xml/XMLHttpRequest.cpp
Source/WebKit/win/WebMutableURLRequest.cpp
Source/WebKit/win/WebMutableURLRequest.h
Source/WebKit2/ChangeLog
Source/WebKit2/PluginProcess/PluginControllerProxy.h
Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
Source/WebKit2/WebProcess/Plugins/PluginView.cpp
Source/WebKit2/WebProcess/Plugins/PluginView.h

index 06db815..a30fbfa 100644 (file)
@@ -1,3 +1,20 @@
+2014-06-15  Anders Carlsson  <andersca@apple.com>
+
+        Change ResourceRequestBase::addHTTPHeaderFields to setHTTPHeaderFields instead
+        https://bugs.webkit.org/show_bug.cgi?id=133925
+
+        Reviewed by Sam Weinig.
+
+        * WebCore.exp.in:
+        * platform/network/ResourceRequestBase.cpp:
+        (WebCore::ResourceRequestBase::setHTTPHeaderFields):
+        (WebCore::ResourceRequestBase::addHTTPHeaderFields): Deleted.
+        * platform/network/ResourceRequestBase.h:
+        * plugins/PluginView.cpp:
+        (WebCore::PluginView::handlePost):
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::createRequest):
+
 2014-06-16  Jeongeun Kim  <je_julie.kim@samsung.com>
 
         Use references instead of pointers to RenderBlock in RenderObject::enclosingBox().
index 6fa701a..bb2d4b8 100644 (file)
@@ -818,7 +818,7 @@ __ZN7WebCore19MediaSessionManager9addClientEPNS_25MediaSessionManagerClientE
 __ZN7WebCore19ResourceRequestBase11setHTTPBodyEN3WTF10PassRefPtrINS_8FormDataEEE
 __ZN7WebCore19ResourceRequestBase13setHTTPMethodERKN3WTF6StringE
 __ZN7WebCore19ResourceRequestBase15setHTTPReferrerERKN3WTF6StringE
-__ZN7WebCore19ResourceRequestBase19addHTTPHeaderFieldsERKNS_13HTTPHeaderMapE
+__ZN7WebCore19ResourceRequestBase19setHTTPHeaderFieldsENS_13HTTPHeaderMapE
 __ZN7WebCore19ResourceRequestBase22defaultTimeoutIntervalEv
 __ZN7WebCore19ResourceRequestBase24s_defaultTimeoutIntervalE
 __ZN7WebCore19ResourceRequestBase25setDefaultTimeoutIntervalEd
index 75053a7..5286db5 100644 (file)
@@ -463,10 +463,14 @@ void ResourceRequestBase::addHTTPHeaderField(const AtomicString& name, const Str
         m_platformRequestUpdated = false;
 }
 
-void ResourceRequestBase::addHTTPHeaderFields(const HTTPHeaderMap& headerFields)
+void ResourceRequestBase::setHTTPHeaderFields(HTTPHeaderMap headerFields)
 {
-    for (const auto& header : headerFields)
-        addHTTPHeaderField(header.key, header.value);
+    updateResourceRequest();
+
+    m_httpHeaderFields = std::move(headerFields);
+
+    if (url().protocolIsInHTTPFamily())
+        m_platformRequestUpdated = false;
 }
 
 bool equalIgnoringHeaderFields(const ResourceRequestBase& a, const ResourceRequestBase& b)
index 7b01904..a4b236d 100644 (file)
@@ -80,16 +80,18 @@ namespace WebCore {
         void setHTTPMethod(const String& httpMethod);
         
         const HTTPHeaderMap& httpHeaderFields() const;
+        void setHTTPHeaderFields(HTTPHeaderMap);
+
         String httpHeaderField(const AtomicString& name) const;
         String httpHeaderField(HTTPHeaderName) const;
         void setHTTPHeaderField(const AtomicString& name, const String& value);
         void setHTTPHeaderField(HTTPHeaderName, const String& value);
         void addHTTPHeaderField(const AtomicString& name, const String& value);
-        void addHTTPHeaderFields(const HTTPHeaderMap& headerFields);
 
         // Instead of passing a string literal to any of these functions, just use a HTTPHeaderName instead.
         template<size_t length> String httpHeaderField(const char (&)[length]) const = delete;
         template<size_t length> void setHTTPHeaderField(const char (&)[length], const String&) = delete;
+        template<size_t length> void addHTTPHeaderField(const char (&)[length], const String&) = delete;
 
         void clearHTTPAuthorization();
 
index 72380fc..d73c66c 100644 (file)
@@ -1176,7 +1176,7 @@ NPError PluginView::handlePost(const char* url, const char* target, uint32_t len
 
     frameLoadRequest.resourceRequest().setHTTPMethod("POST");
     frameLoadRequest.resourceRequest().setURL(makeURL(m_parentFrame->document()->baseURL(), url));
-    frameLoadRequest.resourceRequest().addHTTPHeaderFields(headerFields);
+    frameLoadRequest.resourceRequest().setHTTPHeaderFields(std::move(headerFields));
     frameLoadRequest.resourceRequest().setHTTPBody(FormData::create(postData, postDataLength));
     frameLoadRequest.setFrameName(target);
 
index d64ba95..416e866 100644 (file)
@@ -753,7 +753,7 @@ void XMLHttpRequest::createRequest(ExceptionCode& ec)
     }
 
     if (!m_requestHeaders.isEmpty())
-        request.addHTTPHeaderFields(m_requestHeaders);
+        request.setHTTPHeaderFields(m_requestHeaders);
 
     ThreadableLoaderOptions options;
     options.sendLoadCallbacks = SendCallbacks;
index 89d3c85..3b5a22c 100644 (file)
@@ -411,11 +411,6 @@ const PassRefPtr<FormData> WebMutableURLRequest::formData() const
     return m_request.httpBody();
 }
 
-void WebMutableURLRequest::addHTTPHeaderFields(const HTTPHeaderMap& headerFields)
-{
-    m_request.addHTTPHeaderFields(headerFields);
-}
-
 const HTTPHeaderMap& WebMutableURLRequest::httpHeaderFields() const
 {
     return m_request.httpHeaderFields();
index dee9655..8e36c71 100644 (file)
@@ -164,7 +164,6 @@ public:
     void setFormData(const PassRefPtr<WebCore::FormData> data);
     const PassRefPtr<WebCore::FormData> formData() const;
     
-    void addHTTPHeaderFields(const WebCore::HTTPHeaderMap& headerFields);
     const WebCore::HTTPHeaderMap& httpHeaderFields() const;
 
     const WebCore::ResourceRequest& resourceRequest() const;
index a7bb043..1a9b58c 100644 (file)
@@ -1,3 +1,19 @@
+2014-06-15  Anders Carlsson  <andersca@apple.com>
+
+        Change ResourceRequestBase::addHTTPHeaderFields to setHTTPHeaderFields instead
+        https://bugs.webkit.org/show_bug.cgi?id=133925
+
+        Reviewed by Sam Weinig.
+
+        * PluginProcess/PluginControllerProxy.h:
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<ResourceRequest>::decode):
+        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
+        (WebKit::NPN_PostURL):
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::loadURL):
+        * WebProcess/Plugins/PluginView.h:
+
 2014-06-16  Anders Carlsson  <andersca@apple.com>
 
         Add HTTPHeaderName overloads on ResourceResponseBase
index 65d902b..d33e557 100644 (file)
@@ -82,19 +82,19 @@ private:
     void paint();
 
     // PluginController
-    virtual bool isPluginVisible();
-    virtual void invalidate(const WebCore::IntRect&);
-    virtual String userAgent();
-    virtual void loadURL(uint64_t requestID, const String& method, const String& urlString, const String& target, const WebCore::HTTPHeaderMap& headerFields, const Vector<uint8_t>& httpBody, bool allowPopups);
-    virtual void cancelStreamLoad(uint64_t streamID);
-    virtual void cancelManualStreamLoad();
-    virtual NPObject* windowScriptNPObject();
-    virtual NPObject* pluginElementNPObject();
-    virtual bool evaluate(NPObject*, const String& scriptString, NPVariant* result, bool allowPopups);
-    virtual void setStatusbarText(const String&);
-    virtual bool isAcceleratedCompositingEnabled();
-    virtual void pluginProcessCrashed();
-    virtual void willSendEventToPlugin();
+    virtual bool isPluginVisible() override;
+    virtual void invalidate(const WebCore::IntRect&) override;
+    virtual String userAgent() override;
+    virtual void loadURL(uint64_t requestID, const String& method, const String& urlString, const String& target, const WebCore::HTTPHeaderMap& headerFields, const Vector<uint8_t>& httpBody, bool allowPopups) override;
+    virtual void cancelStreamLoad(uint64_t streamID) override;
+    virtual void cancelManualStreamLoad() override;
+    virtual NPObject* windowScriptNPObject() override;
+    virtual NPObject* pluginElementNPObject() override;
+    virtual bool evaluate(NPObject*, const String& scriptString, NPVariant* result, bool allowPopups) override;
+    virtual void setStatusbarText(const String&) override;
+    virtual bool isAcceleratedCompositingEnabled() override;
+    virtual void pluginProcessCrashed() override;
+    virtual void willSendEventToPlugin() override;
     virtual void didInitializePlugin() override;
     virtual void didFailToInitializePlugin() override;
 
@@ -105,17 +105,17 @@ private:
     virtual void openPluginPreferencePane() override;
 #endif
 
-    virtual float contentsScaleFactor();
-    virtual String proxiesForURL(const String&);
-    virtual String cookiesForURL(const String&);
-    virtual void setCookiesForURL(const String& urlString, const String& cookieString);
-    virtual bool isPrivateBrowsingEnabled();
-    virtual bool getAuthenticationInfo(const WebCore::ProtectionSpace&, String& username, String& password);
-    virtual void protectPluginFromDestruction();
-    virtual void unprotectPluginFromDestruction();
+    virtual float contentsScaleFactor() override;
+    virtual String proxiesForURL(const String&) override;
+    virtual String cookiesForURL(const String&) override;
+    virtual void setCookiesForURL(const String& urlString, const String& cookieString) override;
+    virtual bool isPrivateBrowsingEnabled() override;
+    virtual bool getAuthenticationInfo(const WebCore::ProtectionSpace&, String& username, String& password) override;
+    virtual void protectPluginFromDestruction() override;
+    virtual void unprotectPluginFromDestruction() override;
 #if PLUGIN_ARCHITECTURE(X11)
-    virtual uint64_t createPluginContainer();
-    virtual void windowedPluginGeometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, uint64_t windowID);
+    virtual uint64_t createPluginContainer() override;
+    virtual void windowedPluginGeometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, uint64_t windowID) override;
 #endif
     
     // Message handlers.
index 7f7913c..8a1e3b3 100644 (file)
@@ -699,7 +699,7 @@ bool ArgumentCoder<ResourceRequest>::decode(ArgumentDecoder& decoder, ResourceRe
         HTTPHeaderMap headers;
         if (!decoder.decode(headers))
             return false;
-        request.addHTTPHeaderFields(headers);
+        request.setHTTPHeaderFields(std::move(headers));
 
         bool hasHTTPBody;
         if (!decoder.decode(hasHTTPBody))
index 5ab0685..4ac1f48 100644 (file)
@@ -299,7 +299,7 @@ static NPError NPN_PostURL(NPP npp, const char* url, const char* target, uint32_
         return error;
 
     RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
-    plugin->loadURL("POST", makeURLString(url), target, headerFields, postData, false, 0);
+    plugin->loadURL("POST", makeURLString(url), target, std::move(headerFields), postData, false, 0);
     return NPERR_NO_ERROR;
 }
 
index 20230d2..a4e1ae0 100644 (file)
@@ -1330,13 +1330,12 @@ String PluginView::userAgent()
     return frame->loader().client().userAgent(URL());
 }
 
-void PluginView::loadURL(uint64_t requestID, const String& method, const String& urlString, const String& target, 
-                         const HTTPHeaderMap& headerFields, const Vector<uint8_t>& httpBody, bool allowPopups)
+void PluginView::loadURL(uint64_t requestID, const String& method, const String& urlString, const String& target, const HTTPHeaderMap& headerFields, const Vector<uint8_t>& httpBody, bool allowPopups)
 {
     FrameLoadRequest frameLoadRequest(m_pluginElement->document().securityOrigin());
     frameLoadRequest.resourceRequest().setHTTPMethod(method);
     frameLoadRequest.resourceRequest().setURL(m_pluginElement->document().completeURL(urlString));
-    frameLoadRequest.resourceRequest().addHTTPHeaderFields(headerFields);
+    frameLoadRequest.resourceRequest().setHTTPHeaderFields(headerFields);
     frameLoadRequest.resourceRequest().setHTTPBody(FormData::create(httpBody.data(), httpBody.size()));
     frameLoadRequest.setFrameName(target);
 
index cb2afe6..8166ae3 100644 (file)
@@ -147,84 +147,83 @@ private:
 
     // WebCore::PluginViewBase
 #if PLATFORM(COCOA)
-    virtual PlatformLayer* platformLayer() const;
+    virtual PlatformLayer* platformLayer() const override;
 #endif
-    virtual JSC::JSObject* scriptObject(JSC::JSGlobalObject*);
-    virtual void storageBlockingStateChanged();
-    virtual void privateBrowsingStateChanged(bool);
-    virtual bool getFormValue(String&);
-    virtual bool scroll(WebCore::ScrollDirection, WebCore::ScrollGranularity);
-    virtual WebCore::Scrollbar* horizontalScrollbar();
-    virtual WebCore::Scrollbar* verticalScrollbar();
-    virtual bool wantsWheelEvents();
+    virtual JSC::JSObject* scriptObject(JSC::JSGlobalObject*) override;
+    virtual void storageBlockingStateChanged() override;
+    virtual void privateBrowsingStateChanged(bool) override;
+    virtual bool getFormValue(String&) override;
+    virtual bool scroll(WebCore::ScrollDirection, WebCore::ScrollGranularity) override;
+    virtual WebCore::Scrollbar* horizontalScrollbar() override;
+    virtual WebCore::Scrollbar* verticalScrollbar() override;
+    virtual bool wantsWheelEvents() override;
     virtual bool shouldAlwaysAutoStart() const override;
     virtual void beginSnapshottingRunningPlugin() override;
     virtual bool shouldAllowNavigationFromDrags() const override;
     virtual bool shouldNotAddLayer() const override;
 
     // WebCore::Widget
-    virtual void setFrameRect(const WebCore::IntRect&);
-    virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect&);
-    virtual void invalidateRect(const WebCore::IntRect&);
-    virtual void setFocus(bool);
-    virtual void frameRectsChanged();
-    virtual void setParent(WebCore::ScrollView*);
-    virtual void handleEvent(WebCore::Event*);
-    virtual void notifyWidget(WebCore::WidgetNotification);
-    virtual void show();
-    virtual void hide();
-    virtual bool transformsAffectFrameRect();
+    virtual void setFrameRect(const WebCore::IntRect&) override;
+    virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect&) override;
+    virtual void invalidateRect(const WebCore::IntRect&) override;
+    virtual void setFocus(bool) override;
+    virtual void frameRectsChanged() override;
+    virtual void setParent(WebCore::ScrollView*) override;
+    virtual void handleEvent(WebCore::Event*) override;
+    virtual void notifyWidget(WebCore::WidgetNotification) override;
+    virtual void show() override;
+    virtual void hide() override;
+    virtual bool transformsAffectFrameRect() override;
     virtual void clipRectChanged() override;
 
     // WebCore::MediaCanStartListener
-    virtual void mediaCanStart();
+    virtual void mediaCanStart() override;
 
     // PluginController
-    virtual bool isPluginVisible();
-    virtual void invalidate(const WebCore::IntRect&);
-    virtual String userAgent();
-    virtual void loadURL(uint64_t requestID, const String& method, const String& urlString, const String& target, 
-                         const WebCore::HTTPHeaderMap& headerFields, const Vector<uint8_t>& httpBody, bool allowPopups);
-    virtual void cancelStreamLoad(uint64_t streamID);
-    virtual void cancelManualStreamLoad();
+    virtual bool isPluginVisible() override;
+    virtual void invalidate(const WebCore::IntRect&) override;
+    virtual String userAgent() override;
+    virtual void loadURL(uint64_t requestID, const String& method, const String& urlString, const String& target, const WebCore::HTTPHeaderMap& headerFields, const Vector<uint8_t>& httpBody, bool allowPopups) override;
+    virtual void cancelStreamLoad(uint64_t streamID) override;
+    virtual void cancelManualStreamLoad() override;
 #if ENABLE(NETSCAPE_PLUGIN_API)
-    virtual NPObject* windowScriptNPObject();
-    virtual NPObject* pluginElementNPObject();
-    virtual bool evaluate(NPObject*, const String&scriptString, NPVariant* result, bool allowPopups);
+    virtual NPObject* windowScriptNPObject() override;
+    virtual NPObject* pluginElementNPObject() override;
+    virtual bool evaluate(NPObject*, const String& scriptString, NPVariant* result, bool allowPopups) override;
 #endif
-    virtual void setStatusbarText(const String&);
-    virtual bool isAcceleratedCompositingEnabled();
-    virtual void pluginProcessCrashed();
-    virtual void willSendEventToPlugin();
+    virtual void setStatusbarText(const String&) override;
+    virtual bool isAcceleratedCompositingEnabled() override;
+    virtual void pluginProcessCrashed() override;
+    virtual void willSendEventToPlugin() override;
 #if PLATFORM(COCOA)
-    virtual void pluginFocusOrWindowFocusChanged(bool pluginHasFocusAndWindowHasFocus);
-    virtual void setComplexTextInputState(PluginComplexTextInputState);
-    virtual mach_port_t compositingRenderServerPort();
+    virtual void pluginFocusOrWindowFocusChanged(bool pluginHasFocusAndWindowHasFocus) override;
+    virtual void setComplexTextInputState(PluginComplexTextInputState) override;
+    virtual mach_port_t compositingRenderServerPort() override;
     virtual void openPluginPreferencePane() override;
 #endif
-    virtual float contentsScaleFactor();
-    virtual String proxiesForURL(const String&);
-    virtual String cookiesForURL(const String&);
-    virtual void setCookiesForURL(const String& urlString, const String& cookieString);
-    virtual bool getAuthenticationInfo(const WebCore::ProtectionSpace&, String& username, String& password);
-    virtual bool isPrivateBrowsingEnabled();
-    virtual bool asynchronousPluginInitializationEnabled() const;
-    virtual bool asynchronousPluginInitializationEnabledForAllPlugins() const;
-    virtual bool artificialPluginInitializationDelayEnabled() const;
-    virtual void protectPluginFromDestruction();
-    virtual void unprotectPluginFromDestruction();
+    virtual float contentsScaleFactor() override;
+    virtual String proxiesForURL(const String&) override;
+    virtual String cookiesForURL(const String&) override;
+    virtual void setCookiesForURL(const String& urlString, const String& cookieString) override;
+    virtual bool getAuthenticationInfo(const WebCore::ProtectionSpace&, String& username, String& password) override;
+    virtual bool isPrivateBrowsingEnabled() override;
+    virtual bool asynchronousPluginInitializationEnabled() const override;
+    virtual bool asynchronousPluginInitializationEnabledForAllPlugins() const override;
+    virtual bool artificialPluginInitializationDelayEnabled() const override;
+    virtual void protectPluginFromDestruction() override;
+    virtual void unprotectPluginFromDestruction() override;
 #if PLUGIN_ARCHITECTURE(X11)
-    virtual uint64_t createPluginContainer();
-    virtual void windowedPluginGeometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, uint64_t windowID);
+    virtual uint64_t createPluginContainer() override;
+    virtual void windowedPluginGeometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, uint64_t windowID) override;
 #endif
 
-    virtual void didInitializePlugin();
-    virtual void didFailToInitializePlugin();
+    virtual void didInitializePlugin() override;
+    virtual void didFailToInitializePlugin() override;
     void destroyPluginAndReset();
 
     // WebFrame::LoadListener
-    virtual void didFinishLoad(WebFrame*);
-    virtual void didFailLoad(WebFrame*, bool wasCancelled);
+    virtual void didFinishLoad(WebFrame*) override;
+    virtual void didFailLoad(WebFrame*, bool wasCancelled) override;
 
     std::unique_ptr<WebEvent> createWebEvent(WebCore::MouseEvent*) const;