fune/netwerk/protocol/http/BackgroundChannelRegistrar.h
Shih-Chiang Chien e7a014adc4 Bug 1015466 - Part 3, PHttpBackgroundChannel lifecycle management. r=mayhemer
PHttpBackgroundChannel is created by content process because PBackground IPDL
can only be initiated from content process. The background channel deletion is
controlled by chrome process while PHttpChannel is going to be closed or canceled.

BackgroundChannelRegistrar is introduced for pairing HttpChannelParent and
HttpBackgroundChannelParent since they are created over different IPDL
asynchronously.

nsIParentRedirectingChannel.continueVerification is introduced to asynchronously
wait for background channel to be established on the new channel during the
Redirect2Verify phase.

MozReview-Commit-ID: 41l8ivan8iA

--HG--
extra : rebase_source : b8b6d7e7c037efaa9fc13df14191205c603e833a
2017-04-24 11:09:35 +08:00

52 lines
1.7 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_net_BackgroundChannelRegistrar_h__
#define mozilla_net_BackgroundChannelRegistrar_h__
#include "nsIBackgroundChannelRegistrar.h"
#include "nsRefPtrHashtable.h"
namespace mozilla {
namespace net {
class HttpBackgroundChannelParent;
class HttpChannelParent;
class BackgroundChannelRegistrar final : public nsIBackgroundChannelRegistrar
{
typedef nsRefPtrHashtable<nsUint64HashKey, HttpChannelParent>
ChannelHashtable;
typedef nsRefPtrHashtable<nsUint64HashKey, HttpBackgroundChannelParent>
BackgroundChannelHashtable;
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIBACKGROUNDCHANNELREGISTRAR
explicit BackgroundChannelRegistrar();
private:
virtual ~BackgroundChannelRegistrar();
// A helper function for BackgroundChannelRegistrar itself to callback
// HttpChannelParent and HttpBackgroundChannelParent when both objects are
// ready. aChannelParent and aBgParent is the pair of HttpChannelParent and
// HttpBackgroundChannelParent that should be linked together.
void NotifyChannelLinked(HttpChannelParent* aChannelParent,
HttpBackgroundChannelParent* aBgParent);
// Store unlinked HttpChannelParent objects.
ChannelHashtable mChannels;
// Store unlinked HttpBackgroundChannelParent objects.
BackgroundChannelHashtable mBgChannels;
};
} // namespace net
} // namespace mozilla
#endif // mozilla_net_BackgroundChannelRegistrar_h__