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_ |