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

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

Issue 2387823002: Adding ClearBlackList to the PreviewsBlackList and plumbing to UI (Closed)
Patch Set: tbansal comments Created 4 years, 2 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 #ifndef COMPONENTS_PREVIEWS_CORE_PREVIEWS_IO_DATA_H_ 5 #ifndef COMPONENTS_PREVIEWS_CORE_PREVIEWS_IO_DATA_H_
6 #define COMPONENTS_PREVIEWS_CORE_PREVIEWS_IO_DATA_H_ 6 #define COMPONENTS_PREVIEWS_CORE_PREVIEWS_IO_DATA_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/time/time.h"
15 #include "components/previews/core/previews_opt_out_store.h" 16 #include "components/previews/core/previews_opt_out_store.h"
16 17
18 class GURL;
19
17 namespace previews { 20 namespace previews {
18 class PreviewsBlackList; 21 class PreviewsBlackList;
19 class PreviewsUIService; 22 class PreviewsUIService;
20 23
21 // A class to manage the IO portion of inter-thread communication between 24 // A class to manage the IO portion of inter-thread communication between
22 // previews/ objects. Created on the UI thread, but used only on the IO thread 25 // previews/ objects. Created on the UI thread, but used only on the IO thread
23 // after initialization. 26 // after initialization.
24 class PreviewsIOData { 27 class PreviewsIOData {
25 public: 28 public:
26 PreviewsIOData( 29 PreviewsIOData(
27 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, 30 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner,
28 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); 31 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner);
29 virtual ~PreviewsIOData(); 32 virtual ~PreviewsIOData();
30 33
31 // Stores |previews_ui_service| as |previews_ui_service_| and posts a task to 34 // Stores |previews_ui_service| as |previews_ui_service_| and posts a task to
32 // InitializeOnIOThread on the IO thread. 35 // InitializeOnIOThread on the IO thread.
33 void Initialize(base::WeakPtr<PreviewsUIService> previews_ui_service, 36 void Initialize(base::WeakPtr<PreviewsUIService> previews_ui_service,
34 std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store); 37 std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store);
35 38
39 // Adds a navigation to |url| to the black list with result |opt_out|.
40 void AddPreviewNavigation(const GURL& url, bool opt_out, PreviewsType type);
41
42 // Clears the history of the black list between |begin_time| and |end_time|.
tbansal1 2016/10/04 00:16:59 Add: both inclusive.
RyanSturm 2016/10/04 20:27:23 Done.
43 void ClearBlackList(base::Time begin_time, base::Time end_time);
44
45 // The previews black list that decides whether a navigation can use previews.
36 PreviewsBlackList* black_list() const { return previews_black_list_.get(); } 46 PreviewsBlackList* black_list() const { return previews_black_list_.get(); }
37 47
38 protected: 48 protected:
39 // Posts a task to SetIOData for |previews_ui_service_| on the UI thread with 49 // Posts a task to SetIOData for |previews_ui_service_| on the UI thread with
40 // a weak pointer to |this|. Virtualized for testing. 50 // a weak pointer to |this|. Virtualized for testing.
41 virtual void InitializeOnIOThread( 51 virtual void InitializeOnIOThread(
42 std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store); 52 std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store);
43 53
44 private: 54 private:
45 // The UI thread portion of the inter-thread communication for previews. 55 // The UI thread portion of the inter-thread communication for previews.
46 base::WeakPtr<PreviewsUIService> previews_ui_service_; 56 base::WeakPtr<PreviewsUIService> previews_ui_service_;
47 57
48 std::unique_ptr<PreviewsBlackList> previews_black_list_; 58 std::unique_ptr<PreviewsBlackList> previews_black_list_;
49 59
50 // The UI and IO thread task runners. |ui_task_runner_| is used to post 60 // The UI and IO thread task runners. |ui_task_runner_| is used to post
51 // tasks to |previews_ui_service_|, and |io_task_runner_| is used to post from 61 // tasks to |previews_ui_service_|, and |io_task_runner_| is used to post from
52 // Initialize to InitializeOnIOThread as well as verify that execution is 62 // Initialize to InitializeOnIOThread as well as verify that execution is
53 // happening on the IO thread. 63 // happening on the IO thread.
54 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; 64 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
55 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 65 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
56 66
57 base::WeakPtrFactory<PreviewsIOData> weak_factory_; 67 base::WeakPtrFactory<PreviewsIOData> weak_factory_;
58 68
59 DISALLOW_COPY_AND_ASSIGN(PreviewsIOData); 69 DISALLOW_COPY_AND_ASSIGN(PreviewsIOData);
60 }; 70 };
61 71
62 } // namespace previews 72 } // namespace previews
63 73
64 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_IO_DATA_H_ 74 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_IO_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698