author Dorel Luca <>
Thu, 14 Mar 2019 09:14:15 +0200
changeset 521851 4d0c32fbf17c2146a1c1a51afc458de79c10b705
parent 521845 af4e03d1f5c896d10b6bdacd3e51dfe5448a3060
child 521915 a0c8d47ee188ee72fb0896dd80b02076f9bcafb5
permissions -rw-r--r--
Backed out 5 changesets (bug 1533074) for eslint failure Backed out changeset 36c6a7178a5c (bug 1533074) Backed out changeset 7e6a8fadff5b (bug 1533074) Backed out changeset 2a0494fed543 (bug 1533074) Backed out changeset 38470d2dd98c (bug 1533074) Backed out changeset af4e03d1f5c8 (bug 1533074)

/* -*- 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_TrackingDummyChannel_h
#define mozilla_net_TrackingDummyChannel_h

#include "nsIChannel.h"
#include <functional>

#define TRACKING_DUMMY_CHANNEL_IID                   \
  {                                                  \
    0x70ceb97d, 0xbfa6, 0x4255, {                    \
      0xb7, 0x08, 0xe1, 0xb4, 0x4a, 0x1e, 0x0e, 0x9a \
    }                                                \

class nsIChannel;

namespace mozilla {
namespace net {

 * In child intercept mode, the decision to intercept a channel is made in the
 * child process without consulting the parent process.  The decision is based
 * on whether there is a ServiceWorker with a scope covering the URL in question
 * and whether storage is allowed for the origin/URL.  When the
 * "network.cookie.cookieBehavior" preference is set to BEHAVIOR_REJECT_TRACKER,
 * annotated channels are denied storage which means that the ServiceWorker
 * should not intercept the channel.  However, the decision for tracking
 * protection to annotate a channel only occurs in the parent process.  The
 * dummy channel is a hack to allow the intercept decision process to ask the
 * parent process if the channel should be annotated.  Because this round-trip
 * to the parent has overhead, the dummy channel is only created 1) if the
 * ServiceWorker initially determines that the channel should be intercepted and
 * 2) it's a navigation request.
 * This hack can be removed once Bug 1231208's new "parent intercept" mechanism
 * fully lands, the pref is enabled by default it stays enabled for long enough
 * to be confident we will never need/want to turn it off.  Then as part of bug
 * 1496997 we can remove this implementation.  Bug 1498259 covers removing this
 * hack in particular.
class TrackingDummyChannel final : public nsIChannel,
                                   public nsIHttpChannelInternal {


  enum StorageAllowedState {

  static StorageAllowedState StorageAllowed(
      nsIChannel* aChannel, const std::function<void(bool)>& aCallback);

  TrackingDummyChannel(nsIURI* aURI, nsIURI* aTopWindowURI,
                       nsresult aTopWindowURIResult, nsILoadInfo* aLoadInfo);

  bool IsTrackingResource() const;

  void SetIsTrackingResource();


  nsCOMPtr<nsILoadInfo> mLoadInfo;
  nsCOMPtr<nsIURI> mURI;
  nsCOMPtr<nsIURI> mTopWindowURI;
  nsresult mTopWindowURIResult;

  bool mIsTrackingResource;


}  // namespace net
}  // namespace mozilla

#endif  // mozilla_net_TrackingDummyChannel_h