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

Side by Side Diff: service.h

Issue 6801020: service,cryptohome: wire up lockbox to dbus (Closed)
Patch Set: auto-Finalization on Mount Created 9 years, 8 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
« cryptohome.xml ('K') | « interface.cc ('k') | service.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 OS Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium OS 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 #ifndef CRYPTOHOME_SERVICE_H_ 4 #ifndef CRYPTOHOME_SERVICE_H_
5 #define CRYPTOHOME_SERVICE_H_ 5 #define CRYPTOHOME_SERVICE_H_
6 6
7 #include <base/logging.h> 7 #include <base/logging.h>
8 #include <base/scoped_ptr.h> 8 #include <base/scoped_ptr.h>
9 #include <base/thread.h> 9 #include <base/thread.h>
10 #include <chromeos/dbus/abstract_dbus_service.h> 10 #include <chromeos/dbus/abstract_dbus_service.h>
11 #include <chromeos/dbus/dbus.h> 11 #include <chromeos/dbus/dbus.h>
12 #include <chromeos/dbus/service_constants.h> 12 #include <chromeos/dbus/service_constants.h>
13 #include <chromeos/glib/object.h> 13 #include <chromeos/glib/object.h>
14 #include <dbus/dbus-glib.h> 14 #include <dbus/dbus-glib.h>
15 #include <glib-object.h> 15 #include <glib-object.h>
16 16
17 #include "cryptohome_event_source.h" 17 #include "cryptohome_event_source.h"
18 #include "install_attributes.h"
18 #include "mount.h" 19 #include "mount.h"
19 #include "mount_task.h" 20 #include "mount_task.h"
20 #include "pkcs11_init.h" 21 #include "pkcs11_init.h"
21 #include "tpm_init.h" 22 #include "tpm_init.h"
22 23
23 namespace cryptohome { 24 namespace cryptohome {
24 namespace gobject { 25 namespace gobject {
25 26
26 struct Cryptohome; 27 struct Cryptohome;
27 } // namespace gobject 28 } // namespace gobject
28 29
29 // Service 30 // Service
30 // Provides a wrapper for exporting CryptohomeInterface to 31 // Provides a wrapper for exporting CryptohomeInterface to
31 // D-Bus and entering the glib run loop. 32 // D-Bus and entering the glib run loop.
32 // 33 //
33 // ::g_type_init() must be called before this class is used. 34 // ::g_type_init() must be called before this class is used.
34 class Service : public chromeos::dbus::AbstractDbusService, 35 class Service : public chromeos::dbus::AbstractDbusService,
35 public MountTaskObserver, 36 public MountTaskObserver,
36 public CryptohomeEventSourceSink, 37 public CryptohomeEventSourceSink,
37 public TpmInit::TpmInitCallback { 38 public TpmInit::TpmInitCallback {
38 public: 39 public:
39 Service(); 40 Service();
40 virtual ~Service(); 41 virtual ~Service();
41 42
42 // From chromeos::dbus::AbstractDbusService 43 // From chromeos::dbus::AbstractDbusService
43 // Setup the wrapped GObject and the GMainLoop 44 // Setup the wrapped GObject and the GMainLoop
44 virtual bool Initialize(); 45 virtual bool Initialize();
45 virtual bool SeedUrandom(); 46 virtual bool SeedUrandom();
47 virtual void InitializeInstallAttributes(bool first_time);
46 virtual bool Reset(); 48 virtual bool Reset();
47 49
48 // Used internally during registration to set the 50 // Used internally during registration to set the
49 // proper service information. 51 // proper service information.
50 virtual const char *service_name() const { 52 virtual const char *service_name() const {
51 return kCryptohomeServiceName; 53 return kCryptohomeServiceName;
52 } 54 }
53 virtual const char *service_path() const { 55 virtual const char *service_path() const {
54 return kCryptohomeServicePath; 56 return kCryptohomeServicePath;
55 } 57 }
56 virtual const char *service_interface() const { 58 virtual const char *service_interface() const {
57 return kCryptohomeInterface; 59 return kCryptohomeInterface;
58 } 60 }
59 virtual GObject* service_object() const { 61 virtual GObject* service_object() const {
60 return G_OBJECT(cryptohome_); 62 return G_OBJECT(cryptohome_);
61 } 63 }
62 virtual void set_mount(Mount* mount) { 64 virtual void set_mount(Mount* mount) {
63 mount_ = mount; 65 mount_ = mount;
64 } 66 }
65 virtual void set_tpm_init(TpmInit* tpm_init) { 67 virtual void set_tpm_init(TpmInit* tpm_init) {
66 tpm_init_ = tpm_init; 68 tpm_init_ = tpm_init;
67 } 69 }
68 virtual void set_initialize_tpm(bool value) { 70 virtual void set_initialize_tpm(bool value) {
69 initialize_tpm_ = value; 71 initialize_tpm_ = value;
70 } 72 }
71 virtual void set_auto_cleanup_period(int value) { 73 virtual void set_auto_cleanup_period(int value) {
72 auto_cleanup_period_ = value; 74 auto_cleanup_period_ = value;
73 } 75 }
76 virtual void set_install_attrs(InstallAttributes* install_attrs) {
77 install_attrs_ = install_attrs;
78 }
74 virtual void set_update_user_activity_period(int value) { 79 virtual void set_update_user_activity_period(int value) {
75 update_user_activity_period_ = value; 80 update_user_activity_period_ = value;
76 } 81 }
77 82
78 // MountTaskObserver 83 // MountTaskObserver
79 virtual void MountTaskObserve(const MountTaskResult& result); 84 virtual void MountTaskObserve(const MountTaskResult& result);
80 85
81 // CryptohomeEventSourceSink 86 // CryptohomeEventSourceSink
82 virtual void NotifyEvent(CryptohomeEventBase* event); 87 virtual void NotifyEvent(CryptohomeEventBase* event);
83 88
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 158
154 // Returns the label of the TPM token along with its user PIN. 159 // Returns the label of the TPM token along with its user PIN.
155 virtual gboolean Pkcs11GetTpmTokenInfo(gchar** OUT_label, 160 virtual gboolean Pkcs11GetTpmTokenInfo(gchar** OUT_label,
156 gchar** OUT_user_pin, 161 gchar** OUT_user_pin,
157 GError** error); 162 GError** error);
158 163
159 // Returns in |OUT_ready| whether the TPM token is ready for use. 164 // Returns in |OUT_ready| whether the TPM token is ready for use.
160 virtual gboolean Pkcs11IsTpmTokenReady(gboolean* OUT_ready, GError** error); 165 virtual gboolean Pkcs11IsTpmTokenReady(gboolean* OUT_ready, GError** error);
161 virtual gboolean GetStatusString(gchar** OUT_status, GError** error); 166 virtual gboolean GetStatusString(gchar** OUT_status, GError** error);
162 167
168 // InstallAttributes methods
169 virtual gboolean InstallAttributesGet(gchar* name,
170 GArray** OUT_value,
171 gboolean* OUT_successful,
172 GError** error);
173 virtual gboolean InstallAttributesSet(gchar* name,
174 GArray* value,
175 gboolean* OUT_successful,
176 GError** error);
177 virtual gboolean InstallAttributesFinalize(gboolean* OUT_finalized,
178 GError** error);
179 virtual gboolean InstallAttributesCount(gint* OUT_count, GError** error);
180 virtual gboolean InstallAttributesIsReady(gboolean* OUT_ready,
181 GError** error);
182 virtual gboolean InstallAttributesIsSecure(gboolean* OUT_secure,
183 GError** error);
184 virtual gboolean InstallAttributesIsInvalid(gboolean* OUT_invalid,
185 GError** error);
186 virtual gboolean InstallAttributesIsFirstInstall(gboolean* OUT_first_install,
187 GError** error);
188
163 protected: 189 protected:
164 virtual GMainLoop *main_loop() { return loop_; } 190 virtual GMainLoop *main_loop() { return loop_; }
165 191
166 // Called periodically on Mount thread to initiate automatic disk 192 // Called periodically on Mount thread to initiate automatic disk
167 // cleanup if needed. 193 // cleanup if needed.
168 virtual void AutoCleanupCallback(); 194 virtual void AutoCleanupCallback();
169 195
170 private: 196 private:
171 GMainLoop *loop_; 197 GMainLoop *loop_;
172 // Can't use scoped_ptr for cryptohome_ because memory is allocated by glib. 198 // Can't use scoped_ptr for cryptohome_ because memory is allocated by glib.
173 gobject::Cryptohome *cryptohome_; 199 gobject::Cryptohome *cryptohome_;
174 chromeos::Blob system_salt_; 200 chromeos::Blob system_salt_;
175 scoped_ptr<cryptohome::Mount> default_mount_; 201 scoped_ptr<cryptohome::Mount> default_mount_;
176 cryptohome::Mount* mount_; 202 cryptohome::Mount* mount_;
177 scoped_ptr<TpmInit> default_tpm_init_; 203 scoped_ptr<TpmInit> default_tpm_init_;
178 TpmInit *tpm_init_; 204 TpmInit *tpm_init_;
179 scoped_ptr<Pkcs11Init> default_pkcs11_init_; 205 scoped_ptr<Pkcs11Init> default_pkcs11_init_;
180 Pkcs11Init *pkcs11_init_; 206 Pkcs11Init *pkcs11_init_;
181 bool initialize_tpm_; 207 bool initialize_tpm_;
182 base::Thread mount_thread_; 208 base::Thread mount_thread_;
183 guint async_complete_signal_; 209 guint async_complete_signal_;
184 guint tpm_init_signal_; 210 guint tpm_init_signal_;
185 CryptohomeEventSource event_source_; 211 CryptohomeEventSource event_source_;
186 int auto_cleanup_period_; 212 int auto_cleanup_period_;
213 scoped_ptr<cryptohome::InstallAttributes> default_install_attrs_;
214 cryptohome::InstallAttributes *install_attrs_;
gauravsh 2011/04/14 07:39:52 nit: * next to type
Will Drewry 2011/04/15 01:31:49 Done, and fixed up all the other ones.
187 int update_user_activity_period_; 215 int update_user_activity_period_;
188 216
189 DISALLOW_COPY_AND_ASSIGN(Service); 217 DISALLOW_COPY_AND_ASSIGN(Service);
190 }; 218 };
191 219
192 } // namespace cryptohome 220 } // namespace cryptohome
193 221
194 #endif // CRYPTOHOME_SERVICE_H_ 222 #endif // CRYPTOHOME_SERVICE_H_
OLDNEW
« cryptohome.xml ('K') | « interface.cc ('k') | service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698