Remove BooleanPrefMember usage from Data Reduction Proxy IO classes.
[chromium-blink-merge.git] / components / update_client / action_update.h
blob8b33444b44d63ca425a7b6e0159e70c969fb4ca0
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_UPDATE_CLIENT_ACTION_UPDATE_H_
6 #define COMPONENTS_UPDATE_CLIENT_ACTION_UPDATE_H_
8 #include <map>
9 #include <string>
10 #include <vector>
12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/threading/thread_checker.h"
15 #include "base/version.h"
16 #include "components/update_client/action.h"
17 #include "components/update_client/component_unpacker.h"
18 #include "components/update_client/update_client.h"
19 #include "components/update_client/update_engine.h"
20 #include "url/gurl.h"
22 namespace update_client {
24 class UpdateChecker;
26 // Defines a template method design pattern for ActionUpdate. This class
27 // implements the common code for updating a CRX using either differential or
28 // full updates algorithm.
29 class ActionUpdate : public Action, protected ActionImpl {
30 public:
31 ActionUpdate();
32 ~ActionUpdate() override;
34 // Action overrides.
35 void Run(UpdateContext* update_context, Callback callback) override;
37 private:
38 virtual bool IsBackgroundDownload(const CrxUpdateItem* item) = 0;
39 virtual std::vector<GURL> GetUrls(const CrxUpdateItem* item) = 0;
40 virtual void OnDownloadStart(CrxUpdateItem* item) = 0;
41 virtual void OnDownloadSuccess(
42 CrxUpdateItem* item,
43 const CrxDownloader::Result& download_result) = 0;
44 virtual void OnDownloadError(
45 CrxUpdateItem* item,
46 const CrxDownloader::Result& download_result) = 0;
47 virtual void OnInstallStart(CrxUpdateItem* item) = 0;
48 virtual void OnInstallSuccess(CrxUpdateItem* item) = 0;
49 virtual void OnInstallError(CrxUpdateItem* item,
50 ComponentUnpacker::Error error,
51 int extended_error) = 0;
53 // Called when progress is being made downloading a CRX. The progress may
54 // not monotonically increase due to how the CRX downloader switches between
55 // different downloaders and fallback urls.
56 void DownloadProgress(const std::string& crx_id,
57 const CrxDownloader::Result& download_result);
59 // Called when the CRX package has been downloaded to a temporary location.
60 void DownloadComplete(const std::string& crx_id,
61 const CrxDownloader::Result& download_result);
63 void Install(const std::string& crx_id, const base::FilePath& crx_path);
65 // TODO(sorin): refactor the public interface of ComponentUnpacker so
66 // that these calls can run on the main thread.
67 void DoInstallOnBlockingTaskRunner(UpdateContext* update_context,
68 CrxUpdateItem* item,
69 const base::FilePath& crx_path);
71 void EndUnpackingOnBlockingTaskRunner(UpdateContext* update_context,
72 CrxUpdateItem* item,
73 const base::FilePath& crx_path,
74 ComponentUnpacker::Error error,
75 int extended_error);
77 void DoneInstalling(const std::string& crx_id,
78 ComponentUnpacker::Error error,
79 int extended_error);
81 DISALLOW_COPY_AND_ASSIGN(ActionUpdate);
84 class ActionUpdateDiff : public ActionUpdate {
85 public:
86 static scoped_ptr<Action> Create();
88 private:
89 ActionUpdateDiff();
90 ~ActionUpdateDiff() override;
92 void TryUpdateFull();
94 // ActionUpdate overrides.
95 bool IsBackgroundDownload(const CrxUpdateItem* item) override;
96 std::vector<GURL> GetUrls(const CrxUpdateItem* item) override;
97 void OnDownloadStart(CrxUpdateItem* item) override;
98 void OnDownloadSuccess(CrxUpdateItem* item,
99 const CrxDownloader::Result& download_result) override;
100 void OnDownloadError(CrxUpdateItem* item,
101 const CrxDownloader::Result& download_result) override;
102 void OnInstallStart(CrxUpdateItem* item) override;
103 void OnInstallSuccess(CrxUpdateItem* item) override;
104 void OnInstallError(CrxUpdateItem* item,
105 ComponentUnpacker::Error error,
106 int extended_error) override;
108 DISALLOW_COPY_AND_ASSIGN(ActionUpdateDiff);
111 class ActionUpdateFull : ActionUpdate {
112 public:
113 static scoped_ptr<Action> Create();
115 private:
116 ActionUpdateFull();
117 ~ActionUpdateFull() override;
119 // ActionUpdate overrides.
120 bool IsBackgroundDownload(const CrxUpdateItem* item) override;
121 std::vector<GURL> GetUrls(const CrxUpdateItem* item) override;
122 void OnDownloadStart(CrxUpdateItem* item) override;
123 void OnDownloadSuccess(CrxUpdateItem* item,
124 const CrxDownloader::Result& download_result) override;
125 void OnDownloadError(CrxUpdateItem* item,
126 const CrxDownloader::Result& download_result) override;
127 void OnInstallStart(CrxUpdateItem* item) override;
128 void OnInstallSuccess(CrxUpdateItem* item) override;
129 void OnInstallError(CrxUpdateItem* item,
130 ComponentUnpacker::Error error,
131 int extended_error) override;
133 DISALLOW_COPY_AND_ASSIGN(ActionUpdateFull);
136 } // namespace update_client
138 #endif // COMPONENTS_UPDATE_CLIENT_ACTION_UPDATE_H_