Diff
Modified: trunk/Source/WebKit2/ChangeLog (177748 => 177749)
--- trunk/Source/WebKit2/ChangeLog 2014-12-26 19:26:53 UTC (rev 177748)
+++ trunk/Source/WebKit2/ChangeLog 2014-12-26 20:24:34 UTC (rev 177749)
@@ -1,5 +1,29 @@
2014-12-26 Anders Carlsson <[email protected]>
+ Move handle encoding functions to their respective implementation files
+ https://bugs.webkit.org/show_bug.cgi?id=139957
+
+ Reviewed by Dan Bernstein.
+
+ * Shared/API/APIFrameHandle.cpp:
+ (API::FrameHandle::encode):
+ (API::FrameHandle::decode):
+ * Shared/API/APIFrameHandle.h:
+ * Shared/API/APIPageGroupHandle.cpp:
+ (API::PageGroupHandle::PageGroupHandle):
+ (API::PageGroupHandle::encode):
+ (API::PageGroupHandle::decode):
+ * Shared/API/APIPageGroupHandle.h:
+ * Shared/API/APIPageHandle.cpp:
+ (API::PageHandle::encode):
+ (API::PageHandle::decode):
+ * Shared/API/APIPageHandle.h:
+ * Shared/UserData.cpp:
+ (WebKit::UserData::encode):
+ (WebKit::UserData::decode):
+
+2014-12-26 Anders Carlsson <[email protected]>
+
Add the notion of auto-converting page and frame handles
https://bugs.webkit.org/show_bug.cgi?id=139954
Modified: trunk/Source/WebKit2/Shared/API/APIFrameHandle.cpp (177748 => 177749)
--- trunk/Source/WebKit2/Shared/API/APIFrameHandle.cpp 2014-12-26 19:26:53 UTC (rev 177748)
+++ trunk/Source/WebKit2/Shared/API/APIFrameHandle.cpp 2014-12-26 20:24:34 UTC (rev 177749)
@@ -26,6 +26,9 @@
#include "config.h"
#include "APIFrameHandle.h"
+#include "ArgumentDecoder.h"
+#include "ArgumentEncoder.h"
+
namespace API {
Ref<FrameHandle> FrameHandle::create(uint64_t frameID)
@@ -48,4 +51,24 @@
{
}
+void FrameHandle::encode(IPC::ArgumentEncoder& encoder) const
+{
+ encoder << m_frameID;
+ encoder << m_isAutoconverting;
+}
+
+bool FrameHandle::decode(IPC::ArgumentDecoder& decoder, RefPtr<Object>& result)
+{
+ uint64_t frameID;
+ if (!decoder.decode(frameID))
+ return false;
+
+ bool isAutoconverting;
+ if (!decoder.decode(isAutoconverting))
+ return false;
+
+ result = isAutoconverting ? createAutoconverting(frameID) : create(frameID);
+ return true;
+}
+
} // namespace API
Modified: trunk/Source/WebKit2/Shared/API/APIFrameHandle.h (177748 => 177749)
--- trunk/Source/WebKit2/Shared/API/APIFrameHandle.h 2014-12-26 19:26:53 UTC (rev 177748)
+++ trunk/Source/WebKit2/Shared/API/APIFrameHandle.h 2014-12-26 20:24:34 UTC (rev 177749)
@@ -29,19 +29,27 @@
#include "APIObject.h"
#include <wtf/Ref.h>
+namespace IPC {
+class ArgumentDecoder;
+class ArgumentEncoder;
+}
+
namespace API {
class FrameHandle : public ObjectImpl<Object::Type::FrameHandle> {
public:
static Ref<FrameHandle> create(uint64_t frameID);
static Ref<FrameHandle> createAutoconverting(uint64_t frameID);
+
explicit FrameHandle(uint64_t frameID, bool isAutoconverting);
-
virtual ~FrameHandle();
uint64_t frameID() const { return m_frameID; }
bool isAutoconverting() const { return m_isAutoconverting; }
+ void encode(IPC::ArgumentEncoder&) const;
+ static bool decode(IPC::ArgumentDecoder&, RefPtr<Object>&);
+
private:
const uint64_t m_frameID;
const bool m_isAutoconverting;
Modified: trunk/Source/WebKit2/Shared/API/APIPageGroupHandle.cpp (177748 => 177749)
--- trunk/Source/WebKit2/Shared/API/APIPageGroupHandle.cpp 2014-12-26 19:26:53 UTC (rev 177748)
+++ trunk/Source/WebKit2/Shared/API/APIPageGroupHandle.cpp 2014-12-26 20:24:34 UTC (rev 177749)
@@ -26,6 +26,9 @@
#include "config.h"
#include "APIPageGroupHandle.h"
+#include "ArgumentDecoder.h"
+#include "ArgumentEncoder.h"
+
namespace API {
Ref<PageGroupHandle> PageGroupHandle::create(WebKit::WebPageGroupData&& webPageGroupData)
@@ -33,13 +36,28 @@
return adoptRef(*new PageGroupHandle(WTF::move(webPageGroupData)));
}
+PageGroupHandle::PageGroupHandle(WebKit::WebPageGroupData&& webPageGroupData)
+ : m_webPageGroupData(WTF::move(webPageGroupData))
+{
+}
+
PageGroupHandle::~PageGroupHandle()
{
}
-PageGroupHandle::PageGroupHandle(WebKit::WebPageGroupData&& webPageGroupData)
- : m_webPageGroupData(WTF::move(webPageGroupData))
+void PageGroupHandle::encode(IPC::ArgumentEncoder& encoder) const
{
+ encoder << m_webPageGroupData;
}
+bool PageGroupHandle::decode(IPC::ArgumentDecoder& decoder, RefPtr<Object>& result)
+{
+ WebKit::WebPageGroupData webPageGroupData;
+ if (!decoder.decode(webPageGroupData))
+ return false;
+
+ result = create(WTF::move(webPageGroupData));
+ return true;
}
+
+}
Modified: trunk/Source/WebKit2/Shared/API/APIPageGroupHandle.h (177748 => 177749)
--- trunk/Source/WebKit2/Shared/API/APIPageGroupHandle.h 2014-12-26 19:26:53 UTC (rev 177748)
+++ trunk/Source/WebKit2/Shared/API/APIPageGroupHandle.h 2014-12-26 20:24:34 UTC (rev 177749)
@@ -30,6 +30,11 @@
#include "WebPageGroupData.h"
#include <wtf/RefPtr.h>
+namespace IPC {
+class ArgumentDecoder;
+class ArgumentEncoder;
+}
+
namespace API {
class PageGroupHandle : public ObjectImpl<Object::Type::PageGroupHandle> {
@@ -39,6 +44,9 @@
const WebKit::WebPageGroupData& webPageGroupData() const { return m_webPageGroupData; }
+ void encode(IPC::ArgumentEncoder&) const;
+ static bool decode(IPC::ArgumentDecoder&, RefPtr<Object>&);
+
private:
explicit PageGroupHandle(WebKit::WebPageGroupData&&);
Modified: trunk/Source/WebKit2/Shared/API/APIPageHandle.cpp (177748 => 177749)
--- trunk/Source/WebKit2/Shared/API/APIPageHandle.cpp 2014-12-26 19:26:53 UTC (rev 177748)
+++ trunk/Source/WebKit2/Shared/API/APIPageHandle.cpp 2014-12-26 20:24:34 UTC (rev 177749)
@@ -26,6 +26,9 @@
#include "config.h"
#include "APIPageHandle.h"
+#include "ArgumentDecoder.h"
+#include "ArgumentEncoder.h"
+
namespace API {
Ref<PageHandle> PageHandle::create(uint64_t pageID)
@@ -48,4 +51,24 @@
{
}
+void PageHandle::encode(IPC::ArgumentEncoder& encoder) const
+{
+ encoder << m_pageID;
+ encoder << m_isAutoconverting;
+}
+
+bool PageHandle::decode(IPC::ArgumentDecoder& decoder, RefPtr<Object>& result)
+{
+ uint64_t pageID;
+ if (!decoder.decode(pageID))
+ return false;
+
+ bool isAutoconverting;
+ if (!decoder.decode(isAutoconverting))
+ return false;
+
+ result = isAutoconverting ? createAutoconverting(pageID) : create(pageID);
+ return true;
+}
+
} // namespace API
Modified: trunk/Source/WebKit2/Shared/API/APIPageHandle.h (177748 => 177749)
--- trunk/Source/WebKit2/Shared/API/APIPageHandle.h 2014-12-26 19:26:53 UTC (rev 177748)
+++ trunk/Source/WebKit2/Shared/API/APIPageHandle.h 2014-12-26 20:24:34 UTC (rev 177749)
@@ -29,6 +29,11 @@
#include "APIObject.h"
#include <wtf/Ref.h>
+namespace IPC {
+class ArgumentDecoder;
+class ArgumentEncoder;
+}
+
namespace API {
class PageHandle : public ObjectImpl<Object::Type::PageHandle> {
@@ -40,6 +45,9 @@
uint64_t pageID() const { return m_pageID; }
bool isAutoconverting() const { return m_isAutoconverting; }
+ void encode(IPC::ArgumentEncoder&) const;
+ static bool decode(IPC::ArgumentDecoder&, RefPtr<Object>&);
+
private:
explicit PageHandle(uint64_t pageID, bool isAutoconverting);
Modified: trunk/Source/WebKit2/Shared/UserData.cpp (177748 => 177749)
--- trunk/Source/WebKit2/Shared/UserData.cpp 2014-12-26 19:26:53 UTC (rev 177748)
+++ trunk/Source/WebKit2/Shared/UserData.cpp 2014-12-26 20:24:34 UTC (rev 177749)
@@ -34,6 +34,7 @@
#include "APIGeometry.h"
#include "APINumber.h"
#include "APIPageGroupHandle.h"
+#include "APIPageHandle.h"
#include "APISerializedScriptValue.h"
#include "APIString.h"
#include "APIURL.h"
@@ -192,18 +193,18 @@
static_cast<const API::Error&>(object).encode(encoder);
break;
- case API::Object::Type::FrameHandle: {
- auto& frameHandle = static_cast<const API::FrameHandle&>(object);
- encoder << frameHandle.frameID();
+ case API::Object::Type::FrameHandle:
+ static_cast<const API::FrameHandle&>(object).encode(encoder);
break;
- }
- case API::Object::Type::PageGroupHandle: {
- auto& pageGroupHandle = static_cast<const API::PageGroupHandle&>(object);
- encoder << pageGroupHandle.webPageGroupData();
+ case API::Object::Type::PageGroupHandle:
+ static_cast<const API::PageGroupHandle&>(object).encode(encoder);
break;
- }
+ case API::Object::Type::PageHandle:
+ static_cast<const API::PageHandle&>(object).encode(encoder);
+ break;
+
case API::Object::Type::Point:
static_cast<const API::Point&>(object).encode(encoder);
break;
@@ -228,10 +229,9 @@
break;
}
- case API::Object::Type::URL: {
+ case API::Object::Type::URL:
static_cast<const API::URL&>(object).encode(encoder);
break;
- }
case API::Object::Type::URLRequest:
static_cast<const API::URLRequest&>(object).encode(encoder);
@@ -318,28 +318,24 @@
return false;
break;
- case API::Object::Type::FrameHandle: {
- uint64_t frameID;
- if (!decoder.decode(frameID))
+ case API::Object::Type::FrameHandle:
+ if (!API::FrameHandle::decode(decoder, result))
return false;
-
- result = API::FrameHandle::create(frameID);
break;
- }
case API::Object::Type::Null:
result = nullptr;
break;
- case API::Object::Type::PageGroupHandle: {
- WebKit::WebPageGroupData webPageGroupData;
- if (!decoder.decode(webPageGroupData))
+ case API::Object::Type::PageGroupHandle:
+ if (!API::PageGroupHandle::decode(decoder, result))
return false;
break;
- result = API::PageGroupHandle::create(WTF::move(webPageGroupData));
+ case API::Object::Type::PageHandle:
+ if (!API::PageHandle::decode(decoder, result))
+ return false;
break;
- }
case API::Object::Type::Point:
if (!API::Point::decode(decoder, result))