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

Side by Side Diff: components/os_crypt/libsecret_util_posix.h

Issue 1929573002: Changed location of LibsecretLoader (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed memory errors Created 4 years, 7 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 | « components/os_crypt/BUILD.gn ('k') | components/os_crypt/libsecret_util_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 COMPONENTS_OS_CRYPT_LIBSECRET_UTIL_POSIX_H_
6 #define COMPONENTS_OS_CRYPT_LIBSECRET_UTIL_POSIX_H_
7
8 #include <libsecret/secret.h>
9
10 #include <list>
11 #include <string>
12
13 #include "base/macros.h"
14
15 // Utility for dynamically loading libsecret.
16 class LibsecretLoader {
17 public:
18 static decltype(&::secret_password_store_sync) secret_password_store_sync;
19 static decltype(&::secret_service_search_sync) secret_service_search_sync;
20 static decltype(&::secret_password_clear_sync) secret_password_clear_sync;
21 static decltype(&::secret_item_get_secret) secret_item_get_secret;
22 static decltype(&::secret_value_get_text) secret_value_get_text;
23 static decltype(&::secret_item_get_attributes) secret_item_get_attributes;
24 static decltype(&::secret_item_load_secret_sync) secret_item_load_secret_sync;
25 static decltype(&::secret_value_unref) secret_value_unref;
26
27 // Loads the libsecret library and checks that it responds to queries.
28 // Returns false if either step fails.
29 // Repeated calls check the responsiveness every time, but do not load the
30 // the library again if already successful.
31 static bool EnsureLibsecretLoaded();
32
33 protected:
34 static bool libsecret_loaded_;
35
36 private:
37 struct FunctionInfo {
38 const char* name;
39 void** pointer;
40 };
41
42 static const FunctionInfo kFunctions[];
43
44 // Load the libsecret binaries. Returns true on success.
45 // If successful, the result is cached and the function can be safely called
46 // multiple times.
47 // Checking |LibsecretIsAvailable| is necessary after this to verify that the
48 // service responds to queries.
49 static bool LoadLibsecret();
50
51 // True if the libsecret binaries have been loaded and the library responds
52 // to queries.
53 static bool LibsecretIsAvailable();
54
55 DISALLOW_IMPLICIT_CONSTRUCTORS(LibsecretLoader);
56 };
57
58 class LibsecretAttributesBuilder {
59 public:
60 LibsecretAttributesBuilder();
61 ~LibsecretAttributesBuilder();
62
63 void Append(const std::string& name, const std::string& value);
64
65 void Append(const std::string& name, int64_t value);
66
67 // GHashTable, its keys and values returned from Get() are destroyed in
68 // |LibsecretAttributesBuilder| destructor.
69 GHashTable* Get() { return attrs_; }
70
71 private:
72 // |name_values_| is a storage for strings referenced in |attrs_|.
73 std::list<std::string> name_values_;
Lei Zhang 2016/04/29 16:37:26 I thought you were going to switch to a vector.
74 GHashTable* attrs_;
75
76 DISALLOW_COPY_AND_ASSIGN(LibsecretAttributesBuilder);
77 };
78
79 #endif // COMPONENTS_OS_CRYPT_LIBSECRET_UTIL_POSIX_H_
OLDNEW
« no previous file with comments | « components/os_crypt/BUILD.gn ('k') | components/os_crypt/libsecret_util_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698