
Previously, there was a content::LockObserver that both IndexedDB (via IndexedDBExecutionContextConnectionTracker) and web locks (via content::LockManager) would talk to in order to let performance_manager::PerformanceManagerLockObserver know whether or not a particular frame was using either IndexedDB or web locks. This moves the tracking of both of these features into the renderer behind a blink.mojom.FeatureObserver interface which still plumbs through to the same (now) PerformanceManagerFeatureObserver functions. This interface allows the renderer to send an empty ObservedFeature interface, whose lifetime is associated with how long that frame is using it. When the renderer is done, it can close the mojo pipe. For locks, the LockManager owns the FeatureObserver remote pipe. When pending requests are made, the LockRequestImpl owns an ObservedFeature, so that frames with outstanding requests will not be frozen. If the lock is granted, it is passed to the Lock object, where it is held until it is released or the lock is stolen. The blink IndexedDB implementation behaves similarly to locks. IDBFactory gets the appropriate FeatureObserver for this frame and gives it to WebIDBFactory(Impl). This is used to send the ObservedFeature to whenever an IDBOpenDBRequest is created, with the other end of the pipe living temporarily in IDBOpenDBRequest. When the callback completes (if it completes successfully), it is moved into the new IDBDatabase and lives there until that object is destroyed or the database is closed. Change-Id: I4b8a0bb66d758fe20af836f2992199e8867671c2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2015860 Commit-Queue: enne <enne@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Marijn Kruisselbrink <mek@chromium.org> Reviewed-by: François Doray <fdoray@chromium.org> Reviewed-by: Daniel Murphy <dmurph@chromium.org> Cr-Commit-Position: refs/heads/master@{#739579}
55 lines
2.0 KiB
C++
55 lines
2.0 KiB
C++
// Copyright 2019 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 CONTENT_BROWSER_FEATURE_OBSERVER_H_
|
|
#define CONTENT_BROWSER_FEATURE_OBSERVER_H_
|
|
|
|
#include "base/containers/stack_container.h"
|
|
#include "base/macros.h"
|
|
#include "content/common/content_export.h"
|
|
#include "content/public/browser/global_routing_id.h"
|
|
#include "mojo/public/cpp/bindings/receiver_set.h"
|
|
#include "third_party/blink/public/mojom/feature_observer/feature_observer.mojom.h"
|
|
|
|
namespace content {
|
|
|
|
class FeatureObserverClient;
|
|
|
|
// Observer interface to be notified when frames hold resources.
|
|
// client interfaces will be called on the same sequence GetFeatureObserver is
|
|
// called from.
|
|
class CONTENT_EXPORT FeatureObserver : public blink::mojom::FeatureObserver {
|
|
public:
|
|
// |client_| must outlive FeatureObserver.
|
|
FeatureObserver(FeatureObserverClient* client, GlobalFrameRoutingId id);
|
|
~FeatureObserver() override;
|
|
|
|
FeatureObserver(const FeatureObserver&) = delete;
|
|
FeatureObserver& operator=(const FeatureObserver&) = delete;
|
|
|
|
void GetFeatureObserver(
|
|
mojo::PendingReceiver<blink::mojom::FeatureObserver> receiver);
|
|
|
|
// blink::mojom::FeatureObserver implementation:
|
|
// For a given FeatureObserver receiver passed in through Bind, register the
|
|
// lifetime of a feature of a given type.
|
|
void Register(mojo::PendingReceiver<blink::mojom::ObservedFeature> feature,
|
|
blink::mojom::ObservedFeatureType type) override;
|
|
|
|
private:
|
|
// FeatureObservers notifying us about features used in this frame.
|
|
mojo::ReceiverSet<blink::mojom::FeatureObserver> observers_;
|
|
|
|
// Registered features.
|
|
mojo::ReceiverSet<blink::mojom::ObservedFeature> features_by_type_
|
|
[static_cast<int>(blink::mojom::ObservedFeatureType::kMaxValue) + 1];
|
|
|
|
FeatureObserverClient* const client_;
|
|
const GlobalFrameRoutingId id_;
|
|
};
|
|
|
|
} // namespace content
|
|
|
|
#endif // CONTENT_BROWSER_FEATURE_OBSERVER_H_
|