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

Side by Side 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, 7 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 | « extensions/common/features/feature_channel.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "extensions/common/features/feature_channel.h" 5 #include "extensions/common/features/feature_channel.h"
6 6
7 #include "components/version_info/version_info.h" 7 #include "components/version_info/version_info.h"
8 8
9 namespace { 9 namespace {
10 10
11 const version_info::Channel kDefaultChannel = version_info::Channel::STABLE; 11 version_info::Channel g_current_channel = version_info::Channel::STABLE;
12 version_info::Channel g_current_channel = kDefaultChannel; 12 // The number of currently existing instances of |ScopedCurrentChannel|.
13 int g_current_channel_override_count = 0;
13 14
14 } // namespace 15 } // namespace
15 16
16 namespace extensions { 17 namespace extensions {
17 18
18 version_info::Channel GetCurrentChannel() { 19 version_info::Channel GetCurrentChannel() {
19 return g_current_channel; 20 return g_current_channel;
20 } 21 }
21 22
22 void SetCurrentChannel(version_info::Channel channel) { 23 void SetCurrentChannel(version_info::Channel channel) {
23 g_current_channel = channel; 24 if (!g_current_channel_override_count)
Devlin 2017/05/15 20:34:47 We'd have this issue already, but I wonder if ther
24 } 25 g_current_channel = channel;
25
26 version_info::Channel GetDefaultChannel() {
27 return kDefaultChannel;
28 } 26 }
29 27
30 ScopedCurrentChannel::ScopedCurrentChannel(version_info::Channel channel) 28 ScopedCurrentChannel::ScopedCurrentChannel(version_info::Channel channel)
31 : original_channel_(version_info::Channel::UNKNOWN) { 29 : original_channel_(g_current_channel) {
32 original_channel_ = GetCurrentChannel(); 30 g_current_channel = channel;
33 SetCurrentChannel(channel); 31 ++g_current_channel_override_count;
34 } 32 }
35 33
36 ScopedCurrentChannel::~ScopedCurrentChannel() { 34 ScopedCurrentChannel::~ScopedCurrentChannel() {
37 SetCurrentChannel(original_channel_); 35 --g_current_channel_override_count;
36 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
38 } 37 }
39 38
40 } // namespace extensions 39 } // namespace extensions
OLDNEW
« 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