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

Unified Diff: chrome/common/extensions/features/feature.h

Issue 10826199: Properly propagate the current Chrome channel into the Feature system on the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 8 years, 4 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
Index: chrome/common/extensions/features/feature.h
diff --git a/chrome/common/extensions/features/feature.h b/chrome/common/extensions/features/feature.h
index 2683d5b8f999dcb592f80f5606ff7495f27af845..bf315acac6ef6f1e793f39224dbfd530a84dd96c 100644
--- a/chrome/common/extensions/features/feature.h
+++ b/chrome/common/extensions/features/feature.h
@@ -68,23 +68,44 @@ class Feature {
Feature(const Feature& other);
virtual ~Feature();
- // (Re)Sets whether checking against "channel" should be done. This must only
- // be called on the browser process, since the check involves accessing the
- // filesystem.
- // See http://crbug.com/126535.
- static void SetChannelCheckingEnabled(bool enabled);
- static void ResetChannelCheckingEnabled();
-
- // (Re)Sets the Channel to for all Features to compare against. This is
- // usually chrome::VersionInfo::GetChannel(), but for tests allow this to be
- // overridden.
- static void SetChannelForTesting(chrome::VersionInfo::Channel channel);
- static void ResetChannelForTesting();
-
- // Returns the current channel as seen by the Feature system (i.e. the
- // ChannelForTesting if one is set, otherwise the actual channel).
+ // Returns true if a channel has been set.
+ static bool HasCurrentChannel();
+
+ // Gets the current channel as seen by the Feature system.
+ // SetCurrentChannel() must have already been called.
static chrome::VersionInfo::Channel GetCurrentChannel();
+ // Sets the current channel as seen by the Feature system. In the browser
+ // process this should be chrome::VersionInfo::GetChannel(), and in the
+ // renderer this will need to come from an IPC.
+ static void SetCurrentChannel(chrome::VersionInfo::Channel channel);
+
+ // Clears the current channel as seen by the Feature system.
+ static void ClearCurrentChannel();
+
+ // Scoped channel setter. Use for tests.
+ class ScopedCurrentChannel {
+ public:
+ explicit ScopedCurrentChannel(chrome::VersionInfo::Channel channel)
+ : has_original_channel_(false),
+ original_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) {
+ if (HasCurrentChannel()) {
+ has_original_channel_ = true;
+ original_channel_ = GetCurrentChannel();
+ }
+ SetCurrentChannel(channel);
+ }
+
+ ~ScopedCurrentChannel() {
+ if (has_original_channel_)
+ SetCurrentChannel(original_channel_);
Matt Perry 2012/08/08 19:17:26 else: ClearCurrentChannel?
not at google - send to devlin 2012/08/09 00:14:37 Oops. Thanks.
+ }
+
+ private:
+ bool has_original_channel_;
+ chrome::VersionInfo::Channel original_channel_;
+ };
+
const std::string& name() const { return name_; }
void set_name(const std::string& name) { name_ = name; }

Powered by Google App Engine
This is Rietveld 408576698