Chromium Code Reviews| Index: chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h |
| diff --git a/chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h b/chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h |
| index 8f47b4d968582b8e0ed8a6a907ea2cc25d325ddf..70d56add98eee9d07889f84126c01a07990762d5 100644 |
| --- a/chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h |
| +++ b/chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h |
| @@ -5,12 +5,14 @@ |
| #ifndef CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_CHROMEOS_H_ |
| #define CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_CHROMEOS_H_ |
| -#include <deque> |
| +#include <queue> |
| +#include <utility> |
| #include <vector> |
| #include "base/callback_forward.h" |
| -#include "base/compiler_specific.h" |
| #include "base/macros.h" |
| +#include "base/memory/linked_ptr.h" |
| +#include "base/observer_list.h" |
| #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| #include "chromeos/dbus/session_manager_client.h" |
| #include "components/keyed_service/core/keyed_service.h" |
| @@ -27,8 +29,6 @@ class OwnerKeyUtil; |
| namespace chromeos { |
| -class SessionManagerOperation; |
| - |
| // The class is a profile-keyed service which holds public/private |
| // keypair corresponds to a profile. The keypair is reloaded automatically when |
| // profile is created and TPM token is ready. Note that the private part of a |
| @@ -38,16 +38,23 @@ class SessionManagerOperation; |
| // (crbug.com/230018). |
| class OwnerSettingsServiceChromeOS : public ownership::OwnerSettingsService, |
| public content::NotificationObserver, |
| - public SessionManagerClient::Observer { |
| + public SessionManagerClient::Observer, |
| + public DeviceSettingsService::Observer { |
| public: |
| + class Observer { |
| + public: |
| + virtual ~Observer() {} |
| + virtual void OnSetCompleted(bool success) = 0; |
| + }; |
| + |
| virtual ~OwnerSettingsServiceChromeOS(); |
| void OnTPMTokenReady(bool tpm_token_enabled); |
| // ownership::OwnerSettingsService implementation: |
| - virtual void SignAndStorePolicyAsync( |
| - scoped_ptr<enterprise_management::PolicyData> policy, |
| - const base::Closure& callback) override; |
| + virtual bool HandlesSetting(const std::string& setting) override; |
| + virtual void Set(const std::string& setting, |
| + const base::Value& value) override; |
| // NotificationObserver implementation: |
| virtual void Observe(int type, |
| @@ -57,6 +64,10 @@ class OwnerSettingsServiceChromeOS : public ownership::OwnerSettingsService, |
| // SessionManagerClient::Observer: |
| virtual void OwnerKeySet(bool success) override; |
| + // DeviceSettingsService::Observer: |
| + virtual void OwnershipStatusChanged() override; |
| + virtual void DeviceSettingsUpdated() override; |
| + |
| // Checks if the user is the device owner, without the user profile having to |
| // been initialized. Should be used only if login state is in safe mode. |
| static void IsOwnerForSafeModeAsync( |
| @@ -67,7 +78,14 @@ class OwnerSettingsServiceChromeOS : public ownership::OwnerSettingsService, |
| static void SetDeviceSettingsServiceForTesting( |
| DeviceSettingsService* device_settings_service); |
| + void AddObserver(Observer* observer); |
| + |
| + void RemoveObserver(Observer* observer); |
| + |
| private: |
| + // Scoped lock for DeviceSettingsService processing loop. |
| + class DeviceSettingsServiceLock; |
| + |
| friend class OwnerSettingsServiceChromeOSFactory; |
| OwnerSettingsServiceChromeOS( |
| @@ -85,13 +103,17 @@ class OwnerSettingsServiceChromeOS : public ownership::OwnerSettingsService, |
| // Possibly notifies DeviceSettingsService that owner's keypair is loaded. |
| virtual void OnPostKeypairLoadedActions() override; |
| - // Performs next operation in the queue. |
| - void StartNextOperation(); |
| + void ProcessNextSetRequestAsync(); |
|
Mattias Nissler (ping if slow)
2014/10/17 12:05:27
The functions here could use some documentation.
ygorshenin1
2014/10/20 11:36:10
Done.
|
| - // Called when sign-and-store operation completes it's work. |
| - void HandleCompletedOperation(const base::Closure& callback, |
| - SessionManagerOperation* operation, |
| - DeviceSettingsService::Status status); |
| + void ProcessNextSetRequest(); |
| + |
| + void OnPolicyAssembledAndSigned( |
| + scoped_ptr<DeviceSettingsServiceLock> lock, |
| + scoped_ptr<enterprise_management::PolicyFetchResponse> policy_response); |
| + |
| + void OnSignedPolicyStored(); |
| + |
| + void HandleError(); |
| // Profile this service instance belongs to. |
| Profile* profile_; |
| @@ -105,14 +127,18 @@ class OwnerSettingsServiceChromeOS : public ownership::OwnerSettingsService, |
| // Whether TPM token still needs to be initialized. |
| bool waiting_for_tpm_token_; |
| - // The queue of pending sign-and-store operations. The first operation on the |
| - // queue is currently active; it gets removed and destroyed once it completes. |
| - std::deque<SessionManagerOperation*> pending_operations_; |
| + typedef std::pair<std::string, linked_ptr<base::Value>> SetRequest; |
|
Mattias Nissler (ping if slow)
2014/10/17 12:05:27
Looking at this, I can only guess what the first c
ygorshenin1
2014/10/20 11:36:10
Done.
|
| + std::queue<SetRequest> set_requests_; |
| + |
| + ObserverList<Observer> observers_; |
| content::NotificationRegistrar registrar_; |
| base::WeakPtrFactory<OwnerSettingsServiceChromeOS> weak_factory_; |
| + base::WeakPtrFactory<OwnerSettingsServiceChromeOS> |
| + set_requests_callback_factory_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(OwnerSettingsServiceChromeOS); |
| }; |