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

Side by Side Diff: components/component_updater/configurator_impl.cc

Issue 2661113003: Skeleton mechanical impl. for the RecoveryImprovedComponent. (Closed)
Patch Set: . Created 3 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "components/component_updater/configurator_impl.h" 5 #include "components/component_updater/configurator_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 const char kSwitchUrlSource[] = "url-source"; 47 const char kSwitchUrlSource[] = "url-source";
48 48
49 // Disables differential updates. 49 // Disables differential updates.
50 const char kSwitchDisableDeltaUpdates[] = "disable-delta-updates"; 50 const char kSwitchDisableDeltaUpdates[] = "disable-delta-updates";
51 51
52 #if defined(OS_WIN) 52 #if defined(OS_WIN)
53 // Disables background downloads. 53 // Disables background downloads.
54 const char kSwitchDisableBackgroundDownloads[] = "disable-background-downloads"; 54 const char kSwitchDisableBackgroundDownloads[] = "disable-background-downloads";
55 #endif // defined(OS_WIN) 55 #endif // defined(OS_WIN)
56 56
57 const char kSwitchEnableImprovedRecovery[] = "enable-improved-recovery";
58
57 // Returns true if and only if |test| is contained in |vec|. 59 // Returns true if and only if |test| is contained in |vec|.
58 bool HasSwitchValue(const std::vector<std::string>& vec, const char* test) { 60 bool HasSwitchValue(const std::vector<std::string>& vec, const char* test) {
59 if (vec.empty()) 61 if (vec.empty())
60 return 0; 62 return 0;
61 return (std::find(vec.begin(), vec.end(), test) != vec.end()); 63 return (std::find(vec.begin(), vec.end(), test) != vec.end());
62 } 64 }
63 65
64 // If there is an element of |vec| of the form |test|=.*, returns the right- 66 // If there is an element of |vec| of the form |test|=.*, returns the right-
65 // hand side of that assignment. Otherwise, returns an empty string. 67 // hand side of that assignment. Otherwise, returns an empty string.
66 // The right-hand side may contain additional '=' characters, allowing for 68 // The right-hand side may contain additional '=' characters, allowing for
(...skipping 18 matching lines...) Expand all
85 87
86 ConfiguratorImpl::ConfiguratorImpl( 88 ConfiguratorImpl::ConfiguratorImpl(
87 const base::CommandLine* cmdline, 89 const base::CommandLine* cmdline,
88 net::URLRequestContextGetter* url_request_getter, 90 net::URLRequestContextGetter* url_request_getter,
89 bool require_encryption) 91 bool require_encryption)
90 : url_request_getter_(url_request_getter), 92 : url_request_getter_(url_request_getter),
91 fast_update_(false), 93 fast_update_(false),
92 pings_enabled_(false), 94 pings_enabled_(false),
93 deltas_enabled_(false), 95 deltas_enabled_(false),
94 background_downloads_enabled_(false), 96 background_downloads_enabled_(false),
95 require_encryption_(require_encryption) { 97 require_encryption_(require_encryption),
98 enabled_improved_recovery_(false) {
96 // Parse comma-delimited debug flags. 99 // Parse comma-delimited debug flags.
97 std::vector<std::string> switch_values = base::SplitString( 100 std::vector<std::string> switch_values = base::SplitString(
98 cmdline->GetSwitchValueASCII(switches::kComponentUpdater), ",", 101 cmdline->GetSwitchValueASCII(switches::kComponentUpdater), ",",
99 base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); 102 base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
100 fast_update_ = HasSwitchValue(switch_values, kSwitchFastUpdate); 103 fast_update_ = HasSwitchValue(switch_values, kSwitchFastUpdate);
101 pings_enabled_ = !HasSwitchValue(switch_values, kSwitchDisablePings); 104 pings_enabled_ = !HasSwitchValue(switch_values, kSwitchDisablePings);
102 deltas_enabled_ = !HasSwitchValue(switch_values, kSwitchDisableDeltaUpdates); 105 deltas_enabled_ = !HasSwitchValue(switch_values, kSwitchDisableDeltaUpdates);
103 106 enabled_improved_recovery_ =
107 HasSwitchValue(switch_values, kSwitchEnableImprovedRecovery);
104 #if defined(OS_WIN) 108 #if defined(OS_WIN)
105 background_downloads_enabled_ = 109 background_downloads_enabled_ =
106 !HasSwitchValue(switch_values, kSwitchDisableBackgroundDownloads); 110 !HasSwitchValue(switch_values, kSwitchDisableBackgroundDownloads);
107 #else 111 #else
108 background_downloads_enabled_ = false; 112 background_downloads_enabled_ = false;
109 #endif 113 #endif
110 114
111 const std::string switch_url_source = 115 const std::string switch_url_source =
112 GetSwitchArgument(switch_values, kSwitchUrlSource); 116 GetSwitchArgument(switch_values, kSwitchUrlSource);
113 if (!switch_url_source.empty()) { 117 if (!switch_url_source.empty()) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 193 }
190 194
191 bool ConfiguratorImpl::EnabledBackgroundDownloader() const { 195 bool ConfiguratorImpl::EnabledBackgroundDownloader() const {
192 return background_downloads_enabled_; 196 return background_downloads_enabled_;
193 } 197 }
194 198
195 bool ConfiguratorImpl::EnabledCupSigning() const { 199 bool ConfiguratorImpl::EnabledCupSigning() const {
196 return true; 200 return true;
197 } 201 }
198 202
203 bool ConfiguratorImpl::EnabledImprovedRecovery() const {
204 #if defined(OS_WIN) || defined(OS_MACOSX)
205 return enabled_improved_recovery_;
206 #else
207 return false;
208 #endif
209 }
210
199 } // namespace component_updater 211 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698