| 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 "components/offline_pages/core/background/save_page_request.h" | 5 #include "components/offline_pages/core/background/save_page_request.h" |
| 6 | 6 |
| 7 namespace offline_pages { | 7 namespace offline_pages { |
| 8 | 8 |
| 9 SavePageRequest::SavePageRequest(int64_t request_id, | 9 SavePageRequest::SavePageRequest(int64_t request_id, |
| 10 const GURL& url, | 10 const GURL& url, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 creation_time_ == other.creation_time_ && | 58 creation_time_ == other.creation_time_ && |
| 59 activation_time_ == other.activation_time_ && | 59 activation_time_ == other.activation_time_ && |
| 60 started_attempt_count_ == other.started_attempt_count_ && | 60 started_attempt_count_ == other.started_attempt_count_ && |
| 61 completed_attempt_count_ == other.completed_attempt_count_ && | 61 completed_attempt_count_ == other.completed_attempt_count_ && |
| 62 last_attempt_time_ == other.last_attempt_time_ && | 62 last_attempt_time_ == other.last_attempt_time_ && |
| 63 state_ == other.state_ && original_url_ == other.original_url_; | 63 state_ == other.state_ && original_url_ == other.original_url_; |
| 64 } | 64 } |
| 65 | 65 |
| 66 void SavePageRequest::MarkAttemptStarted(const base::Time& start_time) { | 66 void SavePageRequest::MarkAttemptStarted(const base::Time& start_time) { |
| 67 DCHECK_LE(activation_time_, start_time); | 67 DCHECK_LE(activation_time_, start_time); |
| 68 // TODO(fgorski): As part of introducing policy in GetStatus, we can make a | |
| 69 // check here to ensure we only start tasks in status pending, and bail out in | |
| 70 // other cases. | |
| 71 last_attempt_time_ = start_time; | 68 last_attempt_time_ = start_time; |
| 72 ++started_attempt_count_; | 69 ++started_attempt_count_; |
| 73 state_ = RequestState::OFFLINING; | 70 state_ = RequestState::OFFLINING; |
| 74 } | 71 } |
| 75 | 72 |
| 76 void SavePageRequest::MarkAttemptCompleted() { | 73 void SavePageRequest::MarkAttemptCompleted() { |
| 77 ++completed_attempt_count_; | 74 ++completed_attempt_count_; |
| 78 state_ = RequestState::AVAILABLE; | 75 state_ = RequestState::AVAILABLE; |
| 79 } | 76 } |
| 80 | 77 |
| 81 void SavePageRequest::MarkAttemptAborted() { | 78 void SavePageRequest::MarkAttemptAborted() { |
| 82 DCHECK_GT(started_attempt_count_, 0); | 79 DCHECK_GT(started_attempt_count_, 0); |
| 83 // We intentinally do not increment the completed_attempt_count_, since this | 80 // We intentinally do not increment the completed_attempt_count_, since this |
| 84 // was killed before it completed, so we could use the phone or browser for | 81 // was killed before it completed, so we could use the phone or browser for |
| 85 // other things. | 82 // other things. |
| 86 if (state_ == RequestState::OFFLINING) | 83 if (state_ == RequestState::OFFLINING) |
| 87 state_ = RequestState::AVAILABLE; | 84 state_ = RequestState::AVAILABLE; |
| 88 } | 85 } |
| 89 | 86 |
| 90 void SavePageRequest::MarkAttemptPaused() { | 87 void SavePageRequest::MarkAttemptPaused() { |
| 91 state_ = RequestState::PAUSED; | 88 state_ = RequestState::PAUSED; |
| 92 } | 89 } |
| 93 | 90 |
| 94 } // namespace offline_pages | 91 } // namespace offline_pages |
| OLD | NEW |