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

Side by Side Diff: service.h

Issue 6801020: service,cryptohome: wire up lockbox to dbus (Closed)
Patch Set: fix spaces 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
« no previous file with comments | « interface.cc ('k') | service.cc » ('j') | service.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009 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 "mount.h" 18 #include "mount.h"
19 #include "mount_task.h" 19 #include "mount_task.h"
20 #include "lockbox.h"
gauravsh 2011/04/11 04:03:20 nit: alpha
20 #include "tpm_init.h" 21 #include "tpm_init.h"
21 22
22 namespace cryptohome { 23 namespace cryptohome {
23 namespace gobject { 24 namespace gobject {
24 25
25 struct Cryptohome; 26 struct Cryptohome;
26 } // namespace gobject 27 } // namespace gobject
27 28
28 // Service 29 // Service
29 // Provides a wrapper for exporting CryptohomeInterface to 30 // Provides a wrapper for exporting CryptohomeInterface to
30 // D-Bus and entering the glib run loop. 31 // D-Bus and entering the glib run loop.
31 // 32 //
32 // ::g_type_init() must be called before this class is used. 33 // ::g_type_init() must be called before this class is used.
33 class Service : public chromeos::dbus::AbstractDbusService, 34 class Service : public chromeos::dbus::AbstractDbusService,
34 public MountTaskObserver, 35 public MountTaskObserver,
35 public CryptohomeEventSourceSink, 36 public CryptohomeEventSourceSink,
36 public TpmInit::TpmInitCallback { 37 public TpmInit::TpmInitCallback {
37 public: 38 public:
38 Service(); 39 Service();
39 virtual ~Service(); 40 virtual ~Service();
40 41
41 // From chromeos::dbus::AbstractDbusService 42 // From chromeos::dbus::AbstractDbusService
42 // Setup the wrapped GObject and the GMainLoop 43 // Setup the wrapped GObject and the GMainLoop
43 virtual bool Initialize(); 44 virtual bool Initialize();
44 virtual bool SeedUrandom(); 45 virtual bool SeedUrandom();
46 virtual void InitializeLockbox();
45 virtual bool Reset(); 47 virtual bool Reset();
46 48
47 // Used internally during registration to set the 49 // Used internally during registration to set the
48 // proper service information. 50 // proper service information.
49 virtual const char *service_name() const { 51 virtual const char *service_name() const {
50 return kCryptohomeServiceName; 52 return kCryptohomeServiceName;
51 } 53 }
52 virtual const char *service_path() const { 54 virtual const char *service_path() const {
53 return kCryptohomeServicePath; 55 return kCryptohomeServicePath;
54 } 56 }
55 virtual const char *service_interface() const { 57 virtual const char *service_interface() const {
56 return kCryptohomeInterface; 58 return kCryptohomeInterface;
57 } 59 }
58 virtual GObject* service_object() const { 60 virtual GObject* service_object() const {
59 return G_OBJECT(cryptohome_); 61 return G_OBJECT(cryptohome_);
60 } 62 }
61 virtual void set_mount(Mount* mount) { 63 virtual void set_mount(Mount* mount) {
62 mount_ = mount; 64 mount_ = mount;
63 } 65 }
64 virtual void set_tpm_init(TpmInit* tpm_init) { 66 virtual void set_tpm_init(TpmInit* tpm_init) {
65 tpm_init_ = tpm_init; 67 tpm_init_ = tpm_init;
66 } 68 }
67 virtual void set_initialize_tpm(bool value) { 69 virtual void set_initialize_tpm(bool value) {
68 initialize_tpm_ = value; 70 initialize_tpm_ = value;
69 } 71 }
70 virtual void set_auto_cleanup_period(int value) { 72 virtual void set_auto_cleanup_period(int value) {
71 auto_cleanup_period_ = value; 73 auto_cleanup_period_ = value;
72 } 74 }
73 75 virtual void set_lockbox(Lockbox* lockbox) {
76 lockbox_ = lockbox;
77 }
74 78
75 // MountTaskObserver 79 // MountTaskObserver
76 virtual void MountTaskObserve(const MountTaskResult& result); 80 virtual void MountTaskObserve(const MountTaskResult& result);
77 81
78 // CryptohomeEventSourceSink 82 // CryptohomeEventSourceSink
79 virtual void NotifyEvent(CryptohomeEventBase* event); 83 virtual void NotifyEvent(CryptohomeEventBase* event);
80 84
81 // TpmInitCallback 85 // TpmInitCallback
82 virtual void InitializeTpmComplete(bool status, bool took_ownership); 86 virtual void InitializeTpmComplete(bool status, bool took_ownership);
83 87
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 146
143 virtual gboolean TpmIsReady(gboolean* OUT_ready, GError** error); 147 virtual gboolean TpmIsReady(gboolean* OUT_ready, GError** error);
144 virtual gboolean TpmIsEnabled(gboolean* OUT_enabled, GError** error); 148 virtual gboolean TpmIsEnabled(gboolean* OUT_enabled, GError** error);
145 virtual gboolean TpmGetPassword(gchar** OUT_password, GError** error); 149 virtual gboolean TpmGetPassword(gchar** OUT_password, GError** error);
146 virtual gboolean TpmIsOwned(gboolean* OUT_owned, GError** error); 150 virtual gboolean TpmIsOwned(gboolean* OUT_owned, GError** error);
147 virtual gboolean TpmIsBeingOwned(gboolean* OUT_owning, GError** error); 151 virtual gboolean TpmIsBeingOwned(gboolean* OUT_owning, GError** error);
148 virtual gboolean TpmCanAttemptOwnership(GError** error); 152 virtual gboolean TpmCanAttemptOwnership(GError** error);
149 virtual gboolean TpmClearStoredPassword(GError** error); 153 virtual gboolean TpmClearStoredPassword(GError** error);
150 virtual gboolean GetStatusString(gchar** OUT_status, GError** error); 154 virtual gboolean GetStatusString(gchar** OUT_status, GError** error);
151 155
156 // Lockbox methods
157 virtual gboolean LockboxGet(gchar* name,
158 GArray** OUT_value,
159 gboolean* OUT_successful,
160 GError** error);
161 virtual gboolean LockboxSet(gchar* name,
162 GArray* value,
163 gboolean* OUT_successful,
164 GError** error);
165 virtual gboolean LockboxLock(gboolean* OUT_locked, GError** error);
166 virtual gboolean LockboxCount(gint* OUT_count, GError** error);
167 virtual gboolean LockboxIsReady(gboolean* OUT_ready, GError** error);
168 virtual gboolean LockboxIsLocked(gboolean* OUT_locked, GError** error);
169 virtual gboolean LockboxIsSecure(gboolean* OUT_secure, GError** error);
170 virtual gboolean LockboxIsTampered(gboolean* OUT_tampered, GError** error);
171 virtual gboolean LockboxIsLegacy(gboolean* OUT_legacy, GError** error);
172
152 protected: 173 protected:
153 virtual GMainLoop *main_loop() { return loop_; } 174 virtual GMainLoop *main_loop() { return loop_; }
154 175
155 // Called periodically on Mount thread to initiate automatic disk 176 // Called periodically on Mount thread to initiate automatic disk
156 // cleanup if needed. 177 // cleanup if needed.
157 virtual void AutoCleanupCallback(); 178 virtual void AutoCleanupCallback();
158 179
159 private: 180 private:
160 GMainLoop *loop_; 181 GMainLoop *loop_;
161 // Can't use scoped_ptr for cryptohome_ because memory is allocated by glib. 182 // Can't use scoped_ptr for cryptohome_ because memory is allocated by glib.
162 gobject::Cryptohome *cryptohome_; 183 gobject::Cryptohome *cryptohome_;
163 chromeos::Blob system_salt_; 184 chromeos::Blob system_salt_;
164 scoped_ptr<cryptohome::Mount> default_mount_; 185 scoped_ptr<cryptohome::Mount> default_mount_;
165 cryptohome::Mount* mount_; 186 cryptohome::Mount* mount_;
166 scoped_ptr<TpmInit> default_tpm_init_; 187 scoped_ptr<TpmInit> default_tpm_init_;
167 TpmInit *tpm_init_; 188 TpmInit *tpm_init_;
168 bool initialize_tpm_; 189 bool initialize_tpm_;
169 base::Thread mount_thread_; 190 base::Thread mount_thread_;
170 guint async_complete_signal_; 191 guint async_complete_signal_;
171 guint tpm_init_signal_; 192 guint tpm_init_signal_;
172 CryptohomeEventSource event_source_; 193 CryptohomeEventSource event_source_;
173 int auto_cleanup_period_; 194 int auto_cleanup_period_;
195 scoped_ptr<cryptohome::Lockbox> default_lockbox_;
196 cryptohome::Lockbox *lockbox_;
gauravsh 2011/04/11 04:03:20 nit: * next to the type.
174 197
175 DISALLOW_COPY_AND_ASSIGN(Service); 198 DISALLOW_COPY_AND_ASSIGN(Service);
176 }; 199 };
177 200
178 } // namespace cryptohome 201 } // namespace cryptohome
179 202
180 #endif // CRYPTOHOME_SERVICE_H_ 203 #endif // CRYPTOHOME_SERVICE_H_
OLDNEW
« no previous file with comments | « interface.cc ('k') | service.cc » ('j') | service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698