OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_INTERNAL_H_ | 5 #ifndef COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_INTERNAL_H_ |
6 #define COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_INTERNAL_H_ | 6 #define COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_INTERNAL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/sequenced_task_runner.h" | 15 #include "base/sequenced_task_runner.h" |
16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
17 #include "base/threading/thread_checker.h" | 17 #include "base/threading/thread_checker.h" |
18 #include "components/component_updater/timer.h" | 18 #include "components/component_updater/timer.h" |
19 | 19 |
| 20 namespace base { |
| 21 class TimeTicks; |
| 22 } |
| 23 |
20 namespace component_updater { | 24 namespace component_updater { |
21 | 25 |
22 class OnDemandUpdater; | 26 class OnDemandUpdater; |
23 | 27 |
24 using CrxInstaller = update_client::CrxInstaller; | 28 using CrxInstaller = update_client::CrxInstaller; |
25 using UpdateClient = update_client::UpdateClient; | 29 using UpdateClient = update_client::UpdateClient; |
26 | 30 |
27 class CrxUpdateService : public ComponentUpdateService, | 31 class CrxUpdateService : public ComponentUpdateService, |
28 public ComponentUpdateService::Observer, | 32 public ComponentUpdateService::Observer, |
29 public OnDemandUpdater { | 33 public OnDemandUpdater { |
30 using Observer = ComponentUpdateService::Observer; | 34 using Observer = ComponentUpdateService::Observer; |
31 | 35 |
32 public: | 36 public: |
33 CrxUpdateService(const scoped_refptr<Configurator>& config, | 37 CrxUpdateService(const scoped_refptr<Configurator>& config, |
34 const scoped_refptr<UpdateClient>& update_client); | 38 const scoped_refptr<UpdateClient>& update_client); |
35 ~CrxUpdateService() override; | 39 ~CrxUpdateService() override; |
36 | 40 |
37 // Overrides for ComponentUpdateService. | 41 // Overrides for ComponentUpdateService. |
38 void AddObserver(Observer* observer) override; | 42 void AddObserver(Observer* observer) override; |
39 void RemoveObserver(Observer* observer) override; | 43 void RemoveObserver(Observer* observer) override; |
40 bool RegisterComponent(const CrxComponent& component) override; | 44 bool RegisterComponent(const CrxComponent& component) override; |
41 bool UnregisterComponent(const std::string& id) override; | 45 bool UnregisterComponent(const std::string& id) override; |
42 std::vector<std::string> GetComponentIDs() const override; | 46 std::vector<std::string> GetComponentIDs() const override; |
43 OnDemandUpdater& GetOnDemandUpdater() override; | 47 OnDemandUpdater& GetOnDemandUpdater() override; |
44 void MaybeThrottle(const std::string& id, | 48 void MaybeThrottle(const std::string& id, |
45 const base::Closure& callback) override; | 49 const base::Closure& callback) override; |
46 scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner() override; | 50 scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner() override; |
47 bool OnDemandUpdate(const std::string& id) override; | |
48 bool GetComponentDetails(const std::string& id, | 51 bool GetComponentDetails(const std::string& id, |
49 CrxUpdateItem* item) const override; | 52 CrxUpdateItem* item) const override; |
50 | 53 |
51 // Overrides for Observer. | 54 // Overrides for Observer. |
52 void OnEvent(Events event, const std::string& id) override; | 55 void OnEvent(Events event, const std::string& id) override; |
53 | 56 |
| 57 // Overrides for OnDemandUpdater. |
| 58 bool OnDemandUpdate(const std::string& id) override; |
| 59 |
54 private: | 60 private: |
55 void Start(); | 61 void Start(); |
56 void Stop(); | 62 void Stop(); |
57 | 63 |
58 bool CheckForUpdates(); | 64 bool CheckForUpdates(); |
59 | 65 |
60 bool OnDemandUpdateInternal(const std::string& id); | 66 bool OnDemandUpdateInternal(const std::string& id); |
61 bool OnDemandUpdateWithCooldown(const std::string& id); | 67 bool OnDemandUpdateWithCooldown(const std::string& id); |
62 | 68 |
63 bool DoUnregisterComponent(const CrxComponent& component); | 69 bool DoUnregisterComponent(const CrxComponent& component); |
64 | 70 |
65 const CrxComponent* GetComponent(const std::string& id) const; | 71 const CrxComponent* GetComponent(const std::string& id) const; |
66 | 72 |
67 const CrxUpdateItem* GetComponentState(const std::string& id) const; | 73 const CrxUpdateItem* GetComponentState(const std::string& id) const; |
68 | 74 |
69 void OnUpdate(const std::vector<std::string>& ids, | 75 void OnUpdate(const std::vector<std::string>& ids, |
70 std::vector<CrxComponent>* components); | 76 std::vector<CrxComponent>* components); |
71 void OnUpdateComplete(int error); | 77 void OnUpdateComplete(const base::TimeTicks& start_time, int error); |
72 | 78 |
73 base::ThreadChecker thread_checker_; | 79 base::ThreadChecker thread_checker_; |
74 | 80 |
75 scoped_refptr<Configurator> config_; | 81 scoped_refptr<Configurator> config_; |
76 | 82 |
77 scoped_refptr<UpdateClient> update_client_; | 83 scoped_refptr<UpdateClient> update_client_; |
78 | 84 |
79 Timer timer_; | 85 Timer timer_; |
80 | 86 |
81 // A collection of every registered component. | 87 // A collection of every registered component. |
(...skipping 21 matching lines...) Expand all Loading... |
103 ComponentStates component_states_; | 109 ComponentStates component_states_; |
104 | 110 |
105 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 111 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
106 | 112 |
107 DISALLOW_COPY_AND_ASSIGN(CrxUpdateService); | 113 DISALLOW_COPY_AND_ASSIGN(CrxUpdateService); |
108 }; | 114 }; |
109 | 115 |
110 } // namespace component_updater | 116 } // namespace component_updater |
111 | 117 |
112 #endif // COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_INTERNAL_H_ | 118 #endif // COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_INTERNAL_H_ |
OLD | NEW |