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

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

Issue 2748033002: Revert of Moving previews code from components/ to chrome/ (Closed)
Patch Set: Created 3 years, 9 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_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_experiments.h" 15 #include "components/previews/core/previews_experiments.h"
16 #include "components/previews/core/previews_io_data.h"
17 #include "components/previews/core/previews_opt_out_store.h" 16 #include "components/previews/core/previews_opt_out_store.h"
18 17
19 class GURL; 18 class GURL;
20 19
21 namespace base { 20 namespace base {
22 class SingleThreadTaskRunner; 21 class SingleThreadTaskRunner;
23 } 22 }
24 23
25 namespace previews { 24 namespace previews {
26 class PreviewsIOData; 25 class PreviewsIOData;
27 26
28 // A class to manage the UI portion of inter-thread communication between 27 // A class to manage the UI portion of inter-thread communication between
29 // previews/ objects. Created and used on the UI thread. 28 // previews/ objects. Created and used on the UI thread.
30 class PreviewsUIService { 29 class PreviewsUIService {
31 public: 30 public:
32 PreviewsUIService( 31 PreviewsUIService(
33 PreviewsIOData* previews_io_data, 32 PreviewsIOData* previews_io_data,
34 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, 33 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner,
35 std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store, 34 std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store);
36 const PreviewsIsEnabledCallback& is_enabled_callback);
37 virtual ~PreviewsUIService(); 35 virtual ~PreviewsUIService();
38 36
39 // Sets |io_data_| to |io_data| to allow calls from the UI thread to the IO 37 // Sets |io_data_| to |io_data| to allow calls from the UI thread to the IO
40 // thread. Virtualized in testing. 38 // thread. Virtualized in testing.
41 virtual void SetIOData(base::WeakPtr<PreviewsIOData> io_data); 39 virtual void SetIOData(base::WeakPtr<PreviewsIOData> io_data);
42 40
43 // Adds a navigation to |url| to the black list with result |opt_out|. 41 // Adds a navigation to |url| to the black list with result |opt_out|.
44 void AddPreviewNavigation(const GURL& url, PreviewsType type, bool opt_out); 42 void AddPreviewNavigation(const GURL& url, PreviewsType type, bool opt_out);
45 43
46 // Clears the history of the black list between |begin_time| and |end_time|. 44 // Clears the history of the black list between |begin_time| and |end_time|.
47 void ClearBlackList(base::Time begin_time, base::Time end_time); 45 void ClearBlackList(base::Time begin_time, base::Time end_time);
48 46
49 private: 47 private:
50 // The IO thread portion of the inter-thread communication for previews/. 48 // The IO thread portion of the inter-thread communication for previews/.
51 base::WeakPtr<previews::PreviewsIOData> io_data_; 49 base::WeakPtr<previews::PreviewsIOData> io_data_;
52 50
53 base::ThreadChecker thread_checker_; 51 base::ThreadChecker thread_checker_;
54 52
55 // The IO thread task runner. Used to post tasks to |io_data_|. 53 // The IO thread task runner. Used to post tasks to |io_data_|.
56 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 54 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
57 55
58 base::WeakPtrFactory<PreviewsUIService> weak_factory_; 56 base::WeakPtrFactory<PreviewsUIService> weak_factory_;
59 57
60 DISALLOW_COPY_AND_ASSIGN(PreviewsUIService); 58 DISALLOW_COPY_AND_ASSIGN(PreviewsUIService);
61 }; 59 };
62 60
63 } // namespace previews 61 } // namespace previews
64 62
65 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_UI_SERVICE_H_ 63 #endif // COMPONENTS_PREVIEWS_CORE_PREVIEWS_UI_SERVICE_H_
OLDNEW
« no previous file with comments | « components/previews/core/previews_opt_out_store_sql_unittest.cc ('k') | components/previews/core/previews_ui_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698