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

Unified Diff: base/test/scoped_environment_variable.h

Issue 11271024: Fix DeviceStatusCollectorTest.MaxStoredPeriods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 1 month 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: base/test/scoped_environment_variable.h
diff --git a/base/test/scoped_environment_variable.h b/base/test/scoped_environment_variable.h
new file mode 100644
index 0000000000000000000000000000000000000000..0a49049570bd11a4198ca64ccca4af271c678113
--- /dev/null
+++ b/base/test/scoped_environment_variable.h
@@ -0,0 +1,35 @@
+// Copyright (c) 2012 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.
+
+#ifndef BASE_TEST_SCOPED_ENVIRONMENT_VARIABLE_H_
+#define BASE_TEST_SCOPED_ENVIRONMENT_VARIABLE_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+
+namespace base {
+
+class Environment;
+
+// Overrides the environment variable value for |name| while in scope. The
+// previous value is restored when this goes out of scope.
+class ScopedEnvironmentVariable {
+ public:
+ ScopedEnvironmentVariable(const std::string& name, const std::string& value);
+ ~ScopedEnvironmentVariable();
+
+ private:
+ std::string name_;
+ bool prev_was_set_;
+ std::string prev_value_;
+ scoped_ptr<base::Environment> environment_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedEnvironmentVariable);
+};
+
+} // namespace base
+
+#endif // BASE_TEST_SCOPED_ENVIRONMENT_VARIABLE_H_

Powered by Google App Engine
This is Rietveld 408576698