| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <deque> | 5 #include <deque> |
| 6 #include <memory> | 6 #include <memory> |
| 7 #include <set> | 7 #include <set> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // cases below, we instead post a task since the delegate typically isn't | 102 // cases below, we instead post a task since the delegate typically isn't |
| 103 // expecting a synchronous reply (the real code has to go do at least one | 103 // expecting a synchronous reply (the real code has to go do at least one |
| 104 // network request before getting a response, so this is is a reasonable | 104 // network request before getting a response, so this is is a reasonable |
| 105 // expectation by delegates). | 105 // expectation by delegates). |
| 106 for (const std::string& id : fetch_data->extension_ids()) { | 106 for (const std::string& id : fetch_data->extension_ids()) { |
| 107 auto no_update = no_updates_.find(id); | 107 auto no_update = no_updates_.find(id); |
| 108 if (no_update != no_updates_.end()) { | 108 if (no_update != no_updates_.end()) { |
| 109 no_updates_.erase(no_update); | 109 no_updates_.erase(no_update); |
| 110 base::ThreadTaskRunnerHandle::Get()->PostTask( | 110 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 111 FROM_HERE, | 111 FROM_HERE, |
| 112 base::Bind(&ExtensionDownloaderDelegate::OnExtensionDownloadFailed, | 112 base::BindOnce( |
| 113 base::Unretained(delegate), id, | 113 &ExtensionDownloaderDelegate::OnExtensionDownloadFailed, |
| 114 ExtensionDownloaderDelegate::NO_UPDATE_AVAILABLE, | 114 base::Unretained(delegate), id, |
| 115 ExtensionDownloaderDelegate::PingResult(), | 115 ExtensionDownloaderDelegate::NO_UPDATE_AVAILABLE, |
| 116 fetch_data->request_ids())); | 116 ExtensionDownloaderDelegate::PingResult(), |
| 117 fetch_data->request_ids())); |
| 117 continue; | 118 continue; |
| 118 } | 119 } |
| 119 auto update = updates_.find(id); | 120 auto update = updates_.find(id); |
| 120 if (update != updates_.end()) { | 121 if (update != updates_.end()) { |
| 121 CRXFileInfo info(id, update->second.path, "" /* no hash */); | 122 CRXFileInfo info(id, update->second.path, "" /* no hash */); |
| 122 std::string version = update->second.version; | 123 std::string version = update->second.version; |
| 123 updates_.erase(update); | 124 updates_.erase(update); |
| 124 base::ThreadTaskRunnerHandle::Get()->PostTask( | 125 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 125 FROM_HERE, | 126 FROM_HERE, |
| 126 base::Bind( | 127 base::BindOnce( |
| 127 &ExtensionDownloaderDelegate::OnExtensionDownloadFinished, | 128 &ExtensionDownloaderDelegate::OnExtensionDownloadFinished, |
| 128 base::Unretained(delegate), info, | 129 base::Unretained(delegate), info, |
| 129 false /* file_ownership_passed */, GURL(), version, | 130 false /* file_ownership_passed */, GURL(), version, |
| 130 ExtensionDownloaderDelegate::PingResult(), | 131 ExtensionDownloaderDelegate::PingResult(), |
| 131 fetch_data->request_ids(), | 132 fetch_data->request_ids(), |
| 132 ExtensionDownloaderDelegate::InstallCallback())); | 133 ExtensionDownloaderDelegate::InstallCallback())); |
| 133 continue; | 134 continue; |
| 134 } | 135 } |
| 135 ADD_FAILURE() << "Unexpected extension id " << id; | 136 ADD_FAILURE() << "Unexpected extension id " << id; |
| 136 } | 137 } |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 | 312 |
| 312 // Call again after a longer delay, we should should be unthrottled. | 313 // Call again after a longer delay, we should should be unthrottled. |
| 313 clock_.Advance(base::TimeDelta::FromHours(8)); | 314 clock_.Advance(base::TimeDelta::FromHours(8)); |
| 314 downloader_test_delegate_.AddNoUpdateResponse(id); | 315 downloader_test_delegate_.AddNoUpdateResponse(id); |
| 315 DoUpdateCheck(id, "no_update", ""); | 316 DoUpdateCheck(id, "no_update", ""); |
| 316 } | 317 } |
| 317 | 318 |
| 318 } // namespace | 319 } // namespace |
| 319 | 320 |
| 320 } // namespace extensions | 321 } // namespace extensions |
| OLD | NEW |