diff options
author | Jüri Valdmann <juri.valdmann@qt.io> | 2019-04-12 16:44:18 +0200 |
---|---|---|
committer | Jüri Valdmann <juri.valdmann@qt.io> | 2019-05-24 16:14:51 +0200 |
commit | a69029cf9fcfd0c1fcdaafe5cbcbff2d5dd6b5c5 (patch) | |
tree | a38cae2c082ee3c9a0108942b8406947d826a782 /src/core/web_contents_delegate_qt.h | |
parent | 0f081baa31facec779057de29eec14c6f458f6a6 (diff) |
Implement page lifecycle API
[ChangeLog][QtWebEngine][WebEngineView] WebEngineView now supports lifecycle
states that can be used for reducing CPU and memory consumption of invisible
views.
[ChangeLog][QtWebEngineWidgets][QWebEnginePage] QWebEnginePage now supports
lifecycle states that can be used for reducing CPU and memory consumption of
invisible pages.
Fixes: QTBUG-74166
Fixes: QTBUG-55079
Change-Id: I7d70c85dc995bd17c9fe91385a8e2750dbc0a627
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'src/core/web_contents_delegate_qt.h')
-rw-r--r-- | src/core/web_contents_delegate_qt.h | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h index 1629222c2..2ef4f22fc 100644 --- a/src/core/web_contents_delegate_qt.h +++ b/src/core/web_contents_delegate_qt.h @@ -40,6 +40,7 @@ #ifndef WEB_CONTENTS_DELEGATE_QT_H #define WEB_CONTENTS_DELEGATE_QT_H +#include "content/public/browser/media_capture_devices.h" #include "content/public/browser/web_contents_delegate.h" #include "content/public/browser/web_contents_observer.h" #include "third_party/skia/include/core/SkColor.h" @@ -133,9 +134,13 @@ public: // WebContentsObserver overrides void RenderFrameDeleted(content::RenderFrameHost *render_frame_host) override; + void RenderProcessGone(base::TerminationStatus status) override; void RenderViewHostChanged(content::RenderViewHost *old_host, content::RenderViewHost *new_host) override; void DidStartNavigation(content::NavigationHandle *navigation_handle) override; void DidFinishNavigation(content::NavigationHandle *navigation_handle) override; + void DidStartLoading() override; + void DidReceiveResponse() override; + void DidStopLoading() override; void DidFailLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url, int error_code, const base::string16& error_description) override; void DidFinishLoad(content::RenderFrameHost *render_frame_host, const GURL &validated_url) override; void BeforeUnloadFired(bool proceed, const base::TimeTicks& proceed_time) override; @@ -160,12 +165,32 @@ public: WebContentsAdapter *webContentsAdapter() const; WebContentsAdapterClient *adapterClient() const { return m_viewClient; } + void copyStateFrom(WebContentsDelegateQt *source); + + using LoadingState = WebContentsAdapterClient::LoadingState; + LoadingState loadingState() const { return m_loadingState; } + + void addDevices(const blink::MediaStreamDevices &devices); + void removeDevices(const blink::MediaStreamDevices &devices); + + bool isCapturingAudio() const { return m_audioStreamCount > 0; } + bool isCapturingVideo() const { return m_videoStreamCount > 0; } + bool isMirroring() const { return m_mirroringStreamCount > 0; } + bool isCapturingDesktop() const { return m_desktopStreamCount > 0; } + + base::WeakPtr<WebContentsDelegateQt> AsWeakPtr() { return m_weakPtrFactory.GetWeakPtr(); } + private: QWeakPointer<WebContentsAdapter> createWindow(std::unique_ptr<content::WebContents> new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture); void EmitLoadStarted(const QUrl &url, bool isErrorPage = false); void EmitLoadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()); void EmitLoadCommitted(); + LoadingState determineLoadingState(content::WebContents *contents); + void setLoadingState(LoadingState state); + + int &streamCount(blink::MediaStreamType type); + WebContentsAdapterClient *m_viewClient; QString m_lastSearchedString; int m_lastReceivedFindReply; @@ -175,9 +200,16 @@ private: QSharedPointer<FilePickerController> m_filePickerController; QUrl m_initialTargetUrl; int m_lastLoadProgress; - + LoadingState m_loadingState; + bool m_didStartLoadingSeen; QUrl m_url; QString m_title; + int m_audioStreamCount = 0; + int m_videoStreamCount = 0; + int m_mirroringStreamCount = 0; + int m_desktopStreamCount = 0; + + base::WeakPtrFactory<WebContentsDelegateQt> m_weakPtrFactory { this }; }; } // namespace QtWebEngineCore |