Bug 673260. HttpChannelChild::RecvAssociateApplicationCache needs to be buffered. r=jduell

This commit is contained in:
Han Chang 2011-08-22 14:17:14 -07:00
parent 701de872f8
commit b5abd62ccf
2 changed files with 45 additions and 15 deletions

View File

@ -144,6 +144,48 @@ HttpChannelChild::ReleaseIPDLReference()
Release();
}
class AssociateApplicationCacheEvent : public ChannelEvent
{
public:
AssociateApplicationCacheEvent(HttpChannelChild* child,
const nsCString &groupID,
const nsCString &clientID)
: mChild(child)
, groupID(groupID)
, clientID(clientID) {}
void Run() { mChild->AssociateApplicationCache(groupID, clientID); }
private:
HttpChannelChild* mChild;
nsCString groupID;
nsCString clientID;
};
bool
HttpChannelChild::RecvAssociateApplicationCache(const nsCString &groupID,
const nsCString &clientID)
{
if (mEventQ.ShouldEnqueue()) {
mEventQ.Enqueue(new AssociateApplicationCacheEvent(this, groupID, clientID));
} else {
AssociateApplicationCache(groupID, clientID);
}
return true;
}
void
HttpChannelChild::AssociateApplicationCache(const nsCString &groupID,
const nsCString &clientID)
{
nsresult rv;
mApplicationCache = do_CreateInstance(NS_APPLICATIONCACHE_CONTRACTID, &rv);
if (NS_FAILED(rv))
return;
mLoadedFromApplicationCache = PR_TRUE;
mApplicationCache->InitAsHandle(groupID, clientID);
}
class StartRequestEvent : public ChannelEvent
{
public:
@ -192,21 +234,6 @@ class StartRequestEvent : public ChannelEvent
PRNetAddr mPeerAddr;
};
bool
HttpChannelChild::RecvAssociateApplicationCache(const nsCString &groupID,
const nsCString &clientID)
{
nsresult rv;
mApplicationCache = do_CreateInstance(
NS_APPLICATIONCACHE_CONTRACTID, &rv);
if (NS_FAILED(rv))
return true;
mLoadedFromApplicationCache = PR_TRUE;
mApplicationCache->InitAsHandle(groupID, clientID);
return true;
}
bool
HttpChannelChild::RecvOnStartRequest(const nsHttpResponseHead& responseHead,
const PRBool& useResponseHead,

View File

@ -173,6 +173,8 @@ private:
bool mKeptAlive;
ChannelEventQueue mEventQ;
void AssociateApplicationCache(const nsCString &groupID,
const nsCString &clientID);
void OnStartRequest(const nsHttpResponseHead& responseHead,
const PRBool& useResponseHead,
const RequestHeaderTuples& requestHeaders,
@ -204,6 +206,7 @@ private:
// Called asynchronously from Resume: continues any pending calls into client.
void CompleteResume();
friend class AssociateApplicationCacheEvent;
friend class StartRequestEvent;
friend class StopRequestEvent;
friend class TransportAndDataEvent;