author Shih-Chiang Chien <>
Mon, 24 Apr 2017 11:09:35 +0800
changeset 587450 0425872587b4c64e80ce16ba2e91a6009a797fac
parent 587448 423709763e1abf1362347bc2d3141e2d33aed46a
child 578742 7047ce3c8c8851390a963e8f62faeeaee48d0d8f
child 584806 b9831872aca094bb94d3b05283c640f92b98bd9f
permissions -rw-r--r--
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

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et 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 */

#ifndef mozilla_net_HttpBackgroundChannelChild_h
#define mozilla_net_HttpBackgroundChannelChild_h

#include "mozilla/net/PHttpBackgroundChannelChild.h"

using mozilla::ipc::IPCResult;

namespace mozilla {
namespace net {

class HttpChannelChild;

class HttpBackgroundChannelChild final : public PHttpBackgroundChannelChild
  friend class BackgroundChannelCreateCallback;
  explicit HttpBackgroundChannelChild();


  // Associate this background channel with a HttpChannelChild and
  // initiate the createion of the PBackground IPC channel.
  nsresult Init(HttpChannelChild* aChannelChild);

  // Callback while the associated HttpChannelChild is not going to
  // handle any incoming messages over background channel.
  void OnChannelClosed();

  // Callback while failed to create PBackground IPC channel.
  void OnBackgroundChannelCreationFailed();

  IPCResult RecvOnTransportAndData(const nsresult& aChannelStatus,
                                   const nsresult& aTransportStatus,
                                   const uint64_t& aOffset,
                                   const uint32_t& aCount,
                                   const nsCString& aData) override;

  IPCResult RecvOnStopRequest(const nsresult& aChannelStatus,
                              const ResourceTimingStruct& aTiming) override;

  IPCResult RecvOnProgress(const int64_t& aProgress,
                           const int64_t& aProgressMax) override;

  IPCResult RecvOnStatus(const nsresult& aStatus) override;

  IPCResult RecvFlushedForDiversion() override;

  IPCResult RecvDivertMessages() override;

  IPCResult RecvOnStartRequestSent() override;

  void ActorDestroy(ActorDestroyReason aWhy) override;

  virtual ~HttpBackgroundChannelChild();

  // Initiate the creation of the PBckground IPC channel.
  // Return false if failed.
  bool CreateBackgroundChannel();

  // Associated HttpChannelChild for handling the channel events.
  // Will be removed while failed to create background channel,
  // destruction of the background channel, or explicitly dissociation
  // via OnChannelClosed callback.
  RefPtr<HttpChannelChild> mChannelChild;

} // namespace net
} // namespace mozilla

#endif // mozilla_net_HttpBackgroundChannelChild_h