[M85 Dev][EFL] Fix crashes at webview launch
[platform/framework/web/chromium-efl.git] / base / environment.h
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
3 // found in the LICENSE file.
4
5 #ifndef BASE_ENVIRONMENT_H_
6 #define BASE_ENVIRONMENT_H_
7
8 #include <map>
9 #include <memory>
10 #include <string>
11
12 #include "base/base_export.h"
13 #include "base/strings/string16.h"
14 #include "base/strings/string_piece.h"
15 #include "build/build_config.h"
16
17 namespace base {
18
19 namespace env_vars {
20
21 #if defined(OS_POSIX) || defined(OS_FUCHSIA)
22 BASE_EXPORT extern const char kHome[];
23 #endif
24
25 }  // namespace env_vars
26
27 class BASE_EXPORT Environment {
28  public:
29   virtual ~Environment();
30
31   // Returns the appropriate platform-specific instance.
32   static std::unique_ptr<Environment> Create();
33
34   // Gets an environment variable's value and stores it in |result|.
35   // Returns false if the key is unset.
36   virtual bool GetVar(StringPiece variable_name, std::string* result) = 0;
37
38   // Syntactic sugar for GetVar(variable_name, nullptr);
39   virtual bool HasVar(StringPiece variable_name);
40
41   // Returns true on success, otherwise returns false. This method should not
42   // be called in a multi-threaded process.
43   virtual bool SetVar(StringPiece variable_name,
44                       const std::string& new_value) = 0;
45
46   // Returns true on success, otherwise returns false. This method should not
47   // be called in a multi-threaded process.
48   virtual bool UnSetVar(StringPiece variable_name) = 0;
49 };
50
51 #if defined(OS_WIN)
52 using NativeEnvironmentString = std::wstring;
53 #elif defined(OS_POSIX) || defined(OS_FUCHSIA)
54 using NativeEnvironmentString = std::string;
55 #endif
56 using EnvironmentMap =
57     std::map<NativeEnvironmentString, NativeEnvironmentString>;
58
59 }  // namespace base
60
61 #endif  // BASE_ENVIRONMENT_H_