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

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

Issue 2335023002: Adding a previews IO-thread blacklist (Closed)
Patch Set: tbansal comments Created 4 years, 3 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 <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 "components/previews/core/previews_opt_out_store.h"
15 16
16 namespace previews { 17 namespace previews {
18 class PreviewsBlackList;
17 class PreviewsUIService; 19 class PreviewsUIService;
18 20
19 // A class to manage the IO portion of inter-thread communication between 21 // 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 22 // previews/ objects. Created on the UI thread, but used only on the IO thread
21 // after initialization. 23 // after initialization.
22 class PreviewsIOData { 24 class PreviewsIOData {
23 public: 25 public:
24 PreviewsIOData( 26 PreviewsIOData(
25 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, 27 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner,
26 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); 28 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner);
27 virtual ~PreviewsIOData(); 29 virtual ~PreviewsIOData();
28 30
29 // 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
30 // InitializeOnIOThread on the IO thread. 32 // InitializeOnIOThread on the IO thread.
31 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);
35
36 PreviewsBlackList* black_list() const { return previews_black_list_.get(); }
32 37
33 protected: 38 protected:
34 // 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
35 // a weak pointer to |this|. Virtualized for testing. 40 // a weak pointer to |this|. Virtualized for testing.
36 virtual void InitializeOnIOThread(); 41 virtual void InitializeOnIOThread(
42 std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store);
37 43
38 private: 44 private:
39 // The UI thread portion of the inter-thread communication for previews. 45 // The UI thread portion of the inter-thread communication for previews.
40 base::WeakPtr<PreviewsUIService> previews_ui_service_; 46 base::WeakPtr<PreviewsUIService> previews_ui_service_;
41 47
48 std::unique_ptr<PreviewsBlackList> previews_black_list_;
49
42 // The UI and IO thread task runners. |ui_task_runner_| is used to post 50 // 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 51 // 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 52 // Initialize to InitializeOnIOThread as well as verify that execution is
45 // happening on the IO thread. 53 // happening on the IO thread.
46 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; 54 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
47 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 55 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
48 56
49 base::WeakPtrFactory<PreviewsIOData> weak_factory_; 57 base::WeakPtrFactory<PreviewsIOData> weak_factory_;
50 58
51 DISALLOW_COPY_AND_ASSIGN(PreviewsIOData); 59 DISALLOW_COPY_AND_ASSIGN(PreviewsIOData);
52 }; 60 };
53 61
54 } // namespace previews 62 } // namespace previews
55 63
56 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_IO_DATA_H_ 64 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_IO_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698