| OLD | NEW |
| 1 // Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009-2010 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 | 4 |
| 5 #ifndef LOGIN_MANAGER_SESSION_MANAGER_SERVICE_H_ | 5 #ifndef LOGIN_MANAGER_SESSION_MANAGER_SERVICE_H_ |
| 6 #define LOGIN_MANAGER_SESSION_MANAGER_SERVICE_H_ | 6 #define LOGIN_MANAGER_SESSION_MANAGER_SERVICE_H_ |
| 7 | 7 |
| 8 #include <dbus/dbus.h> | 8 #include <dbus/dbus.h> |
| 9 #include <errno.h> | 9 #include <errno.h> |
| 10 #include <glib.h> | 10 #include <glib.h> |
| 11 #include <gtest/gtest.h> | 11 #include <gtest/gtest.h> |
| 12 #include <signal.h> | 12 #include <signal.h> |
| 13 #include <unistd.h> | 13 #include <unistd.h> |
| 14 | 14 |
| 15 #include <string> | 15 #include <string> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include <base/basictypes.h> | 18 #include <base/basictypes.h> |
| 19 #include <base/ref_counted.h> | 19 #include <base/ref_counted.h> |
| 20 #include <base/scoped_ptr.h> | 20 #include <base/scoped_ptr.h> |
| 21 #include <base/thread.h> | 21 #include <base/thread.h> |
| 22 #include <base/waitable_event.h> |
| 22 #include <chromeos/dbus/abstract_dbus_service.h> | 23 #include <chromeos/dbus/abstract_dbus_service.h> |
| 23 #include <chromeos/dbus/dbus.h> | 24 #include <chromeos/dbus/dbus.h> |
| 24 #include <chromeos/dbus/service_constants.h> | 25 #include <chromeos/dbus/service_constants.h> |
| 25 | 26 |
| 26 #include "login_manager/child_job.h" | 27 #include "login_manager/child_job.h" |
| 27 #include "login_manager/file_checker.h" | 28 #include "login_manager/file_checker.h" |
| 28 #include "login_manager/owner_key.h" | 29 #include "login_manager/owner_key.h" |
| 29 #include "login_manager/owner_key_loss_mitigator.h" | 30 #include "login_manager/owner_key_loss_mitigator.h" |
| 30 #include "login_manager/pref_store.h" | 31 #include "login_manager/pref_store.h" |
| 31 #include "login_manager/system_utils.h" | 32 #include "login_manager/system_utils.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 48 // D-Bus and entering the glib run loop. | 49 // D-Bus and entering the glib run loop. |
| 49 // | 50 // |
| 50 // ::g_type_init() must be called before this class is used. | 51 // ::g_type_init() must be called before this class is used. |
| 51 // | 52 // |
| 52 // All signatures used in the methods of the ownership API are | 53 // All signatures used in the methods of the ownership API are |
| 53 // SHA1 with RSA encryption. | 54 // SHA1 with RSA encryption. |
| 54 class SessionManagerService | 55 class SessionManagerService |
| 55 : public base::RefCountedThreadSafe<SessionManagerService>, | 56 : public base::RefCountedThreadSafe<SessionManagerService>, |
| 56 public chromeos::dbus::AbstractDbusService { | 57 public chromeos::dbus::AbstractDbusService { |
| 57 public: | 58 public: |
| 58 struct PersistKeyData { | |
| 59 public: | |
| 60 PersistKeyData(SystemUtils* utils, OwnerKey* key) | |
| 61 : signaler(utils), | |
| 62 to_persist(key) { | |
| 63 } | |
| 64 ~PersistKeyData() {} | |
| 65 SystemUtils* signaler; | |
| 66 OwnerKey* to_persist; | |
| 67 }; | |
| 68 | |
| 69 struct PersistStoreData { | |
| 70 public: | |
| 71 PersistStoreData(SystemUtils* utils, PrefStore* store) | |
| 72 : signaler(utils), | |
| 73 to_persist(store) { | |
| 74 } | |
| 75 ~PersistStoreData() {} | |
| 76 SystemUtils* signaler; | |
| 77 PrefStore* to_persist; | |
| 78 }; | |
| 79 | 59 |
| 80 SessionManagerService(std::vector<ChildJobInterface*> child_jobs); | 60 SessionManagerService(std::vector<ChildJobInterface*> child_jobs); |
| 81 virtual ~SessionManagerService(); | 61 virtual ~SessionManagerService(); |
| 82 | 62 |
| 83 // If you want to call any of these setters, you should do so before calling | 63 // If you want to call any of these setters, you should do so before calling |
| 84 // any other methods on this class. | 64 // any other methods on this class. |
| 85 class TestApi { | 65 class TestApi { |
| 86 public: | 66 public: |
| 87 // Allows a test program to set the pid of a child. | 67 // Allows a test program to set the pid of a child. |
| 88 void set_child_pid(int i_child, int pid) { | 68 void set_child_pid(int i_child, int pid) { |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 void PersistKey(); | 444 void PersistKey(); |
| 465 | 445 |
| 466 // |store_| is persisted to disk, and then posts a task to |message_loop_| | 446 // |store_| is persisted to disk, and then posts a task to |message_loop_| |
| 467 // to signal Chromium when done. | 447 // to signal Chromium when done. |
| 468 void PersistWhitelist(); | 448 void PersistWhitelist(); |
| 469 | 449 |
| 470 // |store_| is persisted to disk, and then posts a task to |message_loop_| | 450 // |store_| is persisted to disk, and then posts a task to |message_loop_| |
| 471 // to signal Chromium when done. | 451 // to signal Chromium when done. |
| 472 void PersistStore(); | 452 void PersistStore(); |
| 473 | 453 |
| 454 // |store_| is persisted to disk, and |event| is signaled when done. This |
| 455 // is used to provide synchronous, threadsafe persisting. |
| 456 void PersistStoreSync(base::WaitableEvent* event); |
| 457 |
| 474 void StartKeyGeneration(); | 458 void StartKeyGeneration(); |
| 475 | 459 |
| 476 // Uses |system_| to send |signal_name| to Chromium. Attaches a payload | 460 // Uses |system_| to send |signal_name| to Chromium. Attaches a payload |
| 477 // to the signal indicating the status of |succeeded|. | 461 // to the signal indicating the status of |succeeded|. |
| 478 void SendSignal(const char signal_name[], bool succeeded); | 462 void SendSignal(const char signal_name[], bool succeeded); |
| 479 | 463 |
| 480 bool ShouldRunChildren(); | 464 bool ShouldRunChildren(); |
| 481 // Returns true if |child_job| believes it should be stopped. | 465 // Returns true if |child_job| believes it should be stopped. |
| 482 // If the child believes it should be stopped (as opposed to not run anymore) | 466 // If the child believes it should be stopped (as opposed to not run anymore) |
| 483 // we actually exit the Service as well. | 467 // we actually exit the Service as well. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 | 511 |
| 528 bool shutting_down_; | 512 bool shutting_down_; |
| 529 bool shutdown_already_; | 513 bool shutdown_already_; |
| 530 | 514 |
| 531 friend class TestAPI; | 515 friend class TestAPI; |
| 532 DISALLOW_COPY_AND_ASSIGN(SessionManagerService); | 516 DISALLOW_COPY_AND_ASSIGN(SessionManagerService); |
| 533 }; | 517 }; |
| 534 } // namespace login_manager | 518 } // namespace login_manager |
| 535 | 519 |
| 536 #endif // LOGIN_MANAGER_SESSION_MANAGER_SERVICE_H_ | 520 #endif // LOGIN_MANAGER_SESSION_MANAGER_SERVICE_H_ |
| OLD | NEW |