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 #ifndef COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_ITEM_H_ | 5 #ifndef COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_ITEM_H_ |
| 6 #define COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_ITEM_H_ | 6 #define COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_ITEM_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <deque> |
| 11 #include <map> | 11 #include <map> |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include "base/callback.h" | 15 #include "base/callback.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/optional.h" | 17 #include "base/optional.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 | 19 |
| 20 namespace previews { | 20 namespace previews { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 42 | 42 |
| 43 base::Optional<base::Time> most_recent_opt_out_time() const { | 43 base::Optional<base::Time> most_recent_opt_out_time() const { |
| 44 return most_recent_opt_out_time_; | 44 return most_recent_opt_out_time_; |
| 45 } | 45 } |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 // A previews navigation to this host is represented by time and whether the | 48 // A previews navigation to this host is represented by time and whether the |
| 49 // navigation was an opt out. | 49 // navigation was an opt out. |
| 50 struct OptOutRecord { | 50 struct OptOutRecord { |
| 51 OptOutRecord(base::Time entry_time, bool opt_out); | 51 OptOutRecord(base::Time entry_time, bool opt_out); |
| 52 ~OptOutRecord() {} | 52 OptOutRecord& operator=(const OptOutRecord&); |
| 53 const base::Time | 53 ~OptOutRecord(); |
| 54 entry_time; // The time that the opt out state was determined. | 54 |
| 55 const bool opt_out; // Whether the user opt out of the preview. | 55 base::Time entry_time; // The time that the opt out state was determined. |
|
tbansal1
2016/10/21 22:56:26
What happens if you keep them as const?
I am a bit
RyanSturm
2016/10/24 22:24:40
Since priority_queue is basically a vector of thes
| |
| 56 bool opt_out; // Whether the user opt out of the preview. | |
| 56 }; | 57 }; |
| 57 | 58 |
| 58 // The number of entries to store to determine preview eligibility. | 59 // The number of entries to store to determine preview eligibility. |
| 59 const size_t max_stored_history_length_; | 60 const size_t max_stored_history_length_; |
| 60 // The number opt outs in recent history that will trigger blacklisting. | 61 // The number opt outs in recent history that will trigger blacklisting. |
| 61 const int opt_out_black_list_threshold_; | 62 const int opt_out_black_list_threshold_; |
| 62 // The amount of time to black list a domain after the most recent opt out. | 63 // The amount of time to black list a domain after the most recent opt out. |
| 63 const base::TimeDelta max_black_list_duration_; | 64 const base::TimeDelta max_black_list_duration_; |
| 64 | 65 |
| 65 // The |max_stored_history_length_| most recent previews navigation. Is | 66 // The |max_stored_history_length_| most recent previews navigation. Is |
| 66 // maintained as a list sorted by entry_time (earliest to latest). | 67 // maintained as a list sorted by entry_time (earliest to latest). |
| 67 std::list<OptOutRecord> opt_out_records_; | 68 std::deque<OptOutRecord> opt_out_records_; |
|
tbansal1
2016/10/21 22:56:26
Since the list needs to be sorted, why not just us
RyanSturm
2016/10/24 22:24:40
Done.
| |
| 68 | 69 |
| 69 // Time of the most recent opt out. | 70 // Time of the most recent opt out. |
| 70 base::Optional<base::Time> most_recent_opt_out_time_; | 71 base::Optional<base::Time> most_recent_opt_out_time_; |
| 71 | 72 |
| 72 // The total number of opt outs currently in |opt_out_records_|. | 73 // The total number of opt outs currently in |opt_out_records_|. |
| 73 int total_opt_out_; | 74 int total_opt_out_; |
| 74 | 75 |
| 75 DISALLOW_COPY_AND_ASSIGN(PreviewsBlackListItem); | 76 DISALLOW_COPY_AND_ASSIGN(PreviewsBlackListItem); |
| 76 }; | 77 }; |
| 77 | 78 |
| 78 } // namespace previews | 79 } // namespace previews |
| 79 | 80 |
| 80 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_ITEM_H_ | 81 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_ITEM_H_ |
| OLD | NEW |