ConnectionHandle.cpp (2844B)
1 /* vim:set ts=4 sw=2 sts=2 et cin: */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 // HttpLog.h should generally be included first 7 #include "HttpLog.h" 8 9 // Log on level :5, instead of default :4. 10 #undef LOG 11 #define LOG(args) LOG5(args) 12 #undef LOG_ENABLED 13 #define LOG_ENABLED() LOG5_ENABLED() 14 15 #include "ConnectionHandle.h" 16 #include "nsHttpHandler.h" 17 18 namespace mozilla { 19 namespace net { 20 21 ConnectionHandle::~ConnectionHandle() { 22 if (mConn) { 23 nsresult rv = gHttpHandler->ReclaimConnection(mConn); 24 if (NS_FAILED(rv)) { 25 LOG( 26 ("ConnectionHandle::~ConnectionHandle\n" 27 " failed to reclaim connection %p\n", 28 mConn.get())); 29 } 30 } 31 } 32 33 nsresult ConnectionHandle::OnHeadersAvailable(nsAHttpTransaction* trans, 34 nsHttpRequestHead* req, 35 nsHttpResponseHead* resp, 36 bool* reset) { 37 return mConn->OnHeadersAvailable(trans, req, resp, reset); 38 } 39 40 void ConnectionHandle::CloseTransaction(nsAHttpTransaction* trans, 41 nsresult reason) { 42 mConn->CloseTransaction(trans, reason); 43 } 44 45 nsresult ConnectionHandle::TakeTransport(nsISocketTransport** aTransport, 46 nsIAsyncInputStream** aInputStream, 47 nsIAsyncOutputStream** aOutputStream) { 48 return mConn->TakeTransport(aTransport, aInputStream, aOutputStream); 49 } 50 51 WebTransportSessionBase* ConnectionHandle::GetWebTransportSession( 52 nsAHttpTransaction* aTransaction) { 53 return mConn->GetWebTransportSession(aTransaction); 54 } 55 56 bool ConnectionHandle::IsPersistent() { 57 MOZ_ASSERT(OnSocketThread()); 58 return mConn->IsPersistent(); 59 } 60 61 bool ConnectionHandle::IsReused() { 62 MOZ_ASSERT(OnSocketThread()); 63 return mConn->IsReused(); 64 } 65 66 void ConnectionHandle::DontReuse() { 67 MOZ_ASSERT(OnSocketThread()); 68 mConn->DontReuse(); 69 } 70 71 nsresult ConnectionHandle::PushBack(const char* buf, uint32_t bufLen) { 72 return mConn->PushBack(buf, bufLen); 73 } 74 75 already_AddRefed<HttpConnectionBase> ConnectionHandle::TakeHttpConnection() { 76 // return our connection object to the caller and clear it internally 77 // do not drop our reference - the caller now owns it. 78 MOZ_ASSERT(mConn); 79 return mConn.forget(); 80 } 81 82 already_AddRefed<HttpConnectionBase> ConnectionHandle::HttpConnection() { 83 RefPtr<HttpConnectionBase> rv(mConn); 84 return rv.forget(); 85 } 86 87 void ConnectionHandle::CurrentBrowserIdChanged(uint64_t id) { 88 // Do nothing. 89 } 90 91 PRIntervalTime ConnectionHandle::LastWriteTime() { 92 return mConn->LastWriteTime(); 93 } 94 95 } // namespace net 96 } // namespace mozilla