File: mock_attribution_manager.h

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (165 lines) | stat: -rw-r--r-- 5,903 bytes parent folder | download | duplicates (6)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_ATTRIBUTION_REPORTING_TEST_MOCK_ATTRIBUTION_MANAGER_H_
#define CONTENT_BROWSER_ATTRIBUTION_REPORTING_TEST_MOCK_ATTRIBUTION_MANAGER_H_

#include <stdint.h>

#include <memory>
#include <optional>
#include <set>
#include <vector>

#include "base/functional/callback.h"
#include "base/observer_list.h"
#include "base/time/time.h"
#include "components/attribution_reporting/registration_header_error.h"
#include "components/attribution_reporting/suitable_origin.h"
#include "content/browser/attribution_reporting/attribution_manager.h"
#include "content/browser/attribution_reporting/attribution_observer.h"
#include "content/browser/attribution_reporting/attribution_report.h"
#include "content/browser/attribution_reporting/attribution_reporting.mojom-forward.h"
#include "content/browser/attribution_reporting/attribution_trigger.h"
#include "content/browser/attribution_reporting/os_registration.h"
#include "content/browser/attribution_reporting/process_aggregatable_debug_report_result.mojom-forward.h"
#include "content/browser/attribution_reporting/send_result.h"
#include "content/browser/attribution_reporting/storable_source.h"
#include "content/public/browser/attribution_data_model.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/browser/storage_partition.h"
#include "services/network/public/mojom/attribution.mojom-forward.h"
#include "testing/gmock/include/gmock/gmock.h"

namespace base {
class ValueView;
}  // namespace base

namespace content {

class AggregatableDebugReport;
class AttributionDataHostManager;
class AttributionDebugReport;
class BrowsingDataFilterBuilder;
class CreateReportResult;
class StoredSource;

struct SendAggregatableDebugReportResult;

class MockAttributionManager : public AttributionManager {
 public:
  MockAttributionManager();
  ~MockAttributionManager() override;

  // AttributionManager:
  MOCK_METHOD(void,
              HandleSource,
              (StorableSource, GlobalRenderFrameHostId),
              (override));

  MOCK_METHOD(void,
              HandleTrigger,
              (AttributionTrigger, GlobalRenderFrameHostId),
              (override));

  MOCK_METHOD(void,
              GetActiveSourcesForWebUI,
              (base::OnceCallback<void(std::vector<StoredSource>)>),
              (override));

  MOCK_METHOD(void,
              GetPendingReportsForInternalUse,
              (int limit,
               base::OnceCallback<void(std::vector<AttributionReport>)>),
              (override));

  MOCK_METHOD(void,
              SendReportForWebUI,
              (AttributionReport::Id, base::OnceClosure done),
              (override));

  MOCK_METHOD(void,
              ClearData,
              (base::Time delete_begin,
               base::Time delete_end,
               StoragePartition::StorageKeyMatcherFunction filter,
               BrowsingDataFilterBuilder* filter_builder,
               bool delete_rate_limit_data,
               base::OnceClosure done),
              (override));

  MOCK_METHOD(void,
              GetAllDataKeys,
              (base::OnceCallback<void(std::set<DataKey>)>),
              (override));

  MOCK_METHOD(void,
              RemoveAttributionDataByDataKey,
              (const DataKey&, base::OnceClosure done),
              (override));

  MOCK_METHOD(void, HandleOsRegistration, (OsRegistration), (override));

  MOCK_METHOD(void,
              SetDebugMode,
              (std::optional<bool> enabled, base::OnceClosure done),
              (override));

  MOCK_METHOD(void,
              ReportRegistrationHeaderError,
              (attribution_reporting::SuitableOrigin reporting_origin,
               attribution_reporting::RegistrationHeaderError,
               const attribution_reporting::SuitableOrigin& context_origin,
               bool is_within_fenced_frame,
               GlobalRenderFrameHostId),
              (override));

  MOCK_METHOD(void,
              UpdateLastNavigationTime,
              (base::Time registration_time),
              (override));

  void AddObserver(AttributionObserver*) override;
  void RemoveObserver(AttributionObserver*) override;
  AttributionDataHostManager* GetDataHostManager() override;

  void NotifySourcesChanged();
  void NotifyReportsChanged();
  void NotifySourceHandled(
      const StorableSource&,
      StorableSource::Result,
      std::optional<uint64_t> cleared_debug_key = std::nullopt);
  void NotifyReportSent(const AttributionReport&,
                        bool is_debug_report,
                        const SendResult&);
  void NotifyTriggerHandled(
      const CreateReportResult&,
      std::optional<uint64_t> cleared_debug_key = std::nullopt);
  void NotifyDebugReportSent(const AttributionDebugReport&,
                             int status,
                             base::Time);
  void NotifyAggregatableDebugReportSent(
      const AggregatableDebugReport&,
      base::ValueView report_body,
      attribution_reporting::mojom::ProcessAggregatableDebugReportResult,
      const SendAggregatableDebugReportResult&);
  void NotifyOsRegistration(const OsRegistration&,
                            bool is_debug_key_allowed,
                            attribution_reporting::mojom::OsRegistrationResult);
  void NotifyDebugModeChanged(bool debug_mode);

  void SetDataHostManager(std::unique_ptr<AttributionDataHostManager>);

  void SetOnObserverRegistered(base::OnceClosure done);

 private:
  std::unique_ptr<AttributionDataHostManager> data_host_manager_;
  base::ObserverList<AttributionObserver, /*check_empty=*/true> observers_;

  base::OnceClosure on_observer_registered_;
};

}  // namespace content

#endif  // CONTENT_BROWSER_ATTRIBUTION_REPORTING_TEST_MOCK_ATTRIBUTION_MANAGER_H_