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

Side by Side Diff: base/environment.h

Issue 22750002: Move AlterEnvironment to base/environment.h, implement on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win Created 7 years, 3 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/base.gypi ('k') | base/environment.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_ENVIRONMENT_H_ 5 #ifndef BASE_ENVIRONMENT_H_
6 #define BASE_ENVIRONMENT_H_ 6 #define BASE_ENVIRONMENT_H_
7 7
8 #include <map>
8 #include <string> 9 #include <string>
9 10
10 #include "base/base_export.h" 11 #include "base/base_export.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/strings/string16.h"
11 #include "build/build_config.h" 14 #include "build/build_config.h"
12 15
13 namespace base { 16 namespace base {
14 17
15 namespace env_vars { 18 namespace env_vars {
16 19
17 #if defined(OS_POSIX) 20 #if defined(OS_POSIX)
18 BASE_EXPORT extern const char kHome[]; 21 BASE_EXPORT extern const char kHome[];
19 #endif 22 #endif
20 23
(...skipping 15 matching lines...) Expand all
36 virtual bool HasVar(const char* variable_name); 39 virtual bool HasVar(const char* variable_name);
37 40
38 // Returns true on success, otherwise returns false. 41 // Returns true on success, otherwise returns false.
39 virtual bool SetVar(const char* variable_name, 42 virtual bool SetVar(const char* variable_name,
40 const std::string& new_value) = 0; 43 const std::string& new_value) = 0;
41 44
42 // Returns true on success, otherwise returns false. 45 // Returns true on success, otherwise returns false.
43 virtual bool UnSetVar(const char* variable_name) = 0; 46 virtual bool UnSetVar(const char* variable_name) = 0;
44 }; 47 };
45 48
49
50 #if defined(OS_WIN)
51
52 typedef string16 NativeEnvironmentString;
53 typedef std::map<NativeEnvironmentString, NativeEnvironmentString>
54 EnvironmentMap;
55
56 // Returns a modified environment vector constructed from the given environment
57 // and the list of changes given in |changes|. Each key in the environment is
58 // matched against the first element of the pairs. In the event of a match, the
59 // value is replaced by the second of the pair, unless the second is empty, in
60 // which case the key-value is removed.
61 //
62 // This Windows version takes and returns a Windows-style environment block
63 // which is a concatenated list of null-terminated 16-bit strings. The end is
64 // marked by a double-null terminator. The size of the returned string will
65 // include the terminators.
66 BASE_EXPORT string16 AlterEnvironment(const wchar_t* env,
67 const EnvironmentMap& changes);
68
69 #elif defined(OS_POSIX)
70
71 typedef std::string NativeEnvironmentString;
72 typedef std::map<NativeEnvironmentString, NativeEnvironmentString>
73 EnvironmentMap;
74
75 // See general comments for the Windows version above.
76 //
77 // This Posix version takes and returns a Posix-style environment block, which
78 // is a null-terminated list of pointers to null-terminated strings. The
79 // returned array will have appended to it the storage for the array itself so
80 // there is only one pointer to manage, but this means that you can't copy the
81 // array without keeping the original around.
82 BASE_EXPORT scoped_ptr<char*[]> AlterEnvironment(
83 const char* const* env,
84 const EnvironmentMap& changes);
85
86 #endif
87
46 } // namespace base 88 } // namespace base
47 89
48 #endif // BASE_ENVIRONMENT_H_ 90 #endif // BASE_ENVIRONMENT_H_
OLDNEW
« no previous file with comments | « base/base.gypi ('k') | base/environment.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698