OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_ENV_VAR_H_ | 5 #ifndef BASE_ENV_VAR_H_ |
6 #define BASE_ENV_VAR_H_ | 6 #define BASE_ENV_VAR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 | 13 |
14 // These are used to derive mocks for unittests. | 14 // These are used to derive mocks for unittests. |
15 class EnvVarGetter { | 15 class EnvVarGetter { |
16 public: | 16 public: |
17 virtual ~EnvVarGetter() {} | 17 virtual ~EnvVarGetter() {} |
18 // Gets an environment variable's value and stores it in |result|. | 18 // Gets an environment variable's value and stores it in |result|. |
19 // Returns false if the key is unset. | 19 // Returns false if the key is unset. |
20 virtual bool GetEnv(const char* variable_name, std::string* result) = 0; | 20 virtual bool GetEnv(const char* variable_name, std::string* result) = 0; |
21 | 21 |
22 // Syntactic sugar for GetEnv(variable_name, NULL); | 22 // Syntactic sugar for GetEnv(variable_name, NULL); |
23 virtual bool HasEnv(const char* variable_name) { | 23 virtual bool HasEnv(const char* variable_name) { |
24 return GetEnv(variable_name, NULL); | 24 return GetEnv(variable_name, NULL); |
25 } | 25 } |
26 | 26 |
| 27 virtual void SetEnv(const char* variable_name, |
| 28 const std::string& new_value) = 0; |
| 29 |
27 // Create an instance of EnvVarGetter | 30 // Create an instance of EnvVarGetter |
28 static EnvVarGetter* Create(); | 31 static EnvVarGetter* Create(); |
29 }; | 32 }; |
30 | 33 |
31 } // namespace base | 34 } // namespace base |
32 | 35 |
33 #endif // BASE_ENV_VAR_H_ | 36 #endif // BASE_ENV_VAR_H_ |
OLD | NEW |