diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-02-04 13:50:57 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-02-04 14:13:39 +0100 |
commit | 6722bbbf4ea2ddcdd9194f26a883029ec3afc39a (patch) | |
tree | c3290b82fac21c4990be8472ae6cb4ca043205cf /src/core/url_request_custom_job.h | |
parent | 41d69eb0fa2375f0da6ba9b35136f5598be4b3a4 (diff) | |
parent | 82f4d13a13b40d9cb7710f6dd4190175a272a394 (diff) |
Merge branch '5.6' into dev
Change-Id: I0bb971f01ee1e02da768f336680c8ec0254ab2b0
Diffstat (limited to 'src/core/url_request_custom_job.h')
-rw-r--r-- | src/core/url_request_custom_job.h | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/src/core/url_request_custom_job.h b/src/core/url_request_custom_job.h index e6063f485..98e2478c4 100644 --- a/src/core/url_request_custom_job.h +++ b/src/core/url_request_custom_job.h @@ -53,6 +53,7 @@ QT_FORWARD_DECLARE_CLASS(QWebEngineUrlSchemeHandler) namespace QtWebEngineCore { class URLRequestCustomJobDelegate; +class URLRequestCustomJobShared; // A request job that handles reading custom URL schemes class URLRequestCustomJob : public net::URLRequestJob { @@ -65,6 +66,25 @@ public: virtual bool GetCharset(std::string *charset) Q_DECL_OVERRIDE; virtual bool IsRedirectResponse(GURL* location, int* http_status_code) Q_DECL_OVERRIDE; +protected: + virtual ~URLRequestCustomJob(); + +private: + QWebEngineUrlSchemeHandler *m_schemeHandler; + URLRequestCustomJobShared *m_shared; + + friend class URLRequestCustomJobShared; + + DISALLOW_COPY_AND_ASSIGN(URLRequestCustomJob); +}; + +// A shared state between URLRequestCustomJob living on the IO thread +// and URLRequestCustomJobDelegate living on the UI thread. +class URLRequestCustomJobShared { +public: + URLRequestCustomJobShared(URLRequestCustomJob *job); + ~URLRequestCustomJobShared(); + void setReplyMimeType(const std::string &); void setReplyCharset(const std::string &); void setReplyDevice(QIODevice *); @@ -73,29 +93,28 @@ public: void fail(int); void abort(); -protected: - virtual ~URLRequestCustomJob(); + void killJob(); + void unsetJobDelegate(); + void startAsync(); void notifyStarted(); void notifyFailure(); void notifyCanceled(); -private: + GURL requestUrl(); + std::string requestMethod(); + QMutex m_mutex; QPointer<QIODevice> m_device; - QPointer<URLRequestCustomJobDelegate> m_delegate; - QWebEngineUrlSchemeHandler *m_schemeHandler; + URLRequestCustomJob *m_job; + URLRequestCustomJobDelegate *m_delegate; std::string m_mimeType; std::string m_charset; int m_error; GURL m_redirect; bool m_started; - base::WeakPtrFactory<URLRequestCustomJob> m_weakFactoryIO; - base::WeakPtrFactory<URLRequestCustomJob> m_weakFactoryUI; - - friend class URLRequestCustomJobDelegate; - - DISALLOW_COPY_AND_ASSIGN(URLRequestCustomJob); + bool m_asyncInitialized; + base::WeakPtrFactory<URLRequestCustomJobShared> m_weakFactory; }; } // namespace QtWebEngineCore |