forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfido_task.h
55 lines (42 loc) · 1.51 KB
/
fido_task.h
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
// Copyright 2018 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 DEVICE_FIDO_FIDO_TASK_H_
#define DEVICE_FIDO_FIDO_TASK_H_
#include <stdint.h>
#include <vector>
#include "base/callback.h"
#include "base/component_export.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "device/fido/fido_device.h"
namespace device {
// Encapsulates per-device request logic shared between MakeCredential and
// GetAssertion.
//
// TODO(martinkr): FidoTask should be subsumed by FidoDeviceAuthenticator.
class COMPONENT_EXPORT(DEVICE_FIDO) FidoTask {
public:
// The |device| must outlive the FidoTask instance.
explicit FidoTask(FidoDevice* device);
virtual ~FidoTask();
// Cancel attempts to cancel the operation. This may safely be called at any
// point but may not be effective because the task may have already completed
// or the device may not support cancelation. Even if canceled, the callback
// will still be invoked, albeit perhaps with a status of
// |kCtap2ErrKeepAliveCancel|.
virtual void Cancel() = 0;
protected:
// Asynchronously initiates CTAP request operation for a single device.
virtual void StartTask() = 0;
FidoDevice* device() const {
DCHECK(device_);
return device_;
}
private:
FidoDevice* const device_;
base::WeakPtrFactory<FidoTask> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(FidoTask);
};
} // namespace device
#endif // DEVICE_FIDO_FIDO_TASK_H_