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

Side by Side Diff: components/previews/core/previews_black_list.h

Issue 2439203002: Adding a short blacklist period after every previews opt out (Closed)
Patch Set: tbansal comments Created 4 years, 1 month 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 #ifndef COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_H_ 5 #ifndef COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_H_
6 #define COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_H_ 6 #define COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <queue> 11 #include <queue>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
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/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
18 #include "base/optional.h"
18 #include "base/threading/thread_checker.h" 19 #include "base/threading/thread_checker.h"
19 #include "components/previews/core/previews_opt_out_store.h" 20 #include "components/previews/core/previews_opt_out_store.h"
20 21
21 class GURL; 22 class GURL;
22 23
23 namespace base { 24 namespace base {
24 class Clock; 25 class Clock;
tbansal1 2016/10/25 00:47:41 #include "base/time/time.h" and remove this. (oth
RyanSturm 2016/10/25 17:15:38 I definitely need base/time/time.h, but I also nee
25 } 26 }
26 27
27 namespace previews { 28 namespace previews {
28 class PreviewsBlackListItem; 29 class PreviewsBlackListItem;
29 30
30 // Manages the state of black listed domains for the previews experiment. Loads 31 // Manages the state of black listed domains for the previews experiment. Loads
31 // the stored black list from |opt_out_store| and manages an in memory black 32 // the stored black list from |opt_out_store| and manages an in memory black
32 // list on the IO thread. Updates to the black list are stored in memory and 33 // list on the IO thread. Updates to the black list are stored in memory and
33 // pushed to the store. Asynchronous modifications are stored in a queue and 34 // pushed to the store. Asynchronous modifications are stored in a queue and
34 // executed in order. Reading from the black list is always synchronous, and if 35 // executed in order. Reading from the black list is always synchronous, and if
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // Enqueues a task to run when when loading black list information has 97 // Enqueues a task to run when when loading black list information has
97 // completed. Maintains the order that tasks were called in. 98 // completed. Maintains the order that tasks were called in.
98 void QueuePendingTask(base::Closure callback); 99 void QueuePendingTask(base::Closure callback);
99 100
100 // Map maintaining the in-memory black list. 101 // Map maintaining the in-memory black list.
101 std::unique_ptr<BlackListItemMap> black_list_item_map_; 102 std::unique_ptr<BlackListItemMap> black_list_item_map_;
102 103
103 // Whether the black list is done being loaded from the backing store. 104 // Whether the black list is done being loaded from the backing store.
104 bool loaded_; 105 bool loaded_;
105 106
107 // The time of the last opt out for this session.
108 base::Optional<base::Time> last_opt_out_time_;
109
106 // The backing store of the black list information. 110 // The backing store of the black list information.
107 std::unique_ptr<PreviewsOptOutStore> opt_out_store_; 111 std::unique_ptr<PreviewsOptOutStore> opt_out_store_;
108 112
109 // Callbacks to be run after loading information from the backing store has 113 // Callbacks to be run after loading information from the backing store has
110 // completed. 114 // completed.
111 std::queue<base::Closure> pending_callbacks_; 115 std::queue<base::Closure> pending_callbacks_;
112 116
113 std::unique_ptr<base::Clock> clock_; 117 std::unique_ptr<base::Clock> clock_;
114 118
115 base::ThreadChecker thread_checker_; 119 base::ThreadChecker thread_checker_;
116 120
117 base::WeakPtrFactory<PreviewsBlackList> weak_factory_; 121 base::WeakPtrFactory<PreviewsBlackList> weak_factory_;
118 122
119 DISALLOW_COPY_AND_ASSIGN(PreviewsBlackList); 123 DISALLOW_COPY_AND_ASSIGN(PreviewsBlackList);
120 }; 124 };
121 125
122 } // namespace previews 126 } // namespace previews
123 127
124 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_H_ 128 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_BLACK_LIST_H_
OLDNEW
« no previous file with comments | « no previous file | components/previews/core/previews_black_list.cc » ('j') | components/previews/core/previews_black_list.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698