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 "chrome/browser/android/offline_pages/prerendering_loader.h" | 5 #include "chrome/browser/android/offline_pages/prerendering_loader.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 if (IsIdle()) | 157 if (IsIdle()) |
158 return; | 158 return; |
159 | 159 |
160 if (adapter_->IsActive()) { | 160 if (adapter_->IsActive()) { |
161 DVLOG(1) << "Load failed: " << adapter_->GetFinalStatus(); | 161 DVLOG(1) << "Load failed: " << adapter_->GetFinalStatus(); |
162 adapter_->DestroyActive(); | 162 adapter_->DestroyActive(); |
163 } | 163 } |
164 // Request status depends on whether we are still loading (failed) or | 164 // Request status depends on whether we are still loading (failed) or |
165 // did load and then loading was stopped (cancel - from prerender stack). | 165 // did load and then loading was stopped (cancel - from prerender stack). |
166 Offliner::RequestStatus request_status = | 166 Offliner::RequestStatus request_status = |
167 IsLoaded() ? Offliner::RequestStatus::CANCELED | 167 IsLoaded() ? Offliner::RequestStatus::LOAD_CANCELED |
168 : Offliner::RequestStatus::FAILED; | 168 : Offliner::RequestStatus::LOAD_FAILED; |
169 // TODO(dougarnett): For failure, determine from final status if retry-able | 169 // TODO(dougarnett): For failure, determine from final status if retry-able |
170 // and report different failure statuses if retry-able or not. | 170 // and report different failure statuses if retry-able or not. |
171 snapshot_controller_.reset(nullptr); | 171 snapshot_controller_.reset(nullptr); |
172 session_contents_.reset(nullptr); | 172 session_contents_.reset(nullptr); |
173 state_ = State::IDLE; | 173 state_ = State::IDLE; |
174 base::ThreadTaskRunnerHandle::Get()->PostTask( | 174 base::ThreadTaskRunnerHandle::Get()->PostTask( |
175 FROM_HERE, base::Bind(callback_, request_status, nullptr)); | 175 FROM_HERE, base::Bind(callback_, request_status, nullptr)); |
176 } | 176 } |
177 | 177 |
178 void PrerenderingLoader::CancelPrerender() { | 178 void PrerenderingLoader::CancelPrerender() { |
179 if (adapter_->IsActive()) { | 179 if (adapter_->IsActive()) { |
180 adapter_->DestroyActive(); | 180 adapter_->DestroyActive(); |
181 } | 181 } |
182 snapshot_controller_.reset(nullptr); | 182 snapshot_controller_.reset(nullptr); |
183 session_contents_.reset(nullptr); | 183 session_contents_.reset(nullptr); |
184 if (!IsLoaded() && !IsIdle()) { | 184 if (!IsLoaded() && !IsIdle()) { |
185 base::ThreadTaskRunnerHandle::Get()->PostTask( | 185 base::ThreadTaskRunnerHandle::Get()->PostTask( |
186 FROM_HERE, | 186 FROM_HERE, |
187 base::Bind(callback_, Offliner::RequestStatus::CANCELED, nullptr)); | 187 base::Bind(callback_, Offliner::RequestStatus::LOAD_CANCELED, nullptr)); |
188 } | 188 } |
189 state_ = State::IDLE; | 189 state_ = State::IDLE; |
190 } | 190 } |
191 | 191 |
192 } // namespace offline_pages | 192 } // namespace offline_pages |
OLD | NEW |