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..7d358615a2709c481de874a4c2e2fea93275ade7 |
| --- /dev/null |
| +++ b/extensions/common/features/feature_session_type.cc |
| @@ -0,0 +1,36 @@ |
| +// 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" |
| +#include "base/memory/ptr_util.h" |
| + |
| +namespace extensions { |
| + |
| +namespace { |
| + |
| +const FeatureSessionType kDefaultSessionType = FeatureSessionType::UNKNOWN; |
| +FeatureSessionType g_current_session_type = kDefaultSessionType; |
| + |
| +} // namespace |
| + |
| +FeatureSessionType GetCurrentFeatureSessionType() { |
| + return g_current_session_type; |
| +} |
| + |
| +void SetCurrentFeatureSessionType(FeatureSessionType session_type) { |
| + // Make sure that session type stays constants after it's been initialized. |
|
Devlin
2016/08/19 00:43:28
It's not really that it stays constant in the case
tbarzic
2016/08/19 17:23:32
Yeah, it may be different in tests, but that's kin
|
| + CHECK(g_current_session_type == kDefaultSessionType || |
| + session_type == g_current_session_type); |
| + g_current_session_type = session_type; |
| +} |
| + |
| +std::unique_ptr<base::AutoReset<FeatureSessionType>> |
| +ScopedCurrentFeatureSessionType(FeatureSessionType type) { |
| + return base::MakeUnique<base::AutoReset<FeatureSessionType>>( |
| + &g_current_session_type, type); |
| +} |
| + |
| +} // namespace extensions |