File: task.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; 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,806; 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 (54 lines) | stat: -rw-r--r-- 1,866 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
// 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 CHROME_CREDENTIAL_PROVIDER_EXTENSION_TASK_H_
#define CHROME_CREDENTIAL_PROVIDER_EXTENSION_TASK_H_

#include <vector>

#include "base/time/time.h"
#include "base/win/windows_types.h"
#include "chrome/credential_provider/extension/user_device_context.h"

namespace credential_provider {
namespace extension {

// Configuration the task needs to run on. A way to tell task manager on how
// to run the task.
struct Config {
  // Set a default execution period in case it isn't defined by individual
  // tasks.
  Config() : execution_period(base::Hours(1)) {}

  // The period that the task will be executed on.
  base::TimeDelta execution_period;
};

// An interface that can be implemented by individual GCPW tasks to be executed
// during periodic polling by GCPW extension service. Methods are called in the
// order they are defined. So, initially task runner gets the configuration of
// the task. Then it sets the context task will be running in. Lastly task is
// executed.
class Task {
 public:
  virtual ~Task() = default;

  // ESA calls this function to get the execution config for the task. This
  // contains information about whether task is device level or
  // user level, failure action and etc.
  virtual Config GetConfig() = 0;

  // Based on the config of the task, UserDeviceContext contains identifiers for
  // the user and device. So the task can identify the users it is running on
  // behalf of.
  virtual HRESULT SetContext(const std::vector<UserDeviceContext>& c) = 0;

  // ESA calls execute function to perform the actual task.
  virtual HRESULT Execute() = 0;
};

}  // namespace extension
}  // namespace credential_provider

#endif  // CHROME_CREDENTIAL_PROVIDER_EXTENSION_TASK_H_