OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef BASE_TEST_SCOPED_ENVIRONMENT_VARIABLE_H_ |
| 6 #define BASE_TEST_SCOPED_ENVIRONMENT_VARIABLE_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 |
| 13 namespace base { |
| 14 |
| 15 class Environment; |
| 16 |
| 17 // Overrides the environment variable value for |name| while in scope. The |
| 18 // previous value is restored when this goes out of scope. |
| 19 class ScopedEnvironmentVariable { |
| 20 public: |
| 21 ScopedEnvironmentVariable(const std::string& name, const std::string& value); |
| 22 ~ScopedEnvironmentVariable(); |
| 23 |
| 24 private: |
| 25 std::string name_; |
| 26 bool prev_was_set_; |
| 27 std::string prev_value_; |
| 28 scoped_ptr<base::Environment> environment_; |
| 29 |
| 30 DISALLOW_COPY_AND_ASSIGN(ScopedEnvironmentVariable); |
| 31 }; |
| 32 |
| 33 } // namespace base |
| 34 |
| 35 #endif // BASE_TEST_SCOPED_ENVIRONMENT_VARIABLE_H_ |
OLD | NEW |