| 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_PREVIEWS_UI_SERVICE_H_ | 5 #ifndef COMPONENTS_PREVIEWS_PREVIEWS_UI_SERVICE_H_ |
| 6 #define COMPONENTS_PREVIEWS_PREVIEWS_UI_SERVICE_H_ | 6 #define COMPONENTS_PREVIEWS_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/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 15 #include "base/time/time.h" |
| 16 #include "components/previews/previews_opt_out_store.h" |
| 15 | 17 |
| 16 namespace previews { | 18 namespace previews { |
| 17 class PreviewsIOData; | 19 class PreviewsIOData; |
| 18 | 20 |
| 19 // A class to manage the UI portion of inter-thread communication between | 21 // A class to manage the UI portion of inter-thread communication between |
| 20 // previews/ objects. Created and used on the UI thread. | 22 // previews/ objects. Created and used on the UI thread. |
| 21 class PreviewsUIService { | 23 class PreviewsUIService { |
| 22 public: | 24 public: |
| 23 PreviewsUIService( | 25 PreviewsUIService( |
| 24 PreviewsIOData* previews_io_data, | 26 PreviewsIOData* previews_io_data, |
| 25 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | 27 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
| 28 std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store); |
| 26 virtual ~PreviewsUIService(); | 29 virtual ~PreviewsUIService(); |
| 27 | 30 |
| 28 // Sets |io_data_| to |io_data| to allow calls from the UI thread to the IO | 31 // Sets |io_data_| to |io_data| to allow calls from the UI thread to the IO |
| 29 // thread. Virtualized in testing. | 32 // thread. Virtualized in testing. |
| 30 virtual void SetIOData(base::WeakPtr<PreviewsIOData> io_data); | 33 virtual void SetIOData(base::WeakPtr<PreviewsIOData> io_data); |
| 31 | 34 |
| 32 private: | 35 private: |
| 33 // The IO thread portion of the inter-thread communication for previews/. | 36 // The IO thread portion of the inter-thread communication for previews/. |
| 34 base::WeakPtr<previews::PreviewsIOData> io_data_; | 37 base::WeakPtr<previews::PreviewsIOData> io_data_; |
| 35 | 38 |
| 36 base::ThreadChecker thread_checker_; | 39 base::ThreadChecker thread_checker_; |
| 37 | 40 |
| 38 // The IO thread task runner. Used to post tasks to |io_data_|. | 41 // The IO thread task runner. Used to post tasks to |io_data_|. |
| 39 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 42 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 40 | 43 |
| 41 base::WeakPtrFactory<PreviewsUIService> weak_factory_; | 44 base::WeakPtrFactory<PreviewsUIService> weak_factory_; |
| 42 | 45 |
| 43 DISALLOW_COPY_AND_ASSIGN(PreviewsUIService); | 46 DISALLOW_COPY_AND_ASSIGN(PreviewsUIService); |
| 44 }; | 47 }; |
| 45 | 48 |
| 46 } // namespace previews | 49 } // namespace previews |
| 47 | 50 |
| 48 #endif // COMPONENTS_PREVIEWS_PREVIEWS_UI_SERVICE_H_ | 51 #endif // COMPONENTS_PREVIEWS_PREVIEWS_UI_SERVICE_H_ |
| OLD | NEW |