summaryrefslogtreecommitdiffstats
path: root/chromium/components/update_client/patcher.h
blob: 1316d2609d9b7967a0a32253c00f4d855ff4894a (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
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
// Copyright 2019 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 COMPONENTS_UPDATE_CLIENT_PATCHER_H_
#define COMPONENTS_UPDATE_CLIENT_PATCHER_H_

#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"

namespace base {
class FilePath;
}  // namespace base

namespace update_client {

class Patcher : public base::RefCountedThreadSafe<Patcher> {
 public:
  using PatchCompleteCallback = base::OnceCallback<void(int result)>;

  virtual void PatchBsdiff(const base::FilePath& input_file,
                           const base::FilePath& patch_file,
                           const base::FilePath& destination,
                           PatchCompleteCallback callback) const = 0;

  virtual void PatchCourgette(const base::FilePath& input_file,
                              const base::FilePath& patch_file,
                              const base::FilePath& destination,
                              PatchCompleteCallback callback) const = 0;

 protected:
  friend class base::RefCountedThreadSafe<Patcher>;
  Patcher() = default;
  virtual ~Patcher() = default;

 private:
  DISALLOW_COPY_AND_ASSIGN(Patcher);
};

class PatcherFactory : public base::RefCountedThreadSafe<PatcherFactory> {
 public:
  virtual scoped_refptr<Patcher> Create() const = 0;

 protected:
  friend class base::RefCountedThreadSafe<PatcherFactory>;
  PatcherFactory() = default;
  virtual ~PatcherFactory() = default;

 private:
  DISALLOW_COPY_AND_ASSIGN(PatcherFactory);
};

}  // namespace update_client

#endif  // COMPONENTS_UPDATE_CLIENT_PATCHER_H_