summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/platform/instrumentation/resource_coordinator/document_resource_coordinator.h
blob: 73797f732ca7e64e5ac5907b0f5bf1c895ef7f05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2017 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 THIRD_PARTY_BLINK_RENDERER_PLATFORM_INSTRUMENTATION_RESOURCE_COORDINATOR_DOCUMENT_RESOURCE_COORDINATOR_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_INSTRUMENTATION_RESOURCE_COORDINATOR_DOCUMENT_RESOURCE_COORDINATOR_H_

#include <memory>

#include "base/macros.h"
#include "components/performance_manager/public/mojom/coordination_unit.mojom-blink.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "third_party/blink/renderer/platform/platform_export.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"

namespace blink {

class BrowserInterfaceBrokerProxy;

class PLATFORM_EXPORT DocumentResourceCoordinator final {
  USING_FAST_MALLOC(DocumentResourceCoordinator);

 public:
  // Returns nullptr if instrumentation is not enabled.
  static std::unique_ptr<DocumentResourceCoordinator> MaybeCreate(
      const BrowserInterfaceBrokerProxy&);
  ~DocumentResourceCoordinator();

  void SetNetworkAlmostIdle();
  void SetLifecycleState(performance_manager::mojom::LifecycleState);
  void SetHasNonEmptyBeforeUnload(bool has_nonempty_beforeunload);
  void SetOriginTrialFreezePolicy(
      performance_manager::mojom::InterventionPolicy policy);
  // A one way switch that marks a frame as being an adframe.
  void SetIsAdFrame();
  void OnNonPersistentNotificationCreated();
  void SetHadFormInteraction();

 private:
  explicit DocumentResourceCoordinator(const BrowserInterfaceBrokerProxy&);

  mojo::Remote<performance_manager::mojom::blink::DocumentCoordinationUnit>
      service_;

  bool had_form_interaction_ = false;

  DISALLOW_COPY_AND_ASSIGN(DocumentResourceCoordinator);
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_PLATFORM_INSTRUMENTATION_RESOURCE_COORDINATOR_DOCUMENT_RESOURCE_COORDINATOR_H_