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 <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 // Stores |previews_ui_service| as |previews_ui_service_| and posts a task to | 31 // Stores |previews_ui_service| as |previews_ui_service_| and posts a task to |
32 // InitializeOnIOThread on the IO thread. | 32 // InitializeOnIOThread on the IO thread. |
33 void Initialize(base::WeakPtr<PreviewsUIService> previews_ui_service, | 33 void Initialize(base::WeakPtr<PreviewsUIService> previews_ui_service, |
34 std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store); | 34 std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store); |
35 | 35 |
36 PreviewsBlackList* black_list() const { return previews_black_list_.get(); } | 36 PreviewsBlackList* black_list() const { return previews_black_list_.get(); } |
37 | 37 |
38 protected: | 38 protected: |
39 // Posts a task to SetIOData for |previews_ui_service_| on the UI thread with | 39 // Posts a task to SetIOData for |previews_ui_service_| on the UI thread with |
40 // a weak pointer to |this|. Virtualized for testing. | 40 // a weak pointer to |this|. Virtualized for testing. |
41 virtual void InitializeOnIOThread( | 41 virtual void InitializeOnIOThread(); |
42 std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store); | |
43 | 42 |
44 private: | 43 private: |
45 // The UI thread portion of the inter-thread communication for previews. | 44 // The UI thread portion of the inter-thread communication for previews. |
46 base::WeakPtr<PreviewsUIService> previews_ui_service_; | 45 base::WeakPtr<PreviewsUIService> previews_ui_service_; |
47 | 46 |
48 std::unique_ptr<PreviewsBlackList> previews_black_list_; | 47 std::unique_ptr<PreviewsBlackList> previews_black_list_; |
49 | 48 |
50 // The UI and IO thread task runners. |ui_task_runner_| is used to post | 49 // 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 | 50 // 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 | 51 // Initialize to InitializeOnIOThread as well as verify that execution is |
53 // happening on the IO thread. | 52 // happening on the IO thread. |
54 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 53 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
55 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 54 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
56 | 55 |
57 base::WeakPtrFactory<PreviewsIOData> weak_factory_; | 56 base::WeakPtrFactory<PreviewsIOData> weak_factory_; |
58 | 57 |
59 DISALLOW_COPY_AND_ASSIGN(PreviewsIOData); | 58 DISALLOW_COPY_AND_ASSIGN(PreviewsIOData); |
60 }; | 59 }; |
61 | 60 |
62 } // namespace previews | 61 } // namespace previews |
63 | 62 |
64 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_IO_DATA_H_ | 63 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_IO_DATA_H_ |
OLD | NEW |