blob: 724efa063a3f5085a120796475ba97bf771499c4 [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/observer_list.h"
#include "base/observer_list_types.h"
namespace subresource_filter {
// This class tracks observers of resources that have been identified as ads in
// blink.
class AdResourceTracker {
// Observes resource loads that are identified as ad resources.
class Observer : public base::CheckedObserver {
// This method is called when the subresource filter is notified of a
// new resource that is tagged as an ad.
virtual void OnAdResourceObserved(int request_id) = 0;
// Called before the AdResourceTracker is destroyed. Observers must
// unregister themselves by this point.
virtual void OnAdResourceTrackerGoingAway() = 0;
// Add an observer that will listen for ad resource request ids.
void AddObserver(Observer* ad_resource_observer);
void RemoveObserver(Observer* ad_resource_observer);
// Report the observed request_id as an ad resource.
void NotifyAdResourceObserved(int request_id);
base::ObserverList<Observer> observers_;
} // namespace subresource_filter