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 #include "components/update_client/update_engine.h" | 5 #include "components/update_client/update_engine.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 update_checker_factory_(update_checker_factory), | 53 update_checker_factory_(update_checker_factory), |
54 crx_downloader_factory_(crx_downloader_factory), | 54 crx_downloader_factory_(crx_downloader_factory), |
55 ping_manager_(ping_manager), | 55 ping_manager_(ping_manager), |
56 notify_observers_callback_(notify_observers_callback) { | 56 notify_observers_callback_(notify_observers_callback) { |
57 } | 57 } |
58 | 58 |
59 UpdateEngine::~UpdateEngine() { | 59 UpdateEngine::~UpdateEngine() { |
60 DCHECK(thread_checker_.CalledOnValidThread()); | 60 DCHECK(thread_checker_.CalledOnValidThread()); |
61 } | 61 } |
62 | 62 |
63 bool UpdateEngine::IsUpdating(const std::string& id) const { | |
64 DCHECK(thread_checker_.CalledOnValidThread()); | |
65 for (const auto& context : update_contexts_) { | |
66 const auto& ids = context->ids; | |
67 const auto it = std::find_if( | |
68 ids.begin(), ids.end(), | |
69 [id](const std::string& this_id) { return id == this_id; }); | |
70 if (it != ids.end()) { | |
71 return true; | |
72 } | |
73 } | |
74 return false; | |
75 } | |
76 | |
77 bool UpdateEngine::GetUpdateState(const std::string& id, | 63 bool UpdateEngine::GetUpdateState(const std::string& id, |
78 CrxUpdateItem* update_item) { | 64 CrxUpdateItem* update_item) { |
79 DCHECK(thread_checker_.CalledOnValidThread()); | 65 DCHECK(thread_checker_.CalledOnValidThread()); |
80 for (const auto& context : update_contexts_) { | 66 for (const auto& context : update_contexts_) { |
81 const auto& update_items = context->update_items; | 67 const auto& update_items = context->update_items; |
82 const auto it = std::find_if(update_items.begin(), update_items.end(), | 68 const auto it = std::find_if(update_items.begin(), update_items.end(), |
83 [id](const CrxUpdateItem* update_item) { | 69 [id](const CrxUpdateItem* update_item) { |
84 return id == update_item->id; | 70 return id == update_item->id; |
85 }); | 71 }); |
86 if (it != update_items.end()) { | 72 if (it != update_items.end()) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 111 |
126 auto callback = update_context->callback; | 112 auto callback = update_context->callback; |
127 | 113 |
128 update_contexts_.erase(update_context); | 114 update_contexts_.erase(update_context); |
129 delete update_context; | 115 delete update_context; |
130 | 116 |
131 callback.Run(error); | 117 callback.Run(error); |
132 } | 118 } |
133 | 119 |
134 } // namespace update_client | 120 } // namespace update_client |
OLD | NEW |