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

Side by Side Diff: chrome/browser/chromeos/settings/owner_key_util.h

Issue 10905179: Make OwnerKeyUtil thread safe as originally intended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | « no previous file | no next file » | 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 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_OWNER_KEY_UTIL_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_OWNER_KEY_UTIL_H_
6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_OWNER_KEY_UTIL_H_ 6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_OWNER_KEY_UTIL_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/file_path.h" 13 #include "base/file_path.h"
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 16
17 class FilePath; 17 class FilePath;
18 18
19 namespace crypto { 19 namespace crypto {
20 class RSAPrivateKey; 20 class RSAPrivateKey;
21 } 21 }
22 22
23 namespace chromeos { 23 namespace chromeos {
24 24
25 class OwnerKeyUtilTest; 25 class OwnerKeyUtilTest;
26 26
27 class OwnerKeyUtil : public base::RefCounted<OwnerKeyUtil> { 27 class OwnerKeyUtil : public base::RefCountedThreadSafe<OwnerKeyUtil> {
28 public: 28 public:
29 // Creates an OwnerKeyUtil instance. 29 // Creates an OwnerKeyUtil instance.
30 static OwnerKeyUtil* Create(); 30 static OwnerKeyUtil* Create();
31 31
32 // Attempts to read the public key from the file system. 32 // Attempts to read the public key from the file system.
33 // Upon success, returns true and populates |output|. False on failure. 33 // Upon success, returns true and populates |output|. False on failure.
34 virtual bool ImportPublicKey(std::vector<uint8>* output) = 0; 34 virtual bool ImportPublicKey(std::vector<uint8>* output) = 0;
35 35
36 // Looks for the private key associated with |key| in the default slot, 36 // Looks for the private key associated with |key| in the default slot,
37 // and returns it if it can be found. Returns NULL otherwise. 37 // and returns it if it can be found. Returns NULL otherwise.
38 // Caller takes ownership. 38 // Caller takes ownership.
39 virtual crypto::RSAPrivateKey* FindPrivateKey( 39 virtual crypto::RSAPrivateKey* FindPrivateKey(
40 const std::vector<uint8>& key) = 0; 40 const std::vector<uint8>& key) = 0;
41 41
42 // Checks whether the public key is present in the file system. 42 // Checks whether the public key is present in the file system.
43 virtual bool IsPublicKeyPresent() = 0; 43 virtual bool IsPublicKeyPresent() = 0;
44 44
45 protected: 45 protected:
46 OwnerKeyUtil(); 46 OwnerKeyUtil();
47 virtual ~OwnerKeyUtil(); 47 virtual ~OwnerKeyUtil();
48 48
49 private: 49 private:
50 friend class base::RefCounted<OwnerKeyUtil>; 50 friend class base::RefCountedThreadSafe<OwnerKeyUtil>;
51 51
52 FRIEND_TEST_ALL_PREFIXES(OwnerKeyUtilTest, ExportImportPublicKey); 52 FRIEND_TEST_ALL_PREFIXES(OwnerKeyUtilTest, ExportImportPublicKey);
53 }; 53 };
54 54
55 // Implementation of OwnerKeyUtil that is used in production code. 55 // Implementation of OwnerKeyUtil that is used in production code.
56 class OwnerKeyUtilImpl : public OwnerKeyUtil { 56 class OwnerKeyUtilImpl : public OwnerKeyUtil {
57 public: 57 public:
58 // The file outside the owner's encrypted home directory where her 58 // The file outside the owner's encrypted home directory where her
59 // key will live. 59 // key will live.
60 static const char kOwnerKeyFile[]; 60 static const char kOwnerKeyFile[];
(...skipping 12 matching lines...) Expand all
73 private: 73 private:
74 // The file that holds the public key. 74 // The file that holds the public key.
75 FilePath key_file_; 75 FilePath key_file_;
76 76
77 DISALLOW_COPY_AND_ASSIGN(OwnerKeyUtilImpl); 77 DISALLOW_COPY_AND_ASSIGN(OwnerKeyUtilImpl);
78 }; 78 };
79 79
80 } // namespace chromeos 80 } // namespace chromeos
81 81
82 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_OWNER_KEY_UTIL_H_ 82 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_OWNER_KEY_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698