Chromium Code Reviews| 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 "ios/chrome/browser/reading_list/reading_list_entry.h" | 5 #include "ios/chrome/browser/reading_list/reading_list_entry.h" |
| 6 | 6 |
| 7 ReadingListEntry::ReadingListEntry(const GURL& url, const std::string& title) | 7 ReadingListEntry::ReadingListEntry(const GURL& url, const std::string& title) |
| 8 : url_(url), title_(title), distilled_state_(WAITING) { | 8 : url_(url), |
| 9 title_(title), | |
| 10 distilled_state_(WAITING), | |
| 11 failed_distillation_counter_(0) { | |
| 9 DCHECK(!url.is_empty()); | 12 DCHECK(!url.is_empty()); |
| 10 DCHECK(url.is_valid()); | 13 DCHECK(url.is_valid()); |
| 11 } | 14 } |
| 12 ReadingListEntry::ReadingListEntry(const ReadingListEntry& entry) | 15 ReadingListEntry::ReadingListEntry(const ReadingListEntry& entry) |
| 13 : url_(entry.URL()), | 16 : url_(entry.URL()), |
| 14 title_(entry.Title()), | 17 title_(entry.Title()), |
| 15 distilled_url_(entry.DistilledURL()), | 18 distilled_url_(entry.DistilledURL()), |
| 16 distilled_state_(entry.DistilledState()) {} | 19 distilled_state_(entry.DistilledState()), |
| 20 failed_distillation_counter_(entry.FailedDistillationCounter()) {} | |
| 17 ReadingListEntry::~ReadingListEntry() {} | 21 ReadingListEntry::~ReadingListEntry() {} |
| 18 | 22 |
| 19 const GURL& ReadingListEntry::URL() const { | 23 const GURL& ReadingListEntry::URL() const { |
| 20 return url_; | 24 return url_; |
| 21 } | 25 } |
| 22 | 26 |
| 23 const std::string ReadingListEntry::Title() const { | 27 const std::string ReadingListEntry::Title() const { |
| 24 return title_; | 28 return title_; |
| 25 } | 29 } |
| 26 | 30 |
| 27 ReadingListEntry::DistillationState ReadingListEntry::DistilledState() const { | 31 ReadingListEntry::DistillationState ReadingListEntry::DistilledState() const { |
| 28 return distilled_state_; | 32 return distilled_state_; |
| 29 } | 33 } |
| 30 | 34 |
| 31 const GURL& ReadingListEntry::DistilledURL() const { | 35 const GURL& ReadingListEntry::DistilledURL() const { |
| 32 return distilled_url_; | 36 return distilled_url_; |
| 33 } | 37 } |
| 34 | 38 |
| 39 int ReadingListEntry::FailedDistillationCounter() const { | |
| 40 return failed_distillation_counter_; | |
| 41 } | |
| 42 | |
| 35 ReadingListEntry& ReadingListEntry::operator=(const ReadingListEntry& other) { | 43 ReadingListEntry& ReadingListEntry::operator=(const ReadingListEntry& other) { |
| 36 url_ = other.url_; | 44 url_ = other.url_; |
| 37 title_ = other.title_; | 45 title_ = other.title_; |
| 38 distilled_url_ = other.distilled_url_; | 46 distilled_url_ = other.distilled_url_; |
| 39 distilled_state_ = other.distilled_state_; | 47 distilled_state_ = other.distilled_state_; |
| 48 failed_distillation_counter_ = other.failed_distillation_counter_; | |
| 40 return *this; | 49 return *this; |
| 41 } | 50 } |
| 42 | 51 |
| 43 bool ReadingListEntry::operator==(const ReadingListEntry& other) const { | 52 bool ReadingListEntry::operator==(const ReadingListEntry& other) const { |
| 44 return url_ == other.url_; | 53 return url_ == other.url_; |
| 45 } | 54 } |
| 46 | 55 |
| 47 void ReadingListEntry::SetTitle(const std::string& title) { | 56 void ReadingListEntry::SetTitle(const std::string& title) { |
| 48 title_ = title; | 57 title_ = title; |
| 49 } | 58 } |
| 50 | 59 |
| 51 void ReadingListEntry::SetDistilledURL(const GURL& url) { | 60 void ReadingListEntry::SetDistilledURL(const GURL& url) { |
| 52 DCHECK(url.is_valid()); | 61 DCHECK(url.is_valid()); |
| 53 distilled_url_ = url; | 62 distilled_url_ = url; |
| 54 distilled_state_ = PROCESSED; | 63 distilled_state_ = PROCESSED; |
| 64 failed_distillation_counter_ = 0; | |
| 55 } | 65 } |
| 56 | 66 |
| 57 void ReadingListEntry::SetDistilledState(DistillationState distilled_state) { | 67 void ReadingListEntry::SetDistilledState(DistillationState distilled_state) { |
| 58 DCHECK(distilled_state != PROCESSED); // use SetDistilledURL instead. | 68 DCHECK(distilled_state != PROCESSED); // use SetDistilledURL instead. |
| 59 DCHECK(distilled_state != WAITING); | 69 DCHECK(distilled_state != WAITING); |
| 70 if ((distilled_state == WILL_RETRY || distilled_state == ERROR) && | |
| 71 distilled_state_ != WILL_RETRY && distilled_state_ != ERROR) | |
|
noyau (Ping after 24h)
2016/09/16 14:25:13
This condition is quite hard to read. Can you add
gambard
2016/09/19 09:08:09
Done.
| |
| 72 failed_distillation_counter_++; | |
| 60 distilled_state_ = distilled_state; | 73 distilled_state_ = distilled_state; |
| 61 distilled_url_ = GURL(); | 74 distilled_url_ = GURL(); |
| 62 } | 75 } |
| OLD | NEW |