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_UI_SERVICE_H_ | 5 #ifndef COMPONENTS_PREVIEWS_CORE_PREVIEWS_UI_SERVICE_H_ |
6 #define COMPONENTS_PREVIEWS_CORE_PREVIEWS_UI_SERVICE_H_ | 6 #define COMPONENTS_PREVIEWS_CORE_PREVIEWS_UI_SERVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "components/previews/core/previews_opt_out_store.h" | 15 #include "components/previews/core/previews_opt_out_store.h" |
16 | 16 |
| 17 class GURL; |
| 18 |
17 namespace base { | 19 namespace base { |
18 class SingleThreadTaskRunner; | 20 class SingleThreadTaskRunner; |
19 } | 21 } |
20 | 22 |
21 namespace previews { | 23 namespace previews { |
22 class PreviewsIOData; | 24 class PreviewsIOData; |
23 | 25 |
24 // A class to manage the UI portion of inter-thread communication between | 26 // A class to manage the UI portion of inter-thread communication between |
25 // previews/ objects. Created and used on the UI thread. | 27 // previews/ objects. Created and used on the UI thread. |
26 class PreviewsUIService { | 28 class PreviewsUIService { |
27 public: | 29 public: |
28 PreviewsUIService( | 30 PreviewsUIService( |
29 PreviewsIOData* previews_io_data, | 31 PreviewsIOData* previews_io_data, |
30 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 32 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
31 std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store); | 33 std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store); |
32 virtual ~PreviewsUIService(); | 34 virtual ~PreviewsUIService(); |
33 | 35 |
34 // Sets |io_data_| to |io_data| to allow calls from the UI thread to the IO | 36 // Sets |io_data_| to |io_data| to allow calls from the UI thread to the IO |
35 // thread. Virtualized in testing. | 37 // thread. Virtualized in testing. |
36 virtual void SetIOData(base::WeakPtr<PreviewsIOData> io_data); | 38 virtual void SetIOData(base::WeakPtr<PreviewsIOData> io_data); |
37 | 39 |
| 40 // Adds a navigation to |url| to the black list with result |opt_out|. |
| 41 void AddPreviewNavigation(const GURL& url, PreviewsType type, bool opt_out); |
| 42 |
| 43 // Clears the history of the black list between |begin_time| and |end_time|. |
| 44 void ClearBlackList(base::Time begin_time, base::Time end_time); |
| 45 |
38 private: | 46 private: |
39 // The IO thread portion of the inter-thread communication for previews/. | 47 // The IO thread portion of the inter-thread communication for previews/. |
40 base::WeakPtr<previews::PreviewsIOData> io_data_; | 48 base::WeakPtr<previews::PreviewsIOData> io_data_; |
41 | 49 |
42 base::ThreadChecker thread_checker_; | 50 base::ThreadChecker thread_checker_; |
43 | 51 |
44 // The IO thread task runner. Used to post tasks to |io_data_|. | 52 // The IO thread task runner. Used to post tasks to |io_data_|. |
45 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 53 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
46 | 54 |
47 base::WeakPtrFactory<PreviewsUIService> weak_factory_; | 55 base::WeakPtrFactory<PreviewsUIService> weak_factory_; |
48 | 56 |
49 DISALLOW_COPY_AND_ASSIGN(PreviewsUIService); | 57 DISALLOW_COPY_AND_ASSIGN(PreviewsUIService); |
50 }; | 58 }; |
51 | 59 |
52 } // namespace previews | 60 } // namespace previews |
53 | 61 |
54 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_UI_SERVICE_H_ | 62 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_UI_SERVICE_H_ |
OLD | NEW |