summaryrefslogtreecommitdiffstats
path: root/src/webenginewidgets/api/qwebenginepage_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/webenginewidgets/api/qwebenginepage_p.h')
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h42
1 files changed, 38 insertions, 4 deletions
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index 86605c78..9a4dc57f 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -58,6 +58,43 @@ class QWebEngineHistory;
class QWebEnginePage;
class QWebEngineView;
+class CallbackDirectory {
+public:
+ typedef QtWebEnginePrivate::QWebEngineCallbackPrivateBase<const QVariant&> VariantCallback;
+ typedef QtWebEnginePrivate::QWebEngineCallbackPrivateBase<const QString&> StringCallback;
+
+ ~CallbackDirectory();
+ void registerCallback(quint64 requestId, const QExplicitlySharedDataPointer<VariantCallback> &callback);
+ void registerCallback(quint64 requestId, const QExplicitlySharedDataPointer<StringCallback> &callback);
+ void invoke(quint64 requestId, const QVariant &result);
+ void invoke(quint64 requestId, const QString &result);
+
+private:
+ struct CallbackSharedDataPointer {
+ enum {
+ None,
+ Variant,
+ String
+ } type;
+ union {
+ VariantCallback *variantCallback;
+ StringCallback *stringCallback;
+ };
+ CallbackSharedDataPointer() : type(None) { }
+ CallbackSharedDataPointer(VariantCallback *callback) : type(Variant), variantCallback(callback) { callback->ref.ref(); }
+ CallbackSharedDataPointer(StringCallback *callback) : type(String), stringCallback(callback) { callback->ref.ref(); }
+ CallbackSharedDataPointer(const CallbackSharedDataPointer &other) : type(other.type), variantCallback(other.variantCallback) { doRef(); }
+ ~CallbackSharedDataPointer() { doDeref(); }
+ operator bool () const { return type != None; }
+
+ private:
+ void doRef();
+ void doDeref();
+ };
+
+ QHash<quint64, CallbackSharedDataPointer> m_callbackMap;
+};
+
class QWebEnginePagePrivate : public QObjectPrivate, public WebContentsAdapterClient
{
public:
@@ -104,10 +141,7 @@ public:
WebEngineContextMenuData m_menuData;
QPointer<RenderWidgetHostViewQtDelegateWebPage> m_rwhvDelegate;
- typedef QtWebEnginePrivate::QWebEngineCallbackPrivateBase<const QVariant&> VariantCallback;
- typedef QtWebEnginePrivate::QWebEngineCallbackPrivateBase<const QString&> StringCallback;
- mutable QHash<quint64, QExplicitlySharedDataPointer<VariantCallback> > m_variantCallbacks;
- mutable QHash<quint64, QExplicitlySharedDataPointer<StringCallback> > m_stringCallbacks;
+ mutable CallbackDirectory m_callbacks;
};
QT_END_NAMESPACE