From 4803482a51bbb0de968fe301bcea42bc41b8cf46 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 25 Jun 2013 22:06:29 +0900 Subject: [PATCH] HttpRequest: Store non-owning raw pointer for authConfigFactory_ --- src/DownloadEngine.cc | 9 ++- src/DownloadEngine.h | 9 +-- src/HttpRequest.cc | 23 ++++--- src/HttpRequest.h | 6 +- src/HttpRequestCommand.cc | 17 ++--- src/MultiUrlRequestInfo.cc | 4 +- test/HttpRequestTest.cc | 135 +++++++++++++++++++------------------ 7 files changed, 105 insertions(+), 98 deletions(-) diff --git a/src/DownloadEngine.cc b/src/DownloadEngine.cc index bc315b24..6742d8b7 100644 --- a/src/DownloadEngine.cc +++ b/src/DownloadEngine.cc @@ -544,9 +544,14 @@ void DownloadEngine::removeCachedIPAddress } void DownloadEngine::setAuthConfigFactory -(const std::shared_ptr& factory) +(std::unique_ptr factory) { - authConfigFactory_ = factory; + authConfigFactory_ = std::move(factory); +} + +AuthConfigFactory* DownloadEngine::getAuthConfigFactory() const +{ + return authConfigFactory_.get(); } void DownloadEngine::setRefreshInterval(int64_t interval) diff --git a/src/DownloadEngine.h b/src/DownloadEngine.h index 5784b0d1..f0ba7ae2 100644 --- a/src/DownloadEngine.h +++ b/src/DownloadEngine.h @@ -147,7 +147,7 @@ private: std::shared_ptr dnsCache_; - std::shared_ptr authConfigFactory_; + std::unique_ptr authConfigFactory_; #ifdef ENABLE_WEBSOCKET std::shared_ptr webSocketSessionMan_; @@ -334,12 +334,9 @@ public: void removeCachedIPAddress(const std::string& hostname, uint16_t port); - void setAuthConfigFactory(const std::shared_ptr& factory); + void setAuthConfigFactory(std::unique_ptr factory); - const std::shared_ptr& getAuthConfigFactory() const - { - return authConfigFactory_; - } + AuthConfigFactory* getAuthConfigFactory() const; void setRefreshInterval(int64_t interval); diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index d7320d00..87882743 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -57,13 +57,15 @@ namespace aria2 { const std::string HttpRequest::USER_AGENT("aria2"); -HttpRequest::HttpRequest():contentEncodingEnabled_(true), - userAgent_(USER_AGENT), - acceptMetalink_(false), - option_(0), - noCache_(true), - acceptGzip_(false), - endOffsetOverride_(0) +HttpRequest::HttpRequest() + : contentEncodingEnabled_(true), + userAgent_(USER_AGENT), + acceptMetalink_(false), + authConfigFactory_(0), + option_(0), + noCache_(true), + acceptGzip_(false), + endOffsetOverride_(0) {} HttpRequest::~HttpRequest() {} @@ -333,10 +335,13 @@ void HttpRequest::setCookieStorage cookieStorage_ = cookieStorage; } -void HttpRequest::setAuthConfigFactory -(const std::shared_ptr& factory, const Option* option) +void HttpRequest::setAuthConfigFactory(AuthConfigFactory* factory) { authConfigFactory_ = factory; +} + +void HttpRequest::setOption(const Option* option) +{ option_ = option; } diff --git a/src/HttpRequest.h b/src/HttpRequest.h index a9ac38c0..58b0a53f 100644 --- a/src/HttpRequest.h +++ b/src/HttpRequest.h @@ -76,7 +76,7 @@ private: std::shared_ptr cookieStorage_; - std::shared_ptr authConfigFactory_; + AuthConfigFactory* authConfigFactory_; const Option* option_; @@ -192,8 +192,8 @@ public: return cookieStorage_; } - void setAuthConfigFactory - (const std::shared_ptr& factory, const Option* option); + void setAuthConfigFactory(AuthConfigFactory* factory); + void setOption(const Option* option); /* * To use proxy, pass proxy string to Request::setUri() and set it this diff --git a/src/HttpRequestCommand.cc b/src/HttpRequestCommand.cc index 53f73007..678bec18 100644 --- a/src/HttpRequestCommand.cc +++ b/src/HttpRequestCommand.cc @@ -86,11 +86,9 @@ std::shared_ptr createHttpRequest(const std::shared_ptr& req, const std::shared_ptr& fileEntry, const std::shared_ptr& segment, - int64_t totalLength, const std::shared_ptr