summaryrefslogtreecommitdiff
path: root/chromium/components/cryptauth/sync_scheduler.cc
blob: 52892e2b32656c94a3eca12a3f4aa5aded3bb7a8 (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
// Copyright 2015 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 "components/cryptauth/sync_scheduler.h"

#include "components/proximity_auth/logging/logging.h"

namespace cryptauth {

SyncScheduler::SyncRequest::SyncRequest(
    base::WeakPtr<SyncScheduler> sync_scheduler)
    : sync_scheduler_(sync_scheduler), completed_(false) {
}

SyncScheduler::SyncRequest::~SyncRequest() {
  if (!completed_)
    PA_LOG(ERROR) << "SyncRequest destroyed but Complete() was never called";
}

void SyncScheduler::SyncRequest::OnDidComplete(bool success) {
  if (sync_scheduler_) {
    sync_scheduler_->OnSyncCompleted(success);
    sync_scheduler_.reset();
    completed_ = true;
  } else {
    PA_LOG(ERROR) << "SyncRequest completed, but SyncScheduler destroyed.";
  }
}

}  // namespace cryptauth