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

Side by Side Diff: components/offline_pages/background/save_page_request.cc

Issue 2356433004: [Offline pages] Extracting AddRequest method in RequestQueueStore (Closed)
Patch Set: Addressing feedback plus attempt at fixing compilation issue" Created 4 years, 3 months 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/background/save_page_request.h" 5 #include "components/offline_pages/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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 creation_time_(other.creation_time_), 44 creation_time_(other.creation_time_),
45 activation_time_(other.activation_time_), 45 activation_time_(other.activation_time_),
46 started_attempt_count_(other.started_attempt_count_), 46 started_attempt_count_(other.started_attempt_count_),
47 completed_attempt_count_(other.completed_attempt_count_), 47 completed_attempt_count_(other.completed_attempt_count_),
48 last_attempt_time_(other.last_attempt_time_), 48 last_attempt_time_(other.last_attempt_time_),
49 user_requested_(other.user_requested_), 49 user_requested_(other.user_requested_),
50 state_(other.state_) {} 50 state_(other.state_) {}
51 51
52 SavePageRequest::~SavePageRequest() {} 52 SavePageRequest::~SavePageRequest() {}
53 53
54 bool SavePageRequest::operator==(const SavePageRequest& other) const {
55 return request_id_ == other.request_id_ &&
56 url_ == other.url_ &&
57 client_id_ == other.client_id_ &&
58 creation_time_ == other.creation_time_ &&
59 activation_time_ == other.activation_time_ &&
60 started_attempt_count_ == other.started_attempt_count_ &&
61 completed_attempt_count_ == other.completed_attempt_count_ &&
62 last_attempt_time_ == other.last_attempt_time_ &&
63 state_ == other.state_;
64 }
65
54 void SavePageRequest::MarkAttemptStarted(const base::Time& start_time) { 66 void SavePageRequest::MarkAttemptStarted(const base::Time& start_time) {
55 DCHECK_LE(activation_time_, start_time); 67 DCHECK_LE(activation_time_, start_time);
56 // TODO(fgorski): As part of introducing policy in GetStatus, we can make a 68 // TODO(fgorski): As part of introducing policy in GetStatus, we can make a
57 // check here to ensure we only start tasks in status pending, and bail out in 69 // check here to ensure we only start tasks in status pending, and bail out in
58 // other cases. 70 // other cases.
59 last_attempt_time_ = start_time; 71 last_attempt_time_ = start_time;
60 ++started_attempt_count_; 72 ++started_attempt_count_;
61 state_ = RequestState::PRERENDERING; 73 state_ = RequestState::PRERENDERING;
62 } 74 }
63 75
64 void SavePageRequest::MarkAttemptCompleted() { 76 void SavePageRequest::MarkAttemptCompleted() {
65 ++completed_attempt_count_; 77 ++completed_attempt_count_;
66 state_ = RequestState::AVAILABLE; 78 state_ = RequestState::AVAILABLE;
67 } 79 }
68 80
69 void SavePageRequest::MarkAttemptAborted() { 81 void SavePageRequest::MarkAttemptAborted() {
70 DCHECK_GT(started_attempt_count_, 0); 82 DCHECK_GT(started_attempt_count_, 0);
71 // We intentinally do not increment the completed_attempt_count_, since this 83 // We intentinally do not increment the completed_attempt_count_, since this
72 // was killed before it completed, so we could use the phone or browser for 84 // was killed before it completed, so we could use the phone or browser for
73 // other things. 85 // other things.
74 state_ = RequestState::AVAILABLE; 86 state_ = RequestState::AVAILABLE;
75 } 87 }
76 88
77 void SavePageRequest::MarkAttemptPaused() { 89 void SavePageRequest::MarkAttemptPaused() {
78 state_ = RequestState::PAUSED; 90 state_ = RequestState::PAUSED;
79 } 91 }
80 92
81 } // namespace offline_pages 93 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/background/save_page_request.h ('k') | components/offline_pages/offline_page_metadata_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698