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

Side by Side Diff: base/environment.cc

Issue 611153004: replace OVERRIDE and FINAL with override and final in base/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CC_ -> BASE_ Created 6 years, 2 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
« no previous file with comments | « base/deferred_sequenced_task_runner.h ('k') | base/file_version_info_mac.h » ('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) 2012 The Chromium Authors. All rights reserved. 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 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 #include "base/environment.h" 5 #include "base/environment.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/strings/string_piece.h" 9 #include "base/strings/string_piece.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 12
13 #if defined(OS_POSIX) 13 #if defined(OS_POSIX)
14 #include <stdlib.h> 14 #include <stdlib.h>
15 #elif defined(OS_WIN) 15 #elif defined(OS_WIN)
16 #include <windows.h> 16 #include <windows.h>
17 #endif 17 #endif
18 18
19 namespace base { 19 namespace base {
20 20
21 namespace { 21 namespace {
22 22
23 class EnvironmentImpl : public base::Environment { 23 class EnvironmentImpl : public base::Environment {
24 public: 24 public:
25 virtual bool GetVar(const char* variable_name, 25 virtual bool GetVar(const char* variable_name,
26 std::string* result) OVERRIDE { 26 std::string* result) override {
27 if (GetVarImpl(variable_name, result)) 27 if (GetVarImpl(variable_name, result))
28 return true; 28 return true;
29 29
30 // Some commonly used variable names are uppercase while others 30 // Some commonly used variable names are uppercase while others
31 // are lowercase, which is inconsistent. Let's try to be helpful 31 // are lowercase, which is inconsistent. Let's try to be helpful
32 // and look for a variable name with the reverse case. 32 // and look for a variable name with the reverse case.
33 // I.e. HTTP_PROXY may be http_proxy for some users/systems. 33 // I.e. HTTP_PROXY may be http_proxy for some users/systems.
34 char first_char = variable_name[0]; 34 char first_char = variable_name[0];
35 std::string alternate_case_var; 35 std::string alternate_case_var;
36 if (first_char >= 'a' && first_char <= 'z') 36 if (first_char >= 'a' && first_char <= 'z')
37 alternate_case_var = StringToUpperASCII(std::string(variable_name)); 37 alternate_case_var = StringToUpperASCII(std::string(variable_name));
38 else if (first_char >= 'A' && first_char <= 'Z') 38 else if (first_char >= 'A' && first_char <= 'Z')
39 alternate_case_var = base::StringToLowerASCII(std::string(variable_name)); 39 alternate_case_var = base::StringToLowerASCII(std::string(variable_name));
40 else 40 else
41 return false; 41 return false;
42 return GetVarImpl(alternate_case_var.c_str(), result); 42 return GetVarImpl(alternate_case_var.c_str(), result);
43 } 43 }
44 44
45 virtual bool SetVar(const char* variable_name, 45 virtual bool SetVar(const char* variable_name,
46 const std::string& new_value) OVERRIDE { 46 const std::string& new_value) override {
47 return SetVarImpl(variable_name, new_value); 47 return SetVarImpl(variable_name, new_value);
48 } 48 }
49 49
50 virtual bool UnSetVar(const char* variable_name) OVERRIDE { 50 virtual bool UnSetVar(const char* variable_name) override {
51 return UnSetVarImpl(variable_name); 51 return UnSetVarImpl(variable_name);
52 } 52 }
53 53
54 private: 54 private:
55 bool GetVarImpl(const char* variable_name, std::string* result) { 55 bool GetVarImpl(const char* variable_name, std::string* result) {
56 #if defined(OS_POSIX) 56 #if defined(OS_POSIX)
57 const char* env_value = getenv(variable_name); 57 const char* env_value = getenv(variable_name);
58 if (!env_value) 58 if (!env_value)
59 return false; 59 return false;
60 // Note that the variable may be defined but empty. 60 // Note that the variable may be defined but empty.
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 for (size_t i = 0; i < result_indices.size(); i++) 228 for (size_t i = 0; i < result_indices.size(); i++)
229 result[i] = &storage_data[result_indices[i]]; 229 result[i] = &storage_data[result_indices[i]];
230 result[result_indices.size()] = 0; // Null terminator. 230 result[result_indices.size()] = 0; // Null terminator.
231 231
232 return result.Pass(); 232 return result.Pass();
233 } 233 }
234 234
235 #endif // OS_POSIX 235 #endif // OS_POSIX
236 236
237 } // namespace base 237 } // namespace base
OLDNEW
« no previous file with comments | « base/deferred_sequenced_task_runner.h ('k') | base/file_version_info_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698