Chromium Code Reviews| Index: extensions/common/features/feature_session_type.cc |
| diff --git a/extensions/common/features/feature_session_type.cc b/extensions/common/features/feature_session_type.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e81595dc009fc26a332e2b27a855237ce26c4cdb |
| --- /dev/null |
| +++ b/extensions/common/features/feature_session_type.cc |
| @@ -0,0 +1,39 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "extensions/common/features/feature_session_type.h" |
| + |
| +#include "base/logging.h" |
| + |
| +namespace { |
| + |
| +const extensions::FeatureSessionType kDefaultSessionType = |
|
Devlin
2016/08/18 17:19:15
I think this variable is probably unnecessary.
tbarzic
2016/08/18 18:58:10
It's used to test whether the value has changed fr
|
| + extensions::FEATURE_SESSION_TYPE_UNKNOWN; |
| +extensions::FeatureSessionType g_current_session_type = kDefaultSessionType; |
|
Devlin
2016/08/18 17:19:15
Just put the anonymous namespace inside the extens
tbarzic
2016/08/18 18:58:10
Done.
|
| + |
| +} // namespace |
| + |
| +namespace extensions { |
| + |
| +FeatureSessionType GetCurrentFeatureSessionType() { |
| + return g_current_session_type; |
| +} |
| + |
| +void SetCurrentFeatureSessionType(FeatureSessionType session_type) { |
| + CHECK(g_current_session_type == kDefaultSessionType || |
| + session_type == g_current_session_type); |
|
Devlin
2016/08/18 17:19:15
I'm assuming the motivation here is to not let the
tbarzic
2016/08/18 18:58:10
Added a comment.
|
| + g_current_session_type = session_type; |
| +} |
| + |
| +ScopedCurrentFeatureSessionType::ScopedCurrentFeatureSessionType( |
| + FeatureSessionType session_type) { |
| + original_session_type_ = GetCurrentFeatureSessionType(); |
| + SetCurrentFeatureSessionType(session_type); |
| +} |
| + |
| +ScopedCurrentFeatureSessionType::~ScopedCurrentFeatureSessionType() { |
| + g_current_session_type = original_session_type_; |
| +} |
| + |
| +} // namespace extensions |