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

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

Issue 2489443002: Move all components/offline_pages/ files into component/offline_pages/core (Closed)
Patch Set: more rebase 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/offline_pages/background/save_page_request.h"
6
7 namespace offline_pages {
8
9 SavePageRequest::SavePageRequest(int64_t request_id,
10 const GURL& url,
11 const ClientId& client_id,
12 const base::Time& creation_time,
13 const bool user_requested)
14 : request_id_(request_id),
15 url_(url),
16 client_id_(client_id),
17 creation_time_(creation_time),
18 activation_time_(creation_time),
19 started_attempt_count_(0),
20 completed_attempt_count_(0),
21 user_requested_(user_requested),
22 state_(RequestState::AVAILABLE) {}
23
24 SavePageRequest::SavePageRequest(int64_t request_id,
25 const GURL& url,
26 const ClientId& client_id,
27 const base::Time& creation_time,
28 const base::Time& activation_time,
29 const bool user_requested)
30 : request_id_(request_id),
31 url_(url),
32 client_id_(client_id),
33 creation_time_(creation_time),
34 activation_time_(activation_time),
35 started_attempt_count_(0),
36 completed_attempt_count_(0),
37 user_requested_(user_requested),
38 state_(RequestState::AVAILABLE) {}
39
40 SavePageRequest::SavePageRequest(const SavePageRequest& other)
41 : request_id_(other.request_id_),
42 url_(other.url_),
43 client_id_(other.client_id_),
44 creation_time_(other.creation_time_),
45 activation_time_(other.activation_time_),
46 started_attempt_count_(other.started_attempt_count_),
47 completed_attempt_count_(other.completed_attempt_count_),
48 last_attempt_time_(other.last_attempt_time_),
49 user_requested_(other.user_requested_),
50 state_(other.state_) {}
51
52 SavePageRequest::~SavePageRequest() {}
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
66 void SavePageRequest::MarkAttemptStarted(const base::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;
72 ++started_attempt_count_;
73 state_ = RequestState::OFFLINING;
74 }
75
76 void SavePageRequest::MarkAttemptCompleted() {
77 ++completed_attempt_count_;
78 state_ = RequestState::AVAILABLE;
79 }
80
81 void SavePageRequest::MarkAttemptAborted() {
82 DCHECK_GT(started_attempt_count_, 0);
83 // 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
85 // other things.
86 state_ = RequestState::AVAILABLE;
87 }
88
89 void SavePageRequest::MarkAttemptPaused() {
90 state_ = RequestState::PAUSED;
91 }
92
93 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698