File: get_updates_delegate.cc

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 (99 lines) | stat: -rw-r--r-- 3,589 bytes parent folder | download | duplicates (5)
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
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/sync/engine/get_updates_delegate.h"

#include "components/sync/engine/events/configure_get_updates_request_event.h"
#include "components/sync/engine/events/normal_get_updates_request_event.h"
#include "components/sync/engine/events/poll_get_updates_request_event.h"
#include "components/sync/engine/get_updates_processor.h"
#include "components/sync/engine/update_handler.h"
#include "components/sync/protocol/data_type_progress_marker.pb.h"
#include "components/sync/protocol/get_updates_caller_info.pb.h"
#include "components/sync/protocol/sync.pb.h"

namespace syncer {

NormalGetUpdatesDelegate::NormalGetUpdatesDelegate(
    const NudgeTracker& nudge_tracker)
    : nudge_tracker_(nudge_tracker) {}

NormalGetUpdatesDelegate::~NormalGetUpdatesDelegate() = default;

// This function assumes the progress markers have already been populated.
void NormalGetUpdatesDelegate::HelpPopulateGuMessage(
    sync_pb::GetUpdatesMessage* get_updates) const {
  // Set the origin.
  get_updates->set_get_updates_origin(sync_pb::SyncEnums::GU_TRIGGER);

  // Fill in the notification hints.
  for (int i = 0; i < get_updates->from_progress_marker_size(); ++i) {
    sync_pb::DataTypeProgressMarker* progress_marker =
        get_updates->mutable_from_progress_marker(i);
    DataType type =
        GetDataTypeFromSpecificsFieldNumber(progress_marker->data_type_id());

    DCHECK(!nudge_tracker_->IsTypeBlocked(type))
        << "Throttled types should have been removed from the request_types.";

    nudge_tracker_->FillProtoMessage(
        type, progress_marker->mutable_get_update_triggers());
  }
}

std::unique_ptr<ProtocolEvent> NormalGetUpdatesDelegate::GetNetworkRequestEvent(
    base::Time timestamp,
    const sync_pb::ClientToServerMessage& request) const {
  return std::unique_ptr<ProtocolEvent>(
      new NormalGetUpdatesRequestEvent(timestamp, *nudge_tracker_, request));
}

bool NormalGetUpdatesDelegate::IsNotificationInfoRequired() const {
  return true;
}

ConfigureGetUpdatesDelegate::ConfigureGetUpdatesDelegate(
    sync_pb::SyncEnums::GetUpdatesOrigin origin)
    : origin_(origin) {}

ConfigureGetUpdatesDelegate::~ConfigureGetUpdatesDelegate() = default;

void ConfigureGetUpdatesDelegate::HelpPopulateGuMessage(
    sync_pb::GetUpdatesMessage* get_updates) const {
  get_updates->set_get_updates_origin(origin_);
}

std::unique_ptr<ProtocolEvent>
ConfigureGetUpdatesDelegate::GetNetworkRequestEvent(
    base::Time timestamp,
    const sync_pb::ClientToServerMessage& request) const {
  return std::make_unique<ConfigureGetUpdatesRequestEvent>(timestamp, origin_,
                                                           request);
}

bool ConfigureGetUpdatesDelegate::IsNotificationInfoRequired() const {
  return false;
}

PollGetUpdatesDelegate::PollGetUpdatesDelegate() = default;

PollGetUpdatesDelegate::~PollGetUpdatesDelegate() = default;

void PollGetUpdatesDelegate::HelpPopulateGuMessage(
    sync_pb::GetUpdatesMessage* get_updates) const {
  get_updates->set_get_updates_origin(sync_pb::SyncEnums::PERIODIC);
}

std::unique_ptr<ProtocolEvent> PollGetUpdatesDelegate::GetNetworkRequestEvent(
    base::Time timestamp,
    const sync_pb::ClientToServerMessage& request) const {
  return std::unique_ptr<ProtocolEvent>(
      new PollGetUpdatesRequestEvent(timestamp, request));
}

bool PollGetUpdatesDelegate::IsNotificationInfoRequired() const {
  return false;
}

}  // namespace syncer