Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: components/offline_pages/core/background/cleanup_task.cc

Issue 2568613002: Reconcile the request queue on startup. (Closed)
Patch Set: CR feedback from DougArnett and FGorski Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/cleanup_task.h" 5 #include "components/offline_pages/core/background/cleanup_task.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "components/offline_pages/core/background/offliner_policy.h" 9 #include "components/offline_pages/core/background/offliner_policy.h"
10 #include "components/offline_pages/core/background/offliner_policy_utils.h" 10 #include "components/offline_pages/core/background/offliner_policy_utils.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 std::vector<std::unique_ptr<SavePageRequest>> requests, 81 std::vector<std::unique_ptr<SavePageRequest>> requests,
82 std::vector<int64_t>* expired_request_ids) { 82 std::vector<int64_t>* expired_request_ids) {
83 for (auto& request : requests) { 83 for (auto& request : requests) {
84 // Check for requests past their expiration time or with too many tries. If 84 // Check for requests past their expiration time or with too many tries. If
85 // it is not still valid, push the request and the reason onto the deletion 85 // it is not still valid, push the request and the reason onto the deletion
86 // list. 86 // list.
87 OfflinerPolicyUtils::RequestExpirationStatus status = 87 OfflinerPolicyUtils::RequestExpirationStatus status =
88 OfflinerPolicyUtils::CheckRequestExpirationStatus(request.get(), 88 OfflinerPolicyUtils::CheckRequestExpirationStatus(request.get(),
89 policy_); 89 policy_);
90 90
91 // TODO(petewil): The strategy of checking the state below relies on a
92 // reconciliation task, so at startup we convert any OFFLINING requests to
93 // AVAILABLE. Otherwise, requests in the OFFLINING state when chromium dies
94 // will never be cleaned up.
95
96 // If we are not working on this request in an offliner, and it is not 91 // If we are not working on this request in an offliner, and it is not
97 // valid, put it on a list for removal. We make the exception for current 92 // valid, put it on a list for removal. We make the exception for current
98 // requests because the request might expire after being chosen and before 93 // requests because the request might expire after being chosen and before
99 // we call cleanup, and we shouldn't delete the request while offlining it. 94 // we call cleanup, and we shouldn't delete the request while offlining it.
100 if (status != OfflinerPolicyUtils::RequestExpirationStatus::VALID && 95 if (status != OfflinerPolicyUtils::RequestExpirationStatus::VALID &&
101 request->request_state() != SavePageRequest::RequestState::OFFLINING) { 96 request->request_state() != SavePageRequest::RequestState::OFFLINING) {
102 // TODO(petewil): Push both request and reason, will need to change type 97 // TODO(petewil): Push both request and reason, will need to change type
103 // of list to pairs. 98 // of list to pairs.
104 expired_request_ids->push_back(request->request_id()); 99 expired_request_ids->push_back(request->request_id());
105 } 100 }
106 } 101 }
107 } 102 }
108 103
109 } // namespace offline_pages 104 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698