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

Side by Side Diff: components/quirks/quirks_manager.h

Issue 2006143011: Remove first check random delay on older devices (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove obsolete TODO Created 4 years, 5 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_QUIRKS_QUIRKS_MANAGER_H_ 5 #ifndef COMPONENTS_QUIRKS_QUIRKS_MANAGER_H_
6 #define COMPONENTS_QUIRKS_QUIRKS_MANAGER_H_ 6 #define COMPONENTS_QUIRKS_QUIRKS_MANAGER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 10
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // files ("Quirks"). The manager presents an external Quirks API, handles 50 // files ("Quirks"). The manager presents an external Quirks API, handles
51 // needed components from browser (local preferences, url context getter, 51 // needed components from browser (local preferences, url context getter,
52 // blocking pool, etc), and owns clients and manages their life cycles. 52 // blocking pool, etc), and owns clients and manages their life cycles.
53 class QUIRKS_EXPORT QuirksManager { 53 class QUIRKS_EXPORT QuirksManager {
54 public: 54 public:
55 // Passed function to create a URLFetcher for tests. 55 // Passed function to create a URLFetcher for tests.
56 // Same parameters as URLFetcher::Create(). 56 // Same parameters as URLFetcher::Create().
57 using FakeQuirksFetcherCreator = base::Callback< 57 using FakeQuirksFetcherCreator = base::Callback<
58 std::unique_ptr<net::URLFetcher>(const GURL&, net::URLFetcherDelegate*)>; 58 std::unique_ptr<net::URLFetcher>(const GURL&, net::URLFetcherDelegate*)>;
59 59
60 // Callback after getting days since OOBE on blocking pool.
61 // Parameter is returned number of days.
62 using DaysSinceOobeCallback = base::Callback<void(int)>;
63
64 // Delegate class, so implementation can access browser functionality. 60 // Delegate class, so implementation can access browser functionality.
65 class Delegate { 61 class Delegate {
66 public: 62 public:
67 virtual ~Delegate() = default; 63 virtual ~Delegate() = default;
68 64
69 // Provides Chrome API key for quirks server. 65 // Provides Chrome API key for quirks server.
70 virtual std::string GetApiKey() const = 0; 66 virtual std::string GetApiKey() const = 0;
71 67
72 // Returns the read-only directory where icc files were added before the 68 // Returns the read-only directory where icc files were added before the
73 // Quirks Client provided them. 69 // Quirks Client provided them.
74 virtual base::FilePath GetBuiltInDisplayProfileDirectory() const = 0; 70 virtual base::FilePath GetBuiltInDisplayProfileDirectory() const = 0;
75 71
76 // Returns the path to the writable display profile directory. 72 // Returns the path to the writable display profile directory.
77 // This directory must already exist. 73 // This directory must already exist.
78 virtual base::FilePath GetDownloadDisplayProfileDirectory() const = 0; 74 virtual base::FilePath GetDownloadDisplayProfileDirectory() const = 0;
79 75
80 // Whether downloads are allowed by enterprise device policy. 76 // Whether downloads are allowed by enterprise device policy.
81 virtual bool DevicePolicyEnabled() const = 0; 77 virtual bool DevicePolicyEnabled() const = 0;
82 78
83 // Gets days since first login, returned via callback.
84 virtual void GetDaysSinceOobe(DaysSinceOobeCallback callback) const = 0;
85
86 private: 79 private:
87 DISALLOW_ASSIGN(Delegate); 80 DISALLOW_ASSIGN(Delegate);
88 }; 81 };
89 82
90 static void Initialize( 83 static void Initialize(
91 std::unique_ptr<Delegate> delegate, 84 std::unique_ptr<Delegate> delegate,
92 scoped_refptr<base::SequencedWorkerPool> blocking_pool, 85 scoped_refptr<base::SequencedWorkerPool> blocking_pool,
93 PrefService* local_state, 86 PrefService* local_state,
94 scoped_refptr<net::URLRequestContextGetter> url_context_getter); 87 scoped_refptr<net::URLRequestContextGetter> url_context_getter);
95 static void Shutdown(); 88 static void Shutdown();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 PrefService* local_state, 125 PrefService* local_state,
133 scoped_refptr<net::URLRequestContextGetter> url_context_getter); 126 scoped_refptr<net::URLRequestContextGetter> url_context_getter);
134 ~QuirksManager(); 127 ~QuirksManager();
135 128
136 // Callback after checking for existing icc file; proceed if not found. 129 // Callback after checking for existing icc file; proceed if not found.
137 void OnIccFilePathRequestCompleted( 130 void OnIccFilePathRequestCompleted(
138 int64_t product_id, 131 int64_t product_id,
139 const RequestFinishedCallback& on_request_finished, 132 const RequestFinishedCallback& on_request_finished,
140 base::FilePath path); 133 base::FilePath path);
141 134
142 // Callback after checking OOBE date; launch client if appropriate.
143 void OnDaysSinceOobeReceived(
144 int64_t product_id,
145 const RequestFinishedCallback& on_request_finished,
146 int days_since_oobe);
147
148 // Create and start a client to download file.
149 void CreateClient(int64_t product_id,
150 const RequestFinishedCallback& on_request_finished);
151
152 // Whether downloads allowed by cmd line flag and device policy. 135 // Whether downloads allowed by cmd line flag and device policy.
153 bool QuirksEnabled(); 136 bool QuirksEnabled();
154 137
155 // Records time of most recent server check. 138 // Records time of most recent server check.
156 void SetLastServerCheck(int64_t product_id, const base::Time& last_check); 139 void SetLastServerCheck(int64_t product_id, const base::Time& last_check);
157 140
158 // Set of active clients, each created to download a different Quirks file. 141 // Set of active clients, each created to download a different Quirks file.
159 std::set<std::unique_ptr<QuirksClient>> clients_; 142 std::set<std::unique_ptr<QuirksClient>> clients_;
160 143
161 // Don't start downloads before first session login. 144 // Don't start downloads before first session login.
(...skipping 12 matching lines...) Expand all
174 157
175 // Factory for callbacks. 158 // Factory for callbacks.
176 base::WeakPtrFactory<QuirksManager> weak_ptr_factory_; 159 base::WeakPtrFactory<QuirksManager> weak_ptr_factory_;
177 160
178 DISALLOW_COPY_AND_ASSIGN(QuirksManager); 161 DISALLOW_COPY_AND_ASSIGN(QuirksManager);
179 }; 162 };
180 163
181 } // namespace quirks 164 } // namespace quirks
182 165
183 #endif // COMPONENTS_QUIRKS_QUIRKS_MANAGER_H_ 166 #endif // COMPONENTS_QUIRKS_QUIRKS_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/display/quirks_manager_delegate_impl.cc ('k') | components/quirks/quirks_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698