diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-06-25 22:06:29 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-06-25 22:06:29 +0900 |
| commit | 4803482a51bbb0de968fe301bcea42bc41b8cf46 (patch) | |
| tree | d03e911786a3d28d45e79c2f91dca035cf6215f3 /src | |
| parent | 6bcf33a69e1bfa9f7679b78f9f287d84798015aa (diff) | |
HttpRequest: Store non-owning raw pointer for authConfigFactory_
Diffstat (limited to 'src')
| -rw-r--r-- | src/DownloadEngine.cc | 9 | ||||
| -rw-r--r-- | src/DownloadEngine.h | 9 | ||||
| -rw-r--r-- | src/HttpRequest.cc | 23 | ||||
| -rw-r--r-- | src/HttpRequest.h | 6 | ||||
| -rw-r--r-- | src/HttpRequestCommand.cc | 17 | ||||
| -rw-r--r-- | src/MultiUrlRequestInfo.cc | 4 |
6 files changed, 35 insertions, 33 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<AuthConfigFactory>& factory) +(std::unique_ptr<AuthConfigFactory> 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> dnsCache_; - std::shared_ptr<AuthConfigFactory> authConfigFactory_; + std::unique_ptr<AuthConfigFactory> authConfigFactory_; #ifdef ENABLE_WEBSOCKET std::shared_ptr<rpc::WebSocketSessionMan> webSocketSessionMan_; @@ -334,12 +334,9 @@ public: void removeCachedIPAddress(const std::string& hostname, uint16_t port); - void setAuthConfigFactory(const std::shared_ptr<AuthConfigFactory>& factory); + void setAuthConfigFactory(std::unique_ptr<AuthConfigFactory> factory); - const std::shared_ptr<AuthConfigFactory>& 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<AuthConfigFactory>& 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> cookieStorage_; - std::shared_ptr<AuthConfigFactory> authConfigFactory_; + AuthConfigFactory* authConfigFactory_; const Option* option_; @@ -192,8 +192,8 @@ public: return cookieStorage_; } - void setAuthConfigFactory - (const std::shared_ptr<AuthConfigFactory>& 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<HttpRequest> createHttpRequest(const std::shared_ptr<Request>& req, const std::shared_ptr<FileEntry>& fileEntry, const std::shared_ptr<Segment>& segment, - int64_t totalLength, const std::shared_ptr<Option>& option, const RequestGroup* rg, - const std::shared_ptr<CookieStorage>& cookieStorage, - const std::shared_ptr<AuthConfigFactory>& authConfigFactory, + const DownloadEngine* e, const std::shared_ptr<Request>& proxyRequest, int64_t endOffset = 0) { @@ -100,8 +98,9 @@ createHttpRequest(const std::shared_ptr<Request>& req, httpRequest->setFileEntry(fileEntry); httpRequest->setSegment(segment); httpRequest->addHeader(option->get(PREF_HEADER)); - httpRequest->setCookieStorage(cookieStorage); - httpRequest->setAuthConfigFactory(authConfigFactory, option.get()); + httpRequest->setCookieStorage(e->getCookieStorage()); + httpRequest->setAuthConfigFactory(e->getAuthConfigFactory()); + httpRequest->setOption(option.get()); httpRequest->setProxyRequest(proxyRequest); httpRequest->setAcceptMetalink(rg->getDownloadContext()-> getAcceptMetalink()); @@ -140,11 +139,9 @@ bool HttpRequestCommand::executeInternal() { (createHttpRequest(getRequest(), getFileEntry(), std::shared_ptr<Segment>(), - getRequestGroup()->getTotalLength(), getOption(), getRequestGroup(), - getDownloadEngine()->getCookieStorage(), - getDownloadEngine()->getAuthConfigFactory(), + getDownloadEngine(), proxyRequest_)); if(getOption()->getAsBool(PREF_CONDITIONAL_GET) && (getRequest()->getProtocol() == "http" || @@ -192,11 +189,9 @@ bool HttpRequestCommand::executeInternal() { (createHttpRequest(getRequest(), getFileEntry(), segment, - getRequestGroup()->getTotalLength(), getOption(), getRequestGroup(), - getDownloadEngine()->getCookieStorage(), - getDownloadEngine()->getAuthConfigFactory(), + getDownloadEngine(), proxyRequest_, endOffset)); httpConnection_->sendRequest(httpRequest); diff --git a/src/MultiUrlRequestInfo.cc b/src/MultiUrlRequestInfo.cc index bb054469..107d3ce0 100644 --- a/src/MultiUrlRequestInfo.cc +++ b/src/MultiUrlRequestInfo.cc @@ -187,7 +187,7 @@ int MultiUrlRequestInfo::prepare() } } - std::shared_ptr<AuthConfigFactory> authConfigFactory(new AuthConfigFactory()); + auto authConfigFactory = make_unique<AuthConfigFactory>(); File netrccf(option_->get(PREF_NETRC_PATH)); if(!option_->getAsBool(PREF_NO_NETRC) && netrccf.isFile()) { #ifdef __MINGW32__ @@ -205,7 +205,7 @@ int MultiUrlRequestInfo::prepare() authConfigFactory->setNetrc(netrc); } } - e_->setAuthConfigFactory(authConfigFactory); + e_->setAuthConfigFactory(std::move(authConfigFactory)); #ifdef ENABLE_SSL std::shared_ptr<TLSContext> clTlsContext(TLSContext::make(TLS_CLIENT)); |
