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_UPDATE_CLIENT_UPDATE_CLIENT_INTERNAL_H_ | 5 #ifndef COMPONENTS_UPDATE_CLIENT_UPDATE_CLIENT_INTERNAL_H_ |
6 #define COMPONENTS_UPDATE_CLIENT_UPDATE_CLIENT_INTERNAL_H_ | 6 #define COMPONENTS_UPDATE_CLIENT_UPDATE_CLIENT_INTERNAL_H_ |
7 | 7 |
8 #include "components/update_client/update_client.h" | 8 #include "components/update_client/update_client.h" |
9 | 9 |
10 #include <queue> | 10 #include <queue> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 void RemoveObserver(Observer* observer) override; | 45 void RemoveObserver(Observer* observer) override; |
46 void Install(const std::string& id, | 46 void Install(const std::string& id, |
47 const CrxDataCallback& crx_data_callback, | 47 const CrxDataCallback& crx_data_callback, |
48 const CompletionCallback& completion_callback) override; | 48 const CompletionCallback& completion_callback) override; |
49 void Update(const std::vector<std::string>& ids, | 49 void Update(const std::vector<std::string>& ids, |
50 const CrxDataCallback& crx_data_callback, | 50 const CrxDataCallback& crx_data_callback, |
51 const CompletionCallback& completion_callback) override; | 51 const CompletionCallback& completion_callback) override; |
52 bool GetCrxUpdateState(const std::string& id, | 52 bool GetCrxUpdateState(const std::string& id, |
53 CrxUpdateItem* update_item) const override; | 53 CrxUpdateItem* update_item) const override; |
54 bool IsUpdating(const std::string& id) const override; | 54 bool IsUpdating(const std::string& id) const override; |
55 void Stop() override; | |
56 | 55 |
57 private: | 56 private: |
58 ~UpdateClientImpl() override; | 57 ~UpdateClientImpl() override; |
59 | 58 |
60 void RunTask(scoped_ptr<Task> task); | 59 void RunTask(scoped_ptr<Task> task); |
61 void OnTaskComplete(const CompletionCallback& completion_callback, | 60 void OnTaskComplete(const CompletionCallback& completion_callback, |
62 Task* task, | 61 Task* task, |
63 int error); | 62 int error); |
64 | 63 |
65 void NotifyObservers(Observer::Events event, const std::string& id); | 64 void NotifyObservers(Observer::Events event, const std::string& id); |
66 | 65 |
67 base::ThreadChecker thread_checker_; | 66 base::ThreadChecker thread_checker_; |
68 | 67 |
69 // True is Stop method has been called. | |
70 bool is_stopped_; | |
71 | |
72 scoped_refptr<Configurator> config_; | 68 scoped_refptr<Configurator> config_; |
73 | 69 |
74 // Contains the tasks that are pending. In the current implementation, | 70 // Contains the tasks that are pending. In the current implementation, |
75 // only update tasks (background tasks) are queued up. These tasks are | 71 // only update tasks (background tasks) are queued up. These tasks are |
76 // pending while they are in this queue. They have not been picked up yet | 72 // pending while they are in this queue. They are not being handled for |
77 // by the update engine. | 73 // the moment. |
78 std::queue<Task*> task_queue_; | 74 std::queue<Task*> task_queue_; |
79 | 75 |
80 // Contains all tasks in progress. These are the tasks that the update engine | 76 // Contains all tasks in progress. These are the tasks that the update engine |
81 // is executing at one moment. Install tasks are run concurrently, update | 77 // is executing at one moment. Install tasks are run concurrently, update |
82 // tasks are always serialized, and update tasks are queued up if install | 78 // tasks are always serialized, and update tasks are queued up if install |
83 // tasks are running. In addition, concurrent install tasks for the same id | 79 // tasks are running. In addition, concurrent install tasks for the same id |
84 // are not allowed. | 80 // are not allowed. |
85 std::set<Task*> tasks_; | 81 std::set<Task*> tasks_; |
86 | 82 |
87 // TODO(sorin): try to make the ping manager an observer of the service. | 83 // TODO(sorin): try to make the ping manager an observer of the service. |
88 scoped_ptr<PingManager> ping_manager_; | 84 scoped_ptr<PingManager> ping_manager_; |
89 scoped_ptr<UpdateEngine> update_engine_; | 85 scoped_ptr<UpdateEngine> update_engine_; |
90 | 86 |
91 base::ObserverList<Observer> observer_list_; | 87 base::ObserverList<Observer> observer_list_; |
92 | 88 |
| 89 // Used to post responses back to the main thread. |
| 90 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 91 |
| 92 // Used to execute blocking tasks. |
| 93 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
| 94 |
93 DISALLOW_COPY_AND_ASSIGN(UpdateClientImpl); | 95 DISALLOW_COPY_AND_ASSIGN(UpdateClientImpl); |
94 }; | 96 }; |
95 | 97 |
96 } // namespace update_client | 98 } // namespace update_client |
97 | 99 |
98 #endif // COMPONENTS_UPDATE_CLIENT_UPDATE_CLIENT_INTERNAL_H_ | 100 #endif // COMPONENTS_UPDATE_CLIENT_UPDATE_CLIENT_INTERNAL_H_ |
OLD | NEW |