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

Unified Diff: extensions/common/features/feature_channel.cc

Issue 2854293003: Fix losing of scoped feature channel in tests when it's equal to stable (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/common/features/feature_channel.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/features/feature_channel.cc
diff --git a/extensions/common/features/feature_channel.cc b/extensions/common/features/feature_channel.cc
index 13bd6e1dcaee847aaccae4e4510fac40a71aea5f..2cb3d767709b1f54385aa7a688febfe069753c8b 100644
--- a/extensions/common/features/feature_channel.cc
+++ b/extensions/common/features/feature_channel.cc
@@ -8,8 +8,9 @@
namespace {
-const version_info::Channel kDefaultChannel = version_info::Channel::STABLE;
-version_info::Channel g_current_channel = kDefaultChannel;
+version_info::Channel g_current_channel = version_info::Channel::STABLE;
+// The number of currently existing instances of |ScopedCurrentChannel|.
+int g_current_channel_override_count = 0;
} // namespace
@@ -20,21 +21,19 @@ version_info::Channel GetCurrentChannel() {
}
void SetCurrentChannel(version_info::Channel channel) {
- g_current_channel = channel;
-}
-
-version_info::Channel GetDefaultChannel() {
- return kDefaultChannel;
+ if (!g_current_channel_override_count)
Devlin 2017/05/15 20:34:47 We'd have this issue already, but I wonder if ther
+ g_current_channel = channel;
}
ScopedCurrentChannel::ScopedCurrentChannel(version_info::Channel channel)
- : original_channel_(version_info::Channel::UNKNOWN) {
- original_channel_ = GetCurrentChannel();
- SetCurrentChannel(channel);
+ : original_channel_(g_current_channel) {
+ g_current_channel = channel;
+ ++g_current_channel_override_count;
}
ScopedCurrentChannel::~ScopedCurrentChannel() {
- SetCurrentChannel(original_channel_);
+ --g_current_channel_override_count;
+ g_current_channel = original_channel_;
lazyboy 2017/05/03 19:01:14 Q: Two ScoppedCurrentChannel-s only nest, but cann
emaxx 2017/05/07 01:54:03 Yes, non-nesting overlapping won't work. I don't t
}
} // namespace extensions
« no previous file with comments | « extensions/common/features/feature_channel.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698