Quota: Remove StorageMonitor class.

While adding class comments to Quota classes, I noticed that there are
no calls to StorageMonitor::AddObserver() outside of tests. Without any
observers, this class serves no other purpose.

Change-Id: I9066cbddad78b10de2eb1082cc3bb381e334cd9d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1679156
Reviewed-by: Joshua Bell <jsbell@chromium.org>
Commit-Queue: Jarryd Goodman <jarrydg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#675728}
diff --git a/storage/browser/BUILD.gn b/storage/browser/BUILD.gn
index eec6df4f..a76043c 100644
--- a/storage/browser/BUILD.gn
+++ b/storage/browser/BUILD.gn
@@ -207,10 +207,6 @@
     "quota/quota_temporary_storage_evictor.h",
     "quota/special_storage_policy.cc",
     "quota/special_storage_policy.h",
-    "quota/storage_monitor.cc",
-    "quota/storage_monitor.h",
-    "quota/storage_observer.cc",
-    "quota/storage_observer.h",
     "quota/usage_tracker.cc",
     "quota/usage_tracker.h",
   ]
@@ -316,7 +312,6 @@
     "quota/quota_manager_unittest.cc",
     "quota/quota_settings_unittest.cc",
     "quota/quota_temporary_storage_evictor_unittest.cc",
-    "quota/storage_monitor_unittest.cc",
     "quota/usage_tracker_unittest.cc",
     "test/mock_quota_manager_unittest.cc",
   ]
diff --git a/storage/browser/quota/client_usage_tracker.cc b/storage/browser/quota/client_usage_tracker.cc
index 36e7f4d6..368308ed 100644
--- a/storage/browser/quota/client_usage_tracker.cc
+++ b/storage/browser/quota/client_usage_tracker.cc
@@ -7,10 +7,9 @@
 #include <stdint.h>
 
 #include "base/bind.h"
+#include "base/bind_helpers.h"
 #include "base/stl_util.h"
 #include "net/base/url_util.h"
-#include "storage/browser/quota/storage_monitor.h"
-#include "storage/browser/quota/storage_observer.h"
 
 namespace storage {
 
@@ -61,11 +60,9 @@
     UsageTracker* tracker,
     QuotaClient* client,
     blink::mojom::StorageType type,
-    SpecialStoragePolicy* special_storage_policy,
-    StorageMonitor* storage_monitor)
+    SpecialStoragePolicy* special_storage_policy)
     : client_(client),
       type_(type),
-      storage_monitor_(storage_monitor),
       global_limited_usage_(0),
       global_unlimited_usage_(0),
       global_usage_retrieved_(false),
@@ -160,19 +157,12 @@
                                                       : &global_limited_usage_,
                            delta);
 
-    // Notify the usage monitor that usage has changed. The storage monitor may
-    // be nullptr during tests.
-    if (storage_monitor_) {
-      StorageObserver::Filter filter(type_, origin);
-      storage_monitor_->NotifyUsageChange(filter, delta);
-    }
     return;
   }
 
-  // We don't know about this host yet, so populate our cache for it.
-  GetHostUsage(host,
-               base::BindOnce(&ClientUsageTracker::DidGetHostUsageAfterUpdate,
-                              AsWeakPtr(), origin));
+  // We call GetHostUsage() so that the cache still updates, but we don't need
+  // to do anything else with the usage so we do not pass a callback.
+  GetHostUsage(host, base::DoNothing());
 }
 
 int64_t ClientUsageTracker::GetCachedUsage() const {
@@ -382,16 +372,6 @@
       host, info->limited_usage, info->unlimited_usage);
 }
 
-void ClientUsageTracker::DidGetHostUsageAfterUpdate(const url::Origin& origin,
-                                                    int64_t usage) {
-  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
-  if (!storage_monitor_)
-    return;
-
-  StorageObserver::Filter filter(type_, origin);
-  storage_monitor_->NotifyUsageChange(filter, 0);
-}
-
 void ClientUsageTracker::AddCachedOrigin(const url::Origin& origin,
                                          int64_t new_usage) {
   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
diff --git a/storage/browser/quota/client_usage_tracker.h b/storage/browser/quota/client_usage_tracker.h
index 3b4877d..42f7d47 100644
--- a/storage/browser/quota/client_usage_tracker.h
+++ b/storage/browser/quota/client_usage_tracker.h
@@ -26,7 +26,6 @@
 
 namespace storage {
 
-class StorageMonitor;
 class UsageTracker;
 
 // This class holds per-client usage tracking information and caches per-host
@@ -39,8 +38,7 @@
   ClientUsageTracker(UsageTracker* tracker,
                      QuotaClient* client,
                      blink::mojom::StorageType type,
-                     SpecialStoragePolicy* special_storage_policy,
-                     StorageMonitor* storage_monitor);
+                     SpecialStoragePolicy* special_storage_policy);
   ~ClientUsageTracker() override;
 
   void GetGlobalLimitedUsage(UsageCallback callback);
@@ -84,8 +82,6 @@
                              const base::Optional<url::Origin>& origin,
                              int64_t usage);
 
-  void DidGetHostUsageAfterUpdate(const url::Origin& origin, int64_t usage);
-
   // Methods used by our GatherUsage tasks, as a task makes progress
   // origins and hosts are added incrementally to the cache.
   void AddCachedOrigin(const url::Origin& origin, int64_t usage);
@@ -106,7 +102,6 @@
 
   QuotaClient* client_;
   const blink::mojom::StorageType type_;
-  StorageMonitor* storage_monitor_;
 
   int64_t global_limited_usage_;
   int64_t global_unlimited_usage_;
diff --git a/storage/browser/quota/quota_manager.cc b/storage/browser/quota/quota_manager.cc
index 7154adf..5646bf1 100644
--- a/storage/browser/quota/quota_manager.cc
+++ b/storage/browser/quota/quota_manager.cc
@@ -38,7 +38,6 @@
 #include "storage/browser/quota/quota_macros.h"
 #include "storage/browser/quota/quota_manager_proxy.h"
 #include "storage/browser/quota/quota_temporary_storage_evictor.h"
-#include "storage/browser/quota/storage_monitor.h"
 #include "storage/browser/quota/usage_tracker.h"
 
 using blink::mojom::StorageType;
@@ -878,7 +877,6 @@
       is_getting_eviction_origin_(false),
       special_storage_policy_(std::move(special_storage_policy)),
       get_volume_info_fn_(&QuotaManager::GetVolumeInfo),
-      storage_monitor_(new StorageMonitor(this)),
       weak_factory_(this) {
   DCHECK_EQ(settings_.refresh_interval, base::TimeDelta::Max());
   if (!get_settings_function.is_null()) {
@@ -1189,18 +1187,15 @@
   switch (type) {
     case StorageType::kTemporary:
       temporary_usage_tracker_.reset(new UsageTracker(
-          clients_, StorageType::kTemporary, special_storage_policy_.get(),
-          storage_monitor_.get()));
+          clients_, StorageType::kTemporary, special_storage_policy_.get()));
       return true;
     case StorageType::kPersistent:
       persistent_usage_tracker_.reset(new UsageTracker(
-          clients_, StorageType::kPersistent, special_storage_policy_.get(),
-          storage_monitor_.get()));
+          clients_, StorageType::kPersistent, special_storage_policy_.get()));
       return true;
     case StorageType::kSyncable:
       syncable_usage_tracker_.reset(new UsageTracker(
-          clients_, StorageType::kSyncable, special_storage_policy_.get(),
-          storage_monitor_.get()));
+          clients_, StorageType::kSyncable, special_storage_policy_.get()));
       return true;
     default:
       NOTREACHED();
@@ -1208,19 +1203,6 @@
   return true;
 }
 
-void QuotaManager::AddStorageObserver(
-    StorageObserver* observer, const StorageObserver::MonitorParams& params) {
-  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
-  DCHECK(observer);
-  storage_monitor_->AddObserver(observer, params);
-}
-
-void QuotaManager::RemoveStorageObserver(StorageObserver* observer) {
-  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
-  DCHECK(observer);
-  storage_monitor_->RemoveObserver(observer);
-}
-
 QuotaManager::~QuotaManager() {
   proxy_->manager_ = nullptr;
   for (auto* client : clients_)
@@ -1246,15 +1228,12 @@
   database_.reset(new QuotaDatabase(is_incognito_ ? base::FilePath() :
       profile_path_.AppendASCII(kDatabaseName)));
 
-  temporary_usage_tracker_.reset(
-      new UsageTracker(clients_, StorageType::kTemporary,
-                       special_storage_policy_.get(), storage_monitor_.get()));
-  persistent_usage_tracker_.reset(
-      new UsageTracker(clients_, StorageType::kPersistent,
-                       special_storage_policy_.get(), storage_monitor_.get()));
-  syncable_usage_tracker_.reset(
-      new UsageTracker(clients_, StorageType::kSyncable,
-                       special_storage_policy_.get(), storage_monitor_.get()));
+  temporary_usage_tracker_.reset(new UsageTracker(
+      clients_, StorageType::kTemporary, special_storage_policy_.get()));
+  persistent_usage_tracker_.reset(new UsageTracker(
+      clients_, StorageType::kPersistent, special_storage_policy_.get()));
+  syncable_usage_tracker_.reset(new UsageTracker(
+      clients_, StorageType::kSyncable, special_storage_policy_.get()));
 
   if (!is_incognito_) {
     histogram_timer_.Start(
diff --git a/storage/browser/quota/quota_manager.h b/storage/browser/quota/quota_manager.h
index 66e3bea..a110fe0 100644
--- a/storage/browser/quota/quota_manager.h
+++ b/storage/browser/quota/quota_manager.h
@@ -33,7 +33,6 @@
 #include "storage/browser/quota/quota_settings.h"
 #include "storage/browser/quota/quota_task.h"
 #include "storage/browser/quota/special_storage_policy.h"
-#include "storage/browser/quota/storage_observer.h"
 #include "third_party/blink/public/mojom/quota/quota_types.mojom-forward.h"
 
 namespace base {
@@ -50,7 +49,6 @@
 class MockQuotaManager;
 class MockStorageClient;
 class QuotaManagerTest;
-class StorageMonitorTest;
 }  // namespace content
 
 namespace storage {
@@ -58,7 +56,6 @@
 class QuotaDatabase;
 class QuotaManagerProxy;
 class QuotaTemporaryStorageEvictor;
-class StorageMonitor;
 class UsageTracker;
 
 struct QuotaManagerDeleter;
@@ -242,11 +239,6 @@
 
   bool ResetUsageTracker(blink::mojom::StorageType type);
 
-  // Used to register/deregister observers that wish to monitor storage events.
-  void AddStorageObserver(StorageObserver* observer,
-                          const StorageObserver::MonitorParams& params);
-  void RemoveStorageObserver(StorageObserver* observer);
-
   static const int64_t kPerHostPersistentQuotaLimit;
   static const char kDatabaseName[];
   static const int kThresholdOfErrorsToBeBlacklisted;
@@ -267,7 +259,6 @@
   friend class base::DeleteHelper<QuotaManager>;
   friend class base::RefCountedDeleteOnSequence<QuotaManager>;
   friend class content::QuotaManagerTest;
-  friend class content::StorageMonitorTest;
   friend class content::MockQuotaManager;
   friend class content::MockStorageClient;
   friend class quota_internals::QuotaInternalsProxy;
@@ -478,8 +469,6 @@
   // values. The default value points to QuotaManager::GetVolumeInfo.
   GetVolumeInfoFn get_volume_info_fn_;
 
-  std::unique_ptr<StorageMonitor> storage_monitor_;
-
   SEQUENCE_CHECKER(sequence_checker_);
 
   base::WeakPtrFactory<QuotaManager> weak_factory_;
diff --git a/storage/browser/quota/storage_monitor.cc b/storage/browser/quota/storage_monitor.cc
deleted file mode 100644
index 1d8e570..0000000
--- a/storage/browser/quota/storage_monitor.cc
+++ /dev/null
@@ -1,336 +0,0 @@
-// Copyright 2014 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 "storage/browser/quota/storage_monitor.h"
-
-#include <stdint.h>
-
-#include <algorithm>
-#include <memory>
-
-#include "base/bind.h"
-#include "net/base/url_util.h"
-#include "storage/browser/quota/quota_manager.h"
-
-namespace storage {
-
-// StorageObserverList:
-
-StorageObserverList::ObserverState::ObserverState()
-    : requires_update(false) {
-}
-
-StorageObserverList::StorageObserverList() = default;
-
-StorageObserverList::~StorageObserverList() = default;
-
-void StorageObserverList::AddObserver(
-    StorageObserver* observer, const StorageObserver::MonitorParams& params) {
-  ObserverState& observer_state = observer_state_map_[observer];
-  observer_state.origin = params.filter.origin;
-  observer_state.rate = params.rate;
-}
-
-void StorageObserverList::RemoveObserver(StorageObserver* observer) {
-  observer_state_map_.erase(observer);
-}
-
-size_t StorageObserverList::ObserverCount() const {
-  return observer_state_map_.size();
-}
-
-void StorageObserverList::OnStorageChange(const StorageObserver::Event& event) {
-  for (auto& observer_state_pair : observer_state_map_)
-    observer_state_pair.second.requires_update = true;
-
-  MaybeDispatchEvent(event);
-}
-
-void StorageObserverList::MaybeDispatchEvent(
-    const StorageObserver::Event& event) {
-  notification_timer_.Stop();
-  base::TimeDelta min_delay = base::TimeDelta::Max();
-  bool all_observers_notified = true;
-
-  for (auto& observer_state_pair : observer_state_map_) {
-    StorageObserver* observer = observer_state_pair.first;
-    ObserverState& state = observer_state_pair.second;
-
-    if (!state.requires_update)
-      continue;
-
-    base::TimeTicks current_time = base::TimeTicks::Now();
-    base::TimeDelta delta = current_time - state.last_notification_time;
-    if (state.last_notification_time.is_null() || delta >= state.rate) {
-      state.requires_update = false;
-      state.last_notification_time = current_time;
-
-      if (state.origin == event.filter.origin) {
-        observer->OnStorageEvent(event);
-      } else {
-        // When the quota and usage of an origin is requested, QuotaManager
-        // returns the quota and usage of the host. Multiple origins can map to
-        // to the same host, so ensure the |origin| field in the dispatched
-        // event matches the |origin| specified by the observer when it was
-        // registered.
-        StorageObserver::Event dispatch_event(event);
-        dispatch_event.filter.origin = state.origin;
-
-        observer->OnStorageEvent(dispatch_event);
-      }
-    } else {
-      all_observers_notified = false;
-      base::TimeDelta delay = state.rate - delta;
-      if (delay < min_delay)
-        min_delay = delay;
-    }
-  }
-
-  // We need to respect the notification rate specified by observers. So if it
-  // is too soon to dispatch an event to an observer, save the event and
-  // dispatch it after a delay. If we simply drop the event, another one may
-  // not arrive anytime soon and the observer will miss the most recent event.
-  if (!all_observers_notified) {
-    pending_event_ = event;
-    notification_timer_.Start(
-        FROM_HERE,
-        min_delay,
-        this,
-        &StorageObserverList::DispatchPendingEvent);
-  }
-}
-
-void StorageObserverList::ScheduleUpdateForObserver(StorageObserver* observer) {
-  DCHECK(base::Contains(observer_state_map_, observer));
-  observer_state_map_[observer].requires_update = true;
-}
-
-void StorageObserverList::DispatchPendingEvent() {
-  MaybeDispatchEvent(pending_event_);
-}
-
-
-// HostStorageObservers:
-
-HostStorageObservers::HostStorageObservers(QuotaManager* quota_manager)
-    : quota_manager_(quota_manager),
-      initialized_(false),
-      initializing_(false),
-      event_occurred_before_init_(false),
-      usage_deltas_during_init_(0),
-      cached_usage_(0),
-      cached_quota_(0),
-      weak_factory_(this) {
-}
-
-HostStorageObservers::~HostStorageObservers() = default;
-
-void HostStorageObservers::AddObserver(
-    StorageObserver* observer,
-    const StorageObserver::MonitorParams& params) {
-  observers_.AddObserver(observer, params);
-
-  if (!params.dispatch_initial_state)
-    return;
-
-  if (initialized_) {
-    StorageObserver::Event event(params.filter,
-                                 std::max<int64_t>(cached_usage_, 0),
-                                 std::max<int64_t>(cached_quota_, 0));
-    observer->OnStorageEvent(event);
-    return;
-  }
-
-  // Ensure the observer receives the initial storage state once initialization
-  // is complete.
-  observers_.ScheduleUpdateForObserver(observer);
-  StartInitialization(params.filter);
-}
-
-void HostStorageObservers::RemoveObserver(StorageObserver* observer) {
-  observers_.RemoveObserver(observer);
-}
-
-bool HostStorageObservers::ContainsObservers() const {
-  return observers_.ObserverCount() > 0;
-}
-
-void HostStorageObservers::NotifyUsageChange(
-    const StorageObserver::Filter& filter,
-    int64_t delta) {
-  if (initialized_) {
-    cached_usage_ += delta;
-    DispatchEvent(filter, true);
-    return;
-  }
-
-  // If a storage change occurs before initialization, ensure all observers will
-  // receive an event once initialization is complete.
-  event_occurred_before_init_ = true;
-
-  // During QuotaManager::GetUsageAndQuotaForWebApps(), cached data is read
-  // synchronously, but other data may be retrieved asynchronously. A usage
-  // change may occur between the function call and callback. These deltas need
-  // to be added to the usage received by GotHostUsageAndQuota() to ensure
-  // |cached_usage_| is correctly initialized.
-  if (initializing_) {
-    usage_deltas_during_init_ += delta;
-    return;
-  }
-
-  StartInitialization(filter);
-}
-
-void HostStorageObservers::StartInitialization(
-    const StorageObserver::Filter& filter) {
-  if (initialized_ || initializing_)
-    return;
-  initializing_ = true;
-  quota_manager_->GetUsageAndQuotaForWebApps(
-      filter.origin, filter.storage_type,
-      base::BindOnce(&HostStorageObservers::GotHostUsageAndQuota,
-                     weak_factory_.GetWeakPtr(), filter));
-}
-
-void HostStorageObservers::GotHostUsageAndQuota(
-    const StorageObserver::Filter& filter,
-    blink::mojom::QuotaStatusCode status,
-    int64_t usage,
-    int64_t quota) {
-  initializing_ = false;
-  if (status != blink::mojom::QuotaStatusCode::kOk)
-    return;
-  initialized_ = true;
-  cached_quota_ = quota;
-  cached_usage_ = usage + usage_deltas_during_init_;
-  DispatchEvent(filter, event_occurred_before_init_);
-}
-
-void HostStorageObservers::DispatchEvent(
-    const StorageObserver::Filter& filter, bool is_update) {
-  StorageObserver::Event event(filter, std::max<int64_t>(cached_usage_, 0),
-                               std::max<int64_t>(cached_quota_, 0));
-  if (is_update)
-    observers_.OnStorageChange(event);
-  else
-    observers_.MaybeDispatchEvent(event);
-}
-
-
-// StorageTypeObservers:
-
-StorageTypeObservers::StorageTypeObservers(QuotaManager* quota_manager)
-    : quota_manager_(quota_manager) {
-}
-
-StorageTypeObservers::~StorageTypeObservers() = default;
-
-void StorageTypeObservers::AddObserver(
-    StorageObserver* observer, const StorageObserver::MonitorParams& params) {
-  std::string host = net::GetHostOrSpecFromURL(params.filter.origin.GetURL());
-  if (host.empty())
-    return;
-
-  auto& host_observers = host_observers_map_[host];
-  if (!host_observers) {
-    // Because there are no null entries in host_observers_map_, the [] inserted
-    // a blank pointer, so let's populate it.
-    host_observers = std::make_unique<HostStorageObservers>(quota_manager_);
-  }
-
-  host_observers->AddObserver(observer, params);
-}
-
-void StorageTypeObservers::RemoveObserver(StorageObserver* observer) {
-  for (auto it = host_observers_map_.begin();
-       it != host_observers_map_.end();) {
-    it->second->RemoveObserver(observer);
-    if (!it->second->ContainsObservers()) {
-      it = host_observers_map_.erase(it);
-    } else {
-      ++it;
-    }
-  }
-}
-
-const HostStorageObservers* StorageTypeObservers::GetHostObservers(
-    const std::string& host) const {
-  auto it = host_observers_map_.find(host);
-  if (it != host_observers_map_.end())
-    return it->second.get();
-
-  return nullptr;
-}
-
-void StorageTypeObservers::NotifyUsageChange(
-    const StorageObserver::Filter& filter,
-    int64_t delta) {
-  std::string host = net::GetHostOrSpecFromURL(filter.origin.GetURL());
-  auto it = host_observers_map_.find(host);
-  if (it == host_observers_map_.end())
-    return;
-
-  it->second->NotifyUsageChange(filter, delta);
-}
-
-
-// StorageMonitor:
-
-StorageMonitor::StorageMonitor(QuotaManager* quota_manager)
-    : quota_manager_(quota_manager) {
-}
-
-StorageMonitor::~StorageMonitor() = default;
-
-void StorageMonitor::AddObserver(
-    StorageObserver* observer, const StorageObserver::MonitorParams& params) {
-  DCHECK(observer);
-
-  // Check preconditions.
-  if (params.filter.storage_type == blink::mojom::StorageType::kUnknown ||
-      params.filter.storage_type ==
-          blink::mojom::StorageType::kQuotaNotManaged) {
-    NOTREACHED();
-    return;
-  }
-
-  auto& type_observers =
-      storage_type_observers_map_[params.filter.storage_type];
-  if (!type_observers)
-    type_observers = std::make_unique<StorageTypeObservers>(quota_manager_);
-
-  type_observers->AddObserver(observer, params);
-}
-
-void StorageMonitor::RemoveObserver(StorageObserver* observer) {
-  for (const auto& type_observers_pair : storage_type_observers_map_)
-    type_observers_pair.second->RemoveObserver(observer);
-}
-
-const StorageTypeObservers* StorageMonitor::GetStorageTypeObservers(
-    blink::mojom::StorageType storage_type) const {
-  auto it = storage_type_observers_map_.find(storage_type);
-  if (it != storage_type_observers_map_.end())
-    return it->second.get();
-
-  return nullptr;
-}
-
-void StorageMonitor::NotifyUsageChange(const StorageObserver::Filter& filter,
-                                       int64_t delta) {
-  // Check preconditions.
-  if (filter.storage_type == blink::mojom::StorageType::kUnknown ||
-      filter.storage_type == blink::mojom::StorageType::kQuotaNotManaged) {
-    NOTREACHED();
-    return;
-  }
-
-  auto it = storage_type_observers_map_.find(filter.storage_type);
-  if (it == storage_type_observers_map_.end())
-    return;
-
-  it->second->NotifyUsageChange(filter, delta);
-}
-
-}  // namespace storage
diff --git a/storage/browser/quota/storage_monitor.h b/storage/browser/quota/storage_monitor.h
deleted file mode 100644
index 17ed854..0000000
--- a/storage/browser/quota/storage_monitor.h
+++ /dev/null
@@ -1,179 +0,0 @@
-// Copyright 2014 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.
-
-#ifndef STORAGE_BROWSER_QUOTA_STORAGE_MONITOR_H_
-#define STORAGE_BROWSER_QUOTA_STORAGE_MONITOR_H_
-
-#include <stdint.h>
-
-#include <map>
-#include <memory>
-
-#include "base/component_export.h"
-#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
-#include "base/time/time.h"
-#include "base/timer/timer.h"
-#include "storage/browser/quota/storage_observer.h"
-#include "third_party/blink/public/mojom/quota/quota_types.mojom.h"
-#include "url/origin.h"
-
-namespace content {
-class StorageMonitorTestBase;
-}
-
-namespace storage {
-
-class QuotaManager;
-
-// This class dispatches storage events to observers of a common
-// StorageObserver::Filter.
-class COMPONENT_EXPORT(STORAGE_BROWSER) StorageObserverList {
- public:
-  StorageObserverList();
-  virtual ~StorageObserverList();
-
-  // Adds/removes an observer.
-  void AddObserver(StorageObserver* observer,
-                   const StorageObserver::MonitorParams& params);
-  void RemoveObserver(StorageObserver* observer);
-
-  // Returns the number of observers.
-  size_t ObserverCount() const;
-
-  // Forwards a storage change to observers. The event may be dispatched
-  // immediately to an observer or after a delay, depending on the desired event
-  // rate of the observer.
-  void OnStorageChange(const StorageObserver::Event& event);
-
-  // Dispatch an event to observers that require it.
-  void MaybeDispatchEvent(const StorageObserver::Event& event);
-
-  // Ensure the specified observer receives the next dispatched event.
-  void ScheduleUpdateForObserver(StorageObserver* observer);
-
- private:
-  struct COMPONENT_EXPORT(STORAGE_BROWSER) ObserverState {
-    url::Origin origin;
-    base::TimeTicks last_notification_time;
-    base::TimeDelta rate;
-    bool requires_update;
-
-    ObserverState();
-  };
-
-  void DispatchPendingEvent();
-
-  std::map<StorageObserver*, ObserverState> observer_state_map_;
-  base::OneShotTimer notification_timer_;
-  StorageObserver::Event pending_event_;
-
-  friend class content::StorageMonitorTestBase;
-
-  DISALLOW_COPY_AND_ASSIGN(StorageObserverList);
-};
-
-// Manages the storage observers of a common host. Caches the usage and quota of
-// the host to avoid accumulating for every change.
-class COMPONENT_EXPORT(STORAGE_BROWSER) HostStorageObservers {
- public:
-  explicit HostStorageObservers(QuotaManager* quota_manager);
-  virtual ~HostStorageObservers();
-
-  bool is_initialized() const { return initialized_; }
-
-  // Adds/removes an observer.
-  void AddObserver(
-      StorageObserver* observer,
-      const StorageObserver::MonitorParams& params);
-  void RemoveObserver(StorageObserver* observer);
-  bool ContainsObservers() const;
-
-  // Handles a usage change.
-  void NotifyUsageChange(const StorageObserver::Filter& filter, int64_t delta);
-
- private:
-  void StartInitialization(const StorageObserver::Filter& filter);
-  void GotHostUsageAndQuota(const StorageObserver::Filter& filter,
-                            blink::mojom::QuotaStatusCode status,
-                            int64_t usage,
-                            int64_t quota);
-  void DispatchEvent(const StorageObserver::Filter& filter, bool is_update);
-
-  QuotaManager* quota_manager_;
-  StorageObserverList observers_;
-
-  // Flags used during initialization of the cached properties.
-  bool initialized_;
-  bool initializing_;
-  bool event_occurred_before_init_;
-  int64_t usage_deltas_during_init_;
-
-  // Cached accumulated usage and quota for the host.
-  int64_t cached_usage_;
-  int64_t cached_quota_;
-
-  base::WeakPtrFactory<HostStorageObservers> weak_factory_;
-
-  friend class content::StorageMonitorTestBase;
-
-  DISALLOW_COPY_AND_ASSIGN(HostStorageObservers);
-};
-
-// Manages the observers of a common storage type.
-class COMPONENT_EXPORT(STORAGE_BROWSER) StorageTypeObservers {
- public:
-  explicit StorageTypeObservers(QuotaManager* quota_manager);
-  virtual ~StorageTypeObservers();
-
-  // Adds and removes an observer.
-  void AddObserver(StorageObserver* observer,
-                   const StorageObserver::MonitorParams& params);
-  void RemoveObserver(StorageObserver* observer);
-
-  // Returns the observers of a specific host.
-  const HostStorageObservers* GetHostObservers(const std::string& host) const;
-
-  // Handles a usage change.
-  void NotifyUsageChange(const StorageObserver::Filter& filter, int64_t delta);
-
- private:
-  QuotaManager* quota_manager_;
-  std::map<std::string, std::unique_ptr<HostStorageObservers>>
-      host_observers_map_;
-
-  DISALLOW_COPY_AND_ASSIGN(StorageTypeObservers);
-};
-
-// Storage monitor manages observers and dispatches storage events to them.
-class COMPONENT_EXPORT(STORAGE_BROWSER) StorageMonitor {
- public:
-  explicit StorageMonitor(QuotaManager* quota_manager);
-  virtual ~StorageMonitor();
-
-  // Adds and removes an observer.
-  void AddObserver(StorageObserver* observer,
-                   const StorageObserver::MonitorParams& params);
-  void RemoveObserver(StorageObserver* observer);
-  void RemoveObserverForFilter(StorageObserver* observer,
-                               const StorageObserver::Filter& filter);
-
-  // Returns the observers of a specific storage type.
-  const StorageTypeObservers* GetStorageTypeObservers(
-      blink::mojom::StorageType storage_type) const;
-
-  // Handles a usage change.
-  void NotifyUsageChange(const StorageObserver::Filter& filter, int64_t delta);
-
- private:
-  QuotaManager* quota_manager_;
-  std::map<blink::mojom::StorageType, std::unique_ptr<StorageTypeObservers>>
-      storage_type_observers_map_;
-
-  DISALLOW_COPY_AND_ASSIGN(StorageMonitor);
-};
-
-}  // namespace storage
-
-#endif  // STORAGE_BROWSER_QUOTA_STORAGE_MONITOR_H_
diff --git a/storage/browser/quota/storage_monitor_unittest.cc b/storage/browser/quota/storage_monitor_unittest.cc
deleted file mode 100644
index 75378f2..0000000
--- a/storage/browser/quota/storage_monitor_unittest.cc
+++ /dev/null
@@ -1,679 +0,0 @@
-// Copyright 2014 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 <stdint.h>
-
-#include <vector>
-
-#include "base/files/scoped_temp_dir.h"
-#include "base/run_loop.h"
-#include "base/stl_util.h"
-#include "base/test/scoped_task_environment.h"
-#include "base/threading/thread_task_runner_handle.h"
-#include "net/base/url_util.h"
-#include "storage/browser/quota/quota_manager.h"
-#include "storage/browser/quota/quota_manager_proxy.h"
-#include "storage/browser/quota/storage_monitor.h"
-#include "storage/browser/quota/storage_observer.h"
-#include "storage/browser/test/mock_special_storage_policy.h"
-#include "storage/browser/test/mock_storage_client.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "url/gurl.h"
-#include "url/origin.h"
-
-using blink::mojom::QuotaStatusCode;
-using blink::mojom::StorageType;
-using storage::HostStorageObservers;
-using storage::QuotaClient;
-using storage::QuotaManager;
-using storage::SpecialStoragePolicy;
-using storage::StorageMonitor;
-using storage::StorageObserver;
-using storage::StorageObserverList;
-using storage::StorageTypeObservers;
-
-namespace content {
-
-namespace {
-
-// TODO(crbug.com/889590): Use helper for url::Origin creation from string.
-const url::Origin kDefaultOrigin =
-    url::Origin::Create(GURL("http://www.foo.com/"));
-const url::Origin kAlternativeOrigin =
-    url::Origin::Create(GURL("http://www.bar.com/"));
-
-class MockObserver : public StorageObserver {
- public:
-  const StorageObserver::Event& LastEvent() const {
-    CHECK(!events_.empty());
-    return events_.back();
-  }
-
-  size_t EventCount() const { return events_.size(); }
-
-  // StorageObserver implementation:
-  void OnStorageEvent(const StorageObserver::Event& event) override {
-    events_.push_back(event);
-  }
-
- private:
-  std::vector<StorageObserver::Event> events_;
-};
-
-// A mock quota manager for overriding GetUsageAndQuotaForWebApps().
-class UsageMockQuotaManager : public QuotaManager {
- public:
-  UsageMockQuotaManager(SpecialStoragePolicy* special_storage_policy)
-      : QuotaManager(false,
-                     base::FilePath(),
-                     base::ThreadTaskRunnerHandle::Get().get(),
-                     special_storage_policy,
-                     storage::GetQuotaSettingsFunc()),
-        callback_usage_(0),
-        callback_quota_(0),
-        callback_status_(QuotaStatusCode::kOk),
-        initialized_(false) {}
-
-  void SetCallbackParams(int64_t usage, int64_t quota, QuotaStatusCode status) {
-    initialized_ = true;
-    callback_quota_ = quota;
-    callback_usage_ = usage;
-    callback_status_ = status;
-  }
-
-  void InvokeCallback() {
-    std::move(delayed_callback_)
-        .Run(callback_status_, callback_usage_, callback_quota_);
-  }
-
-  void GetUsageAndQuotaForWebApps(const url::Origin& origin,
-                                  StorageType type,
-                                  UsageAndQuotaCallback callback) override {
-    if (initialized_)
-      std::move(callback).Run(callback_status_, callback_usage_,
-                              callback_quota_);
-    else
-      delayed_callback_ = std::move(callback);
-  }
-
- protected:
-  ~UsageMockQuotaManager() override = default;
-
- private:
-  int64_t callback_usage_;
-  int64_t callback_quota_;
-  QuotaStatusCode callback_status_;
-  bool initialized_;
-  UsageAndQuotaCallback delayed_callback_;
-};
-
-}  // namespace
-
-class StorageMonitorTestBase : public testing::Test {
- protected:
-  void DispatchPendingEvents(StorageObserverList& observer_list) {
-    observer_list.DispatchPendingEvent();
-  }
-
-  const StorageObserver::Event* GetPendingEvent(
-      const StorageObserverList& observer_list) {
-    return observer_list.notification_timer_.IsRunning()
-               ? &observer_list.pending_event_
-               : nullptr;
-  }
-
-  const StorageObserver::Event* GetPendingEvent(
-      const HostStorageObservers& host_observers) {
-    return GetPendingEvent(host_observers.observers_);
-  }
-
-  int GetRequiredUpdatesCount(const StorageObserverList& observer_list) {
-    int count = 0;
-    for (const auto& observer_state_pair : observer_list.observer_state_map_) {
-      if (observer_state_pair.second.requires_update)
-        ++count;
-    }
-
-    return count;
-  }
-
-  int GetRequiredUpdatesCount(const HostStorageObservers& host_observers) {
-    return GetRequiredUpdatesCount(host_observers.observers_);
-  }
-
-  void SetLastNotificationTime(StorageObserverList& observer_list,
-                               StorageObserver* observer) {
-    ASSERT_TRUE(base::Contains(observer_list.observer_state_map_, observer));
-    StorageObserverList::ObserverState& state =
-        observer_list.observer_state_map_[observer];
-    state.last_notification_time = base::TimeTicks::Now() - state.rate;
-  }
-
-  void SetLastNotificationTime(HostStorageObservers& host_observers,
-                               StorageObserver* observer) {
-    SetLastNotificationTime(host_observers.observers_, observer);
-  }
-
-  size_t GetObserverCount(const HostStorageObservers& host_observers) {
-    return host_observers.observers_.ObserverCount();
-  }
-
-  base::test::ScopedTaskEnvironment scoped_task_environment_;
-};
-
-class StorageTestWithManagerBase : public StorageMonitorTestBase {
- public:
-  void SetUp() override {
-    storage_policy_ = new MockSpecialStoragePolicy();
-    quota_manager_ = new UsageMockQuotaManager(storage_policy_.get());
-  }
-
-  void TearDown() override {
-    // This ensures the quota manager is destroyed correctly.
-    quota_manager_ = nullptr;
-    scoped_task_environment_.RunUntilIdle();
-  }
-
- protected:
-  scoped_refptr<MockSpecialStoragePolicy> storage_policy_;
-  scoped_refptr<UsageMockQuotaManager> quota_manager_;
-};
-
-// Tests for StorageObserverList:
-
-using StorageObserverListTest = StorageMonitorTestBase;
-
-// Test dispatching events to one observer.
-TEST_F(StorageObserverListTest, DispatchEventToSingleObserver) {
-  StorageObserver::MonitorParams params(StorageType::kPersistent,
-                                        kDefaultOrigin,
-                                        base::TimeDelta::FromHours(1), false);
-  MockObserver mock_observer;
-  StorageObserverList observer_list;
-  observer_list.AddObserver(&mock_observer, params);
-
-  StorageObserver::Event event;
-  event.filter = params.filter;
-
-  // Verify that the first event is dispatched immediately.
-  event.quota = 1;
-  event.usage = 1;
-  observer_list.OnStorageChange(event);
-  EXPECT_EQ(1u, mock_observer.EventCount());
-  EXPECT_EQ(event, mock_observer.LastEvent());
-  EXPECT_EQ(nullptr, GetPendingEvent(observer_list));
-  EXPECT_EQ(0, GetRequiredUpdatesCount(observer_list));
-
-  // Verify that the next event is pending.
-  event.quota = 2;
-  event.usage = 2;
-  observer_list.OnStorageChange(event);
-  EXPECT_EQ(1u, mock_observer.EventCount());
-  ASSERT_TRUE(GetPendingEvent(observer_list));
-  EXPECT_EQ(event, *GetPendingEvent(observer_list));
-  EXPECT_EQ(1, GetRequiredUpdatesCount(observer_list));
-
-  // Fake the last notification time so that an event will be dispatched.
-  SetLastNotificationTime(observer_list, &mock_observer);
-  event.quota = 3;
-  event.usage = 3;
-  observer_list.OnStorageChange(event);
-  EXPECT_EQ(2u, mock_observer.EventCount());
-  EXPECT_EQ(event, mock_observer.LastEvent());
-  EXPECT_EQ(nullptr, GetPendingEvent(observer_list));
-  EXPECT_EQ(0, GetRequiredUpdatesCount(observer_list));
-
-  // Remove the observer.
-  event.quota = 4;
-  event.usage = 4;
-  observer_list.RemoveObserver(&mock_observer);
-  observer_list.OnStorageChange(event);
-  EXPECT_EQ(2u, mock_observer.EventCount());
-  EXPECT_EQ(nullptr, GetPendingEvent(observer_list));
-}
-
-// Test dispatching events to multiple observers.
-TEST_F(StorageObserverListTest, DispatchEventToMultipleObservers) {
-  MockObserver mock_observer1;
-  MockObserver mock_observer2;
-  StorageObserverList observer_list;
-  StorageObserver::Filter filter(StorageType::kPersistent, kDefaultOrigin);
-  observer_list.AddObserver(
-      &mock_observer1,
-      StorageObserver::MonitorParams(
-          filter, base::TimeDelta::FromHours(1), false));
-  observer_list.AddObserver(
-      &mock_observer2,
-      StorageObserver::MonitorParams(
-          filter, base::TimeDelta::FromHours(2), false));
-
-  StorageObserver::Event event;
-  event.filter = filter;
-
-  // Verify that the first event is dispatched immediately.
-  event.quota = 1;
-  event.usage = 1;
-  observer_list.OnStorageChange(event);
-  EXPECT_EQ(1u, mock_observer1.EventCount());
-  EXPECT_EQ(1u, mock_observer2.EventCount());
-  EXPECT_EQ(event, mock_observer1.LastEvent());
-  EXPECT_EQ(event, mock_observer2.LastEvent());
-  EXPECT_EQ(nullptr, GetPendingEvent(observer_list));
-  EXPECT_EQ(0, GetRequiredUpdatesCount(observer_list));
-
-  // Fake the last notification time so that observer1 will receive the next
-  // event, but it will be pending for observer2.
-  SetLastNotificationTime(observer_list, &mock_observer1);
-  event.quota = 2;
-  event.usage = 2;
-  observer_list.OnStorageChange(event);
-  EXPECT_EQ(2u, mock_observer1.EventCount());
-  EXPECT_EQ(1u, mock_observer2.EventCount());
-  EXPECT_EQ(event, mock_observer1.LastEvent());
-  ASSERT_TRUE(GetPendingEvent(observer_list));
-  EXPECT_EQ(event, *GetPendingEvent(observer_list));
-  EXPECT_EQ(1, GetRequiredUpdatesCount(observer_list));
-
-  // Now dispatch the pending event to observer2.
-  SetLastNotificationTime(observer_list, &mock_observer2);
-  DispatchPendingEvents(observer_list);
-  EXPECT_EQ(2u, mock_observer1.EventCount());
-  EXPECT_EQ(2u, mock_observer2.EventCount());
-  EXPECT_EQ(event, mock_observer1.LastEvent());
-  EXPECT_EQ(event, mock_observer2.LastEvent());
-  EXPECT_EQ(nullptr, GetPendingEvent(observer_list));
-  EXPECT_EQ(0, GetRequiredUpdatesCount(observer_list));
-}
-
-// Ensure that the |origin| field in events match the origin specified by the
-// observer on registration.
-TEST_F(StorageObserverListTest, ReplaceEventOrigin) {
-  StorageObserver::MonitorParams params(StorageType::kPersistent,
-                                        kDefaultOrigin,
-                                        base::TimeDelta::FromHours(1), false);
-  MockObserver mock_observer;
-  StorageObserverList observer_list;
-  observer_list.AddObserver(&mock_observer, params);
-
-  StorageObserver::Event dispatched_event;
-  dispatched_event.filter = params.filter;
-  dispatched_event.filter.origin =
-      url::Origin::Create(GURL("https://www.foo.com/bar"));
-  observer_list.OnStorageChange(dispatched_event);
-
-  EXPECT_EQ(params.filter.origin, mock_observer.LastEvent().filter.origin);
-}
-
-// Tests for HostStorageObservers:
-
-using HostStorageObserversTest = StorageTestWithManagerBase;
-
-// Verify that HostStorageObservers is initialized after the first usage change.
-TEST_F(HostStorageObserversTest, InitializeOnUsageChange) {
-  StorageObserver::MonitorParams params(StorageType::kPersistent,
-                                        kDefaultOrigin,
-                                        base::TimeDelta::FromHours(1), false);
-  const int64_t kUsage = 324554;
-  const int64_t kQuota = 234354354;
-  quota_manager_->SetCallbackParams(kUsage, kQuota, QuotaStatusCode::kOk);
-
-  MockObserver mock_observer;
-  HostStorageObservers host_observers(quota_manager_.get());
-  host_observers.AddObserver(&mock_observer, params);
-
-  // Verify that HostStorageObservers dispatches the first event correctly.
-  StorageObserver::Event expected_event(params.filter, kUsage, kQuota);
-  host_observers.NotifyUsageChange(params.filter, 87324);
-  EXPECT_EQ(1u, mock_observer.EventCount());
-  EXPECT_EQ(expected_event, mock_observer.LastEvent());
-  EXPECT_TRUE(host_observers.is_initialized());
-
-  // Verify that HostStorageObservers handles subsequent usage changes
-  // correctly.
-  const int64_t kDelta = 2345;
-  expected_event.usage += kDelta;
-  SetLastNotificationTime(host_observers, &mock_observer);
-  host_observers.NotifyUsageChange(params.filter, kDelta);
-  EXPECT_EQ(2u, mock_observer.EventCount());
-  EXPECT_EQ(expected_event, mock_observer.LastEvent());
-}
-
-// Verify that HostStorageObservers is initialized after the adding the first
-// observer that elected to receive the initial state.
-TEST_F(HostStorageObserversTest, InitializeOnObserver) {
-  const int64_t kUsage = 74387;
-  const int64_t kQuota = 92834743;
-  quota_manager_->SetCallbackParams(kUsage, kQuota, QuotaStatusCode::kOk);
-  HostStorageObservers host_observers(quota_manager_.get());
-
-  // |host_observers| should not be initialized after the first observer is
-  // added because it did not elect to receive the initial state.
-  StorageObserver::MonitorParams params(StorageType::kPersistent,
-                                        kDefaultOrigin,
-                                        base::TimeDelta::FromHours(1), false);
-  MockObserver mock_observer1;
-  host_observers.AddObserver(&mock_observer1, params);
-  EXPECT_FALSE(host_observers.is_initialized());
-  EXPECT_EQ(0u, mock_observer1.EventCount());
-
-  // |host_observers| should be initialized after the second observer is
-  // added.
-  MockObserver mock_observer2;
-  params.dispatch_initial_state = true;
-  host_observers.AddObserver(&mock_observer2, params);
-  StorageObserver::Event expected_event(params.filter, kUsage, kQuota);
-  EXPECT_EQ(0u, mock_observer1.EventCount());
-  EXPECT_EQ(1u, mock_observer2.EventCount());
-  EXPECT_EQ(expected_event, mock_observer2.LastEvent());
-  EXPECT_TRUE(host_observers.is_initialized());
-  EXPECT_EQ(nullptr, GetPendingEvent(host_observers));
-  EXPECT_EQ(0, GetRequiredUpdatesCount(host_observers));
-
-  // Verify that both observers will receive events after a usage change.
-  const int64_t kDelta = 2345;
-  expected_event.usage += kDelta;
-  SetLastNotificationTime(host_observers, &mock_observer2);
-  host_observers.NotifyUsageChange(params.filter, kDelta);
-  EXPECT_EQ(1u, mock_observer1.EventCount());
-  EXPECT_EQ(2u, mock_observer2.EventCount());
-  EXPECT_EQ(expected_event, mock_observer1.LastEvent());
-  EXPECT_EQ(expected_event, mock_observer2.LastEvent());
-  EXPECT_EQ(nullptr, GetPendingEvent(host_observers));
-  EXPECT_EQ(0, GetRequiredUpdatesCount(host_observers));
-
-  // Verify that the addition of a third observer only causes an event to be
-  // dispatched to the new observer.
-  MockObserver mock_observer3;
-  params.dispatch_initial_state = true;
-  host_observers.AddObserver(&mock_observer3, params);
-  EXPECT_EQ(1u, mock_observer1.EventCount());
-  EXPECT_EQ(2u, mock_observer2.EventCount());
-  EXPECT_EQ(1u, mock_observer3.EventCount());
-  EXPECT_EQ(expected_event, mock_observer3.LastEvent());
-}
-
-// Verify that negative usage and quota is changed to zero.
-TEST_F(HostStorageObserversTest, NegativeUsageAndQuota) {
-  StorageObserver::MonitorParams params(StorageType::kPersistent,
-                                        kDefaultOrigin,
-                                        base::TimeDelta::FromHours(1), false);
-  const int64_t kUsage = -324554;
-  const int64_t kQuota = -234354354;
-  quota_manager_->SetCallbackParams(kUsage, kQuota, QuotaStatusCode::kOk);
-
-  MockObserver mock_observer;
-  HostStorageObservers host_observers(quota_manager_.get());
-  host_observers.AddObserver(&mock_observer, params);
-
-  StorageObserver::Event expected_event(params.filter, 0, 0);
-  host_observers.NotifyUsageChange(params.filter, -87324);
-  EXPECT_EQ(expected_event, mock_observer.LastEvent());
-}
-
-// Verify that HostStorageObservers can recover from a bad initialization.
-TEST_F(HostStorageObserversTest, RecoverFromBadUsageInit) {
-  StorageObserver::MonitorParams params(StorageType::kPersistent,
-                                        kDefaultOrigin,
-                                        base::TimeDelta::FromHours(1), false);
-  MockObserver mock_observer;
-  HostStorageObservers host_observers(quota_manager_.get());
-  host_observers.AddObserver(&mock_observer, params);
-
-  // Set up the quota manager to return an error status.
-  const int64_t kUsage = 6656;
-  const int64_t kQuota = 99585556;
-  quota_manager_->SetCallbackParams(kUsage, kQuota,
-                                    QuotaStatusCode::kErrorNotSupported);
-
-  // Verify that |host_observers| is not initialized and an event has not been
-  // dispatched.
-  host_observers.NotifyUsageChange(params.filter, 9438);
-  EXPECT_EQ(0u, mock_observer.EventCount());
-  EXPECT_FALSE(host_observers.is_initialized());
-  EXPECT_EQ(nullptr, GetPendingEvent(host_observers));
-  EXPECT_EQ(0, GetRequiredUpdatesCount(host_observers));
-
-  // Now ensure that quota manager returns a good status.
-  quota_manager_->SetCallbackParams(kUsage, kQuota, QuotaStatusCode::kOk);
-  host_observers.NotifyUsageChange(params.filter, 9048543);
-  StorageObserver::Event expected_event(params.filter, kUsage, kQuota);
-  EXPECT_EQ(1u, mock_observer.EventCount());
-  EXPECT_EQ(expected_event, mock_observer.LastEvent());
-  EXPECT_TRUE(host_observers.is_initialized());
-}
-
-// Verify that HostStorageObservers handle initialization of the cached usage
-// and quota correctly.
-TEST_F(HostStorageObserversTest, AsyncInitialization) {
-  StorageObserver::MonitorParams params(StorageType::kPersistent,
-                                        kDefaultOrigin,
-                                        base::TimeDelta::FromHours(1), false);
-  MockObserver mock_observer;
-  HostStorageObservers host_observers(quota_manager_.get());
-  host_observers.AddObserver(&mock_observer, params);
-
-  // Trigger initialization. Leave the mock quota manager uninitialized so that
-  // the callback is not invoked.
-  host_observers.NotifyUsageChange(params.filter, 7645);
-  EXPECT_EQ(0u, mock_observer.EventCount());
-  EXPECT_FALSE(host_observers.is_initialized());
-  EXPECT_EQ(nullptr, GetPendingEvent(host_observers));
-  EXPECT_EQ(0, GetRequiredUpdatesCount(host_observers));
-
-  // Simulate notifying |host_observers| of a usage change before initialization
-  // is complete.
-  const int64_t kUsage = 6656;
-  const int64_t kQuota = 99585556;
-  const int64_t kDelta = 327643;
-  host_observers.NotifyUsageChange(params.filter, kDelta);
-  EXPECT_EQ(0u, mock_observer.EventCount());
-  EXPECT_FALSE(host_observers.is_initialized());
-  EXPECT_EQ(nullptr, GetPendingEvent(host_observers));
-  EXPECT_EQ(0, GetRequiredUpdatesCount(host_observers));
-
-  // Simulate an asynchronous callback from QuotaManager.
-  quota_manager_->SetCallbackParams(kUsage, kQuota, QuotaStatusCode::kOk);
-  quota_manager_->InvokeCallback();
-  StorageObserver::Event expected_event(params.filter, kUsage + kDelta, kQuota);
-  EXPECT_EQ(1u, mock_observer.EventCount());
-  EXPECT_EQ(expected_event, mock_observer.LastEvent());
-  EXPECT_TRUE(host_observers.is_initialized());
-  EXPECT_EQ(nullptr, GetPendingEvent(host_observers));
-  EXPECT_EQ(0, GetRequiredUpdatesCount(host_observers));
-}
-
-// Tests for StorageTypeObservers:
-
-using StorageTypeObserversTest = StorageTestWithManagerBase;
-
-// Test adding and removing observers.
-TEST_F(StorageTypeObserversTest, AddRemoveObservers) {
-  StorageTypeObservers type_observers(quota_manager_.get());
-
-  StorageObserver::MonitorParams params1(StorageType::kPersistent,
-                                         kDefaultOrigin,
-                                         base::TimeDelta::FromHours(1), false);
-  StorageObserver::MonitorParams params2(StorageType::kPersistent,
-                                         kAlternativeOrigin,
-                                         base::TimeDelta::FromHours(1), false);
-  std::string host1 = net::GetHostOrSpecFromURL(params1.filter.origin.GetURL());
-  std::string host2 = net::GetHostOrSpecFromURL(params2.filter.origin.GetURL());
-
-  MockObserver mock_observer1;
-  MockObserver mock_observer2;
-  MockObserver mock_observer3;
-  type_observers.AddObserver(&mock_observer1, params1);
-  type_observers.AddObserver(&mock_observer2, params1);
-
-  type_observers.AddObserver(&mock_observer1, params2);
-  type_observers.AddObserver(&mock_observer2, params2);
-  type_observers.AddObserver(&mock_observer3, params2);
-
-  // Verify that the observers have been removed correctly.
-  ASSERT_TRUE(type_observers.GetHostObservers(host1));
-  ASSERT_TRUE(type_observers.GetHostObservers(host2));
-  EXPECT_EQ(2u, GetObserverCount(*type_observers.GetHostObservers(host1)));
-  EXPECT_EQ(3u, GetObserverCount(*type_observers.GetHostObservers(host2)));
-
-  // Remove all instances of observer1.
-  type_observers.RemoveObserver(&mock_observer1);
-  ASSERT_TRUE(type_observers.GetHostObservers(host1));
-  ASSERT_TRUE(type_observers.GetHostObservers(host2));
-  EXPECT_EQ(1u, GetObserverCount(*type_observers.GetHostObservers(host1)));
-  EXPECT_EQ(2u, GetObserverCount(*type_observers.GetHostObservers(host2)));
-
-  // Remove all instances of observer2.
-  type_observers.RemoveObserver(&mock_observer2);
-  ASSERT_TRUE(type_observers.GetHostObservers(host2));
-  EXPECT_EQ(1u, GetObserverCount(*type_observers.GetHostObservers(host2)));
-  // Observers of host1 has been deleted as it is empty.
-  EXPECT_FALSE(type_observers.GetHostObservers(host1));
-}
-
-// Tests for StorageMonitor:
-
-class StorageMonitorTest : public StorageTestWithManagerBase {
- public:
-  StorageMonitorTest()
-      : storage_monitor_(nullptr),
-        params1_(StorageType::kTemporary,
-                 kDefaultOrigin,
-                 base::TimeDelta::FromHours(1),
-                 false),
-        params2_(StorageType::kPersistent,
-                 kDefaultOrigin,
-                 base::TimeDelta::FromHours(1),
-                 false) {}
-
- protected:
-  void SetUp() override {
-    StorageTestWithManagerBase::SetUp();
-
-    storage_monitor_ = quota_manager_->storage_monitor_.get();
-    host_ = net::GetHostOrSpecFromURL(params1_.filter.origin.GetURL());
-
-    storage_monitor_->AddObserver(&mock_observer1_, params1_);
-    storage_monitor_->AddObserver(&mock_observer2_, params1_);
-
-    storage_monitor_->AddObserver(&mock_observer1_, params2_);
-    storage_monitor_->AddObserver(&mock_observer2_, params2_);
-    storage_monitor_->AddObserver(&mock_observer3_, params2_);
-  }
-
-  size_t GetObserverCount(StorageType storage_type) {
-    const StorageTypeObservers* type_observers =
-        storage_monitor_->GetStorageTypeObservers(storage_type);
-    return StorageMonitorTestBase::GetObserverCount(
-                *type_observers->GetHostObservers(host_));
-  }
-
-  void CheckObserverCount(size_t expected_temporary,
-                          size_t expected_persistent) {
-    ASSERT_TRUE(
-        storage_monitor_->GetStorageTypeObservers(StorageType::kTemporary));
-    ASSERT_TRUE(
-        storage_monitor_->GetStorageTypeObservers(StorageType::kTemporary)
-            ->GetHostObservers(host_));
-    EXPECT_EQ(expected_temporary, GetObserverCount(StorageType::kTemporary));
-
-    ASSERT_TRUE(
-        storage_monitor_->GetStorageTypeObservers(StorageType::kPersistent));
-    ASSERT_TRUE(
-        storage_monitor_->GetStorageTypeObservers(StorageType::kPersistent)
-            ->GetHostObservers(host_));
-    EXPECT_EQ(expected_persistent, GetObserverCount(StorageType::kPersistent));
-  }
-
-  StorageMonitor* storage_monitor_;
-  StorageObserver::MonitorParams params1_;
-  StorageObserver::MonitorParams params2_;
-  MockObserver mock_observer1_;
-  MockObserver mock_observer2_;
-  MockObserver mock_observer3_;
-  std::string host_;
-};
-
-// Test adding storage observers.
-TEST_F(StorageMonitorTest, AddObservers) {
-  // Verify that the observers are added correctly.
-  CheckObserverCount(2, 3);
-}
-
-// Test dispatching events to storage observers.
-TEST_F(StorageMonitorTest, EventDispatch) {
-  // Verify dispatch of events.
-  const int64_t kUsage = 5325;
-  const int64_t kQuota = 903845;
-  quota_manager_->SetCallbackParams(kUsage, kQuota, QuotaStatusCode::kOk);
-  storage_monitor_->NotifyUsageChange(params1_.filter, 9048543);
-
-  StorageObserver::Event expected_event(params1_.filter, kUsage, kQuota);
-  EXPECT_EQ(1u, mock_observer1_.EventCount());
-  EXPECT_EQ(1u, mock_observer2_.EventCount());
-  EXPECT_EQ(0u, mock_observer3_.EventCount());
-  EXPECT_EQ(expected_event, mock_observer1_.LastEvent());
-  EXPECT_EQ(expected_event, mock_observer2_.LastEvent());
-}
-
-// Test removing all instances of an observer.
-TEST_F(StorageMonitorTest, RemoveObserver) {
-  storage_monitor_->RemoveObserver(&mock_observer1_);
-  CheckObserverCount(1, 2);
-}
-
-// Integration test for QuotaManager and StorageMonitor:
-
-class StorageMonitorIntegrationTest : public testing::Test {
- public:
-  void SetUp() override {
-    ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
-    storage_policy_ = new MockSpecialStoragePolicy();
-    quota_manager_ = new QuotaManager(
-        false, data_dir_.GetPath(), base::ThreadTaskRunnerHandle::Get().get(),
-        storage_policy_.get(), storage::GetQuotaSettingsFunc());
-
-    client_ = new MockStorageClient(quota_manager_->proxy(), nullptr,
-                                    QuotaClient::kFileSystem, 0);
-
-    quota_manager_->proxy()->RegisterClient(client_);
-  }
-
-  void TearDown() override {
-    // This ensures the quota manager is destroyed correctly.
-    quota_manager_ = nullptr;
-    scoped_task_environment_.RunUntilIdle();
-  }
-
- protected:
-  base::test::ScopedTaskEnvironment scoped_task_environment_;
-  base::ScopedTempDir data_dir_;
-  scoped_refptr<MockSpecialStoragePolicy> storage_policy_;
-  scoped_refptr<QuotaManager> quota_manager_;
-  MockStorageClient* client_;
-};
-
-// This test simulates a usage change in a quota client and verifies that a
-// storage observer will receive a storage event.
-TEST_F(StorageMonitorIntegrationTest, NotifyUsageEvent) {
-  const StorageType kTestStorageType = StorageType::kPersistent;
-  const int64_t kTestUsage = 234743;
-
-  // Register the observer.
-  StorageObserver::MonitorParams params(kTestStorageType, kDefaultOrigin,
-                                        base::TimeDelta::FromHours(1), false);
-  MockObserver mock_observer;
-  quota_manager_->AddStorageObserver(&mock_observer, params);
-
-  // Fire a usage change.
-  client_->AddOriginAndNotify(kDefaultOrigin, kTestStorageType, kTestUsage);
-  scoped_task_environment_.RunUntilIdle();
-
-  // Verify that the observer receives it.
-  ASSERT_EQ(1u, mock_observer.EventCount());
-  const StorageObserver::Event& event = mock_observer.LastEvent();
-  EXPECT_EQ(params.filter, event.filter);
-  EXPECT_EQ(kTestUsage, event.usage);
-}
-
-}  // namespace content
diff --git a/storage/browser/quota/storage_observer.cc b/storage/browser/quota/storage_observer.cc
deleted file mode 100644
index b7ab0b1b..0000000
--- a/storage/browser/quota/storage_observer.cc
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2014 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 "storage/browser/quota/storage_observer.h"
-
-#include <stdint.h>
-
-#include "third_party/blink/public/mojom/quota/quota_types.mojom-shared.h"
-
-namespace storage {
-
-// StorageObserver::Filter
-
-StorageObserver::Filter::Filter()
-    : storage_type(blink::mojom::StorageType::kUnknown) {}
-
-StorageObserver::Filter::Filter(blink::mojom::StorageType storage_type,
-                                const url::Origin& origin)
-    : storage_type(storage_type), origin(origin) {}
-
-bool StorageObserver::Filter::operator==(const Filter& other) const {
-  return storage_type == other.storage_type &&
-         origin == other.origin;
-}
-
-// StorageObserver::MonitorParams
-
-StorageObserver::MonitorParams::MonitorParams()
-    : dispatch_initial_state(false) {
-}
-
-StorageObserver::MonitorParams::MonitorParams(
-    blink::mojom::StorageType storage_type,
-    const url::Origin& origin,
-    const base::TimeDelta& rate,
-    bool get_initial_state)
-    : filter(storage_type, origin),
-      rate(rate),
-      dispatch_initial_state(get_initial_state) {}
-
-StorageObserver::MonitorParams::MonitorParams(
-    const Filter& filter,
-    const base::TimeDelta& rate,
-    bool get_initial_state)
-        : filter(filter),
-          rate(rate),
-          dispatch_initial_state(get_initial_state) {
-}
-
-// StorageObserver::Event
-
-StorageObserver::Event::Event()
-    : usage(0), quota(0) {
-}
-
-StorageObserver::Event::Event(const Filter& filter,
-                              int64_t usage,
-                              int64_t quota)
-    : filter(filter), usage(usage), quota(quota) {}
-
-bool StorageObserver::Event::operator==(const Event& other) const {
-  return filter == other.filter &&
-         usage == other.usage &&
-         quota == other.quota;
-}
-
-}  // namespace storage
diff --git a/storage/browser/quota/storage_observer.h b/storage/browser/quota/storage_observer.h
deleted file mode 100644
index e38c19a..0000000
--- a/storage/browser/quota/storage_observer.h
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright 2014 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.
-
-#ifndef STORAGE_BROWSER_QUOTA_STORAGE_OBSERVER_H_
-#define STORAGE_BROWSER_QUOTA_STORAGE_OBSERVER_H_
-
-#include <stdint.h>
-
-#include "base/component_export.h"
-#include "base/time/time.h"
-#include "storage/browser/quota/quota_client.h"
-#include "third_party/blink/public/mojom/quota/quota_types.mojom-forward.h"
-#include "url/origin.h"
-
-namespace storage {
-
-// This interface is implemented by observers that wish to monitor storage
-// events, such as changes in quota or usage.
-class COMPONENT_EXPORT(STORAGE_BROWSER) StorageObserver {
- public:
-  struct COMPONENT_EXPORT(STORAGE_BROWSER) Filter {
-    // The storage type to monitor. This must not be kUnknown or
-    // kQuotaNotManaged.
-    blink::mojom::StorageType storage_type;
-
-    // The origin to monitor usage for. Must be specified.
-    url::Origin origin;
-
-    Filter();
-    Filter(blink::mojom::StorageType storage_type, const url::Origin& origin);
-    bool operator==(const Filter& other) const;
-  };
-
-  struct COMPONENT_EXPORT(STORAGE_BROWSER) MonitorParams {
-    // Storage type and origin to monitor.
-    Filter filter;
-
-    // The rate at which storage events will be fired. Events will be fired at
-    // approximately this rate, or when a storage status change has been
-    // detected, whichever is the least frequent.
-    base::TimeDelta rate;
-
-    // If set to true, the observer will be dispatched an event when added.
-    bool dispatch_initial_state;
-
-    MonitorParams();
-    MonitorParams(blink::mojom::StorageType storage_type,
-                  const url::Origin& origin,
-                  const base::TimeDelta& rate,
-                  bool get_initial_state);
-    MonitorParams(const Filter& filter,
-                  const base::TimeDelta& rate,
-                  bool get_initial_state);
-  };
-
-  struct COMPONENT_EXPORT(STORAGE_BROWSER) Event {
-    // The storage type and origin monitored.
-    Filter filter;
-
-    // The current usage corresponding to the filter.
-    int64_t usage;
-
-    // The quota corresponding to the filter.
-    int64_t quota;
-
-    Event();
-    Event(const Filter& filter, int64_t usage, int64_t quota);
-    bool operator==(const Event& other) const;
-  };
-
-  // Will be called on the IO thread when a storage event occurs.
-  virtual void OnStorageEvent(const Event& event) = 0;
-
- protected:
-  virtual ~StorageObserver() {}
-};
-
-}  // namespace storage
-
-#endif  // STORAGE_BROWSER_QUOTA_STORAGE_OBSERVER_H_
diff --git a/storage/browser/quota/usage_tracker.cc b/storage/browser/quota/usage_tracker.cc
index 8f3516d..989a9bc 100644
--- a/storage/browser/quota/usage_tracker.cc
+++ b/storage/browser/quota/usage_tracker.cc
@@ -12,7 +12,6 @@
 #include "base/barrier_closure.h"
 #include "base/bind.h"
 #include "storage/browser/quota/client_usage_tracker.h"
-#include "storage/browser/quota/storage_monitor.h"
 
 namespace storage {
 
@@ -35,13 +34,12 @@
 
 UsageTracker::UsageTracker(const std::vector<QuotaClient*>& clients,
                            blink::mojom::StorageType type,
-                           SpecialStoragePolicy* special_storage_policy,
-                           StorageMonitor* storage_monitor)
-    : type_(type), storage_monitor_(storage_monitor), weak_factory_(this) {
+                           SpecialStoragePolicy* special_storage_policy)
+    : type_(type), weak_factory_(this) {
   for (auto* client : clients) {
     if (client->DoesSupport(type)) {
       client_tracker_map_[client->id()] = std::make_unique<ClientUsageTracker>(
-          this, client, type, special_storage_policy, storage_monitor_);
+          this, client, type, special_storage_policy);
     }
   }
 }
diff --git a/storage/browser/quota/usage_tracker.h b/storage/browser/quota/usage_tracker.h
index 74bcb1f..59a5385e 100644
--- a/storage/browser/quota/usage_tracker.h
+++ b/storage/browser/quota/usage_tracker.h
@@ -27,7 +27,6 @@
 namespace storage {
 
 class ClientUsageTracker;
-class StorageMonitor;
 
 // A helper class that gathers and tracks the amount of data stored in
 // all quota clients.
@@ -37,8 +36,7 @@
  public:
   UsageTracker(const std::vector<QuotaClient*>& clients,
                blink::mojom::StorageType type,
-               SpecialStoragePolicy* special_storage_policy,
-               StorageMonitor* storage_monitor);
+               SpecialStoragePolicy* special_storage_policy);
   ~UsageTracker() override;
 
   blink::mojom::StorageType type() const {
@@ -103,8 +101,6 @@
   std::map<std::string, std::vector<UsageWithBreakdownCallback>>
       host_usage_callbacks_;
 
-  StorageMonitor* storage_monitor_;
-
   SEQUENCE_CHECKER(sequence_checker_);
 
   base::WeakPtrFactory<UsageTracker> weak_factory_;
diff --git a/storage/browser/quota/usage_tracker_unittest.cc b/storage/browser/quota/usage_tracker_unittest.cc
index dbb4897..720d756 100644
--- a/storage/browser/quota/usage_tracker_unittest.cc
+++ b/storage/browser/quota/usage_tracker_unittest.cc
@@ -128,8 +128,7 @@
       : storage_policy_(new MockSpecialStoragePolicy()),
         usage_tracker_(GetUsageTrackerList(),
                        StorageType::kTemporary,
-                       storage_policy_.get(),
-                       nullptr) {}
+                       storage_policy_.get()) {}
 
   ~UsageTrackerTest() override = default;