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_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 <string> | 9 #include <string> |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
13 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
14 #include "base/threading/thread_checker.h" | 15 #include "base/time/time.h" |
tbansal1
2016/09/20 17:48:52
#include "base/time/time.h" not needed
RyanSturm
2016/09/20 18:38:17
Done.
| |
16 #include "components/previews/core/previews_opt_out_store.h" | |
15 | 17 |
16 namespace previews { | 18 namespace previews { |
19 class PreviewsBlackList; | |
17 class PreviewsUIService; | 20 class PreviewsUIService; |
18 | 21 |
19 // A class to manage the IO portion of inter-thread communication between | 22 // A class to manage the IO portion of inter-thread communication between |
20 // previews/ objects. Created on the UI thread, but used only on the IO thread | 23 // previews/ objects. Created on the UI thread, but used only on the IO thread |
21 // after initialization. | 24 // after initialization. |
22 class PreviewsIOData { | 25 class PreviewsIOData { |
23 public: | 26 public: |
24 PreviewsIOData( | 27 PreviewsIOData( |
25 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, | 28 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, |
26 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | 29 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); |
27 virtual ~PreviewsIOData(); | 30 virtual ~PreviewsIOData(); |
28 | 31 |
29 // Stores |previews_ui_service| as |previews_ui_service_| and posts a task to | 32 // Stores |previews_ui_service| as |previews_ui_service_| and posts a task to |
30 // InitializeOnIOThread on the IO thread. | 33 // InitializeOnIOThread on the IO thread. |
31 void Initialize(base::WeakPtr<PreviewsUIService> previews_ui_service); | 34 void Initialize(base::WeakPtr<PreviewsUIService> previews_ui_service, |
35 std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store); | |
36 | |
37 PreviewsBlackList* black_list() const { return previews_black_list_.get(); } | |
32 | 38 |
33 protected: | 39 protected: |
34 // Posts a task to SetIOData for |previews_ui_service_| on the UI thread with | 40 // Posts a task to SetIOData for |previews_ui_service_| on the UI thread with |
35 // a weak pointer to |this|. Virtualized for testing. | 41 // a weak pointer to |this|. Virtualized for testing. |
36 virtual void InitializeOnIOThread(); | 42 virtual void InitializeOnIOThread( |
43 std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store); | |
37 | 44 |
38 private: | 45 private: |
39 // The UI thread portion of the inter-thread communication for previews. | 46 // The UI thread portion of the inter-thread communication for previews. |
40 base::WeakPtr<PreviewsUIService> previews_ui_service_; | 47 base::WeakPtr<PreviewsUIService> previews_ui_service_; |
41 | 48 |
49 std::unique_ptr<PreviewsBlackList> previews_black_list_; | |
50 | |
42 // The UI and IO thread task runners. |ui_task_runner_| is used to post | 51 // The UI and IO thread task runners. |ui_task_runner_| is used to post |
43 // tasks to |previews_ui_service_|, and |io_task_runner_| is used to post from | 52 // tasks to |previews_ui_service_|, and |io_task_runner_| is used to post from |
44 // Initialize to InitializeOnIOThread as well as verify that execution is | 53 // Initialize to InitializeOnIOThread as well as verify that execution is |
45 // happening on the IO thread. | 54 // happening on the IO thread. |
46 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 55 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
47 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 56 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
48 | 57 |
49 base::WeakPtrFactory<PreviewsIOData> weak_factory_; | 58 base::WeakPtrFactory<PreviewsIOData> weak_factory_; |
50 | 59 |
51 DISALLOW_COPY_AND_ASSIGN(PreviewsIOData); | 60 DISALLOW_COPY_AND_ASSIGN(PreviewsIOData); |
52 }; | 61 }; |
53 | 62 |
54 } // namespace previews | 63 } // namespace previews |
55 | 64 |
56 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_IO_DATA_H_ | 65 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_IO_DATA_H_ |
OLD | NEW |