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

Side by Side Diff: chrome/browser/safe_browsing/settings_reset_prompt/default_settings_fetcher.h

Issue 2918053003: Settings reset prompt: Fetch default settings only when needed. (Closed)
Patch Set: Addressed Chris's comment Created 3 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_DEFAULT_SETTINGS_FETC HER_H_ 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_DEFAULT_SETTINGS_FETC HER_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_DEFAULT_SETTINGS_FETC HER_H_ 6 #define CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_DEFAULT_SETTINGS_FETC HER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 11
12 class BrandcodedDefaultSettings; 12 class BrandcodedDefaultSettings;
13 class BrandcodeConfigFetcher; 13 class BrandcodeConfigFetcher;
14 14
15 namespace safe_browsing { 15 namespace safe_browsing {
16 16
17 // Class that fetches default settings to be used for the settings reset 17 // Class that fetches default settings to be used for the settings reset
18 // prompt. The static |FetchDefaultSettings()| function will create and manage 18 // prompt. The static |FetchDefaultSettings()| function will create and manage
19 // the lifetime of |DefaultSettingsFetcher| instances. 19 // the lifetime of |DefaultSettingsFetcher| instances.
20 class DefaultSettingsFetcher { 20 class DefaultSettingsFetcher {
21 public: 21 public:
22 using SettingsCallback = 22 using SettingsCallback =
23 base::Callback<void(std::unique_ptr<BrandcodedDefaultSettings>)>; 23 base::Callback<void(std::unique_ptr<BrandcodedDefaultSettings>)>;
24 24
25 // Fetches default settings and passes the corresponding 25 // Fetches default settings and passes the corresponding
26 // |BrandcodedDefaultSettings| object to |callback| on the UI thread. This 26 // |BrandcodedDefaultSettings| object to |callback| on the UI thread. This
27 // function must be called on the UI thread as well. 27 // function must be called on the UI thread as well.
28 //
29 // If fetching of default settings on the network fails, a default-constructed
30 // BrandcodedDefaultSettings object will be passed to |callback|.
28 static void FetchDefaultSettings(SettingsCallback callback); 31 static void FetchDefaultSettings(SettingsCallback callback);
29 // Allows tests to specify the default settings that were fetched in 32 // Allows tests to specify the default settings that were fetched in
30 // |fetched_settings|. Passing nullptr as |fetched_settings| corresponds to 33 // |fetched_settings|. Passing nullptr as |fetched_settings| corresponds to
31 // the case when fetching default settings over the network fails. 34 // the case when fetching default settings over the network fails.
32 static void FetchDefaultSettingsForTesting( 35 static void FetchDefaultSettingsForTesting(
33 SettingsCallback callback, 36 SettingsCallback callback,
34 std::unique_ptr<BrandcodedDefaultSettings> fetched_settings); 37 std::unique_ptr<BrandcodedDefaultSettings> fetched_settings);
35 38
36 private: 39 private:
37 // Instances of |DefaultSettingsFetcher| own themselves and will delete 40 // Instances of |DefaultSettingsFetcher| own themselves and will delete
(...skipping 17 matching lines...) Expand all
55 void PostCallbackAndDeleteSelf( 58 void PostCallbackAndDeleteSelf(
56 std::unique_ptr<BrandcodedDefaultSettings> default_settings); 59 std::unique_ptr<BrandcodedDefaultSettings> default_settings);
57 60
58 std::unique_ptr<BrandcodeConfigFetcher> config_fetcher_; 61 std::unique_ptr<BrandcodeConfigFetcher> config_fetcher_;
59 SettingsCallback callback_; 62 SettingsCallback callback_;
60 }; 63 };
61 64
62 } // namespace safe_browsing 65 } // namespace safe_browsing
63 66
64 #endif // CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_DEFAULT_SETTINGS_F ETCHER_H_ 67 #endif // CHROME_BROWSER_SAFE_BROWSING_SETTINGS_RESET_PROMPT_DEFAULT_SETTINGS_F ETCHER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698