| Index: chrome/browser/chromeos/policy/device_local_account_policy_service.h
|
| diff --git a/chrome/browser/chromeos/policy/device_local_account_policy_service.h b/chrome/browser/chromeos/policy/device_local_account_policy_service.h
|
| index 73b367e2455560f83a9a34f9405a8cc91b8c07b1..268f0a70a8e26642afdf8b9ed73e21ec01912a83 100644
|
| --- a/chrome/browser/chromeos/policy/device_local_account_policy_service.h
|
| +++ b/chrome/browser/chromeos/policy/device_local_account_policy_service.h
|
| @@ -6,6 +6,7 @@
|
| #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_SERVICE_H_
|
|
|
| #include <map>
|
| +#include <set>
|
| #include <string>
|
|
|
| #include "base/basictypes.h"
|
| @@ -14,6 +15,7 @@
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/memory/weak_ptr.h"
|
| #include "base/observer_list.h"
|
| +#include "chrome/browser/chromeos/extensions/device_local_account_external_policy_loader.h"
|
| #include "chrome/browser/chromeos/settings/cros_settings.h"
|
| #include "chrome/browser/policy/cloud/cloud_policy_core.h"
|
| #include "chrome/browser/policy/cloud/cloud_policy_store.h"
|
| @@ -23,14 +25,13 @@ class SequencedTaskRunner;
|
| }
|
|
|
| namespace chromeos {
|
| -class CrosSettings;
|
| class DeviceSettingsService;
|
| class SessionManagerClient;
|
| }
|
|
|
| namespace policy {
|
|
|
| -class CloudPolicyClient;
|
| +struct DeviceLocalAccount;
|
| class DeviceLocalAccountPolicyStore;
|
| class DeviceManagementService;
|
|
|
| @@ -39,19 +40,31 @@ class DeviceManagementService;
|
| class DeviceLocalAccountPolicyBroker {
|
| public:
|
| // |task_runner| is the runner for policy refresh tasks.
|
| - explicit DeviceLocalAccountPolicyBroker(
|
| - const std::string& user_id,
|
| + DeviceLocalAccountPolicyBroker(
|
| + const DeviceLocalAccount& account,
|
| scoped_ptr<DeviceLocalAccountPolicyStore> store,
|
| const scoped_refptr<base::SequencedTaskRunner>& task_runner);
|
| ~DeviceLocalAccountPolicyBroker();
|
|
|
| + // Initialize the broker, loading its |store_|.
|
| + void Initialize();
|
| +
|
| + // For the difference between |account_id| and |user_id|, see the
|
| + // documentation of DeviceLocalAccount.
|
| + const std::string& account_id() const { return account_id_; }
|
| const std::string& user_id() const { return user_id_; }
|
|
|
| + scoped_refptr<chromeos::DeviceLocalAccountExternalPolicyLoader>
|
| + extension_loader() const { return extension_loader_; }
|
| +
|
| CloudPolicyCore* core() { return &core_; }
|
| const CloudPolicyCore* core() const { return &core_; }
|
|
|
| - // Establish a cloud connection for the service.
|
| - void Connect(scoped_ptr<CloudPolicyClient> client);
|
| + // Fire up the cloud connection for fetching policy for the account from the
|
| + // cloud if this is an enterprise-managed device.
|
| + void ConnectIfPossible(
|
| + chromeos::DeviceSettingsService* device_settings_service,
|
| + DeviceManagementService* device_management_service);
|
|
|
| // Destroy the cloud connection, stopping policy refreshes.
|
| void Disconnect();
|
| @@ -64,8 +77,11 @@ class DeviceLocalAccountPolicyBroker {
|
| std::string GetDisplayName() const;
|
|
|
| private:
|
| + const std::string account_id_;
|
| const std::string user_id_;
|
| - scoped_ptr<DeviceLocalAccountPolicyStore> store_;
|
| + const scoped_ptr<DeviceLocalAccountPolicyStore> store_;
|
| + scoped_refptr<chromeos::DeviceLocalAccountExternalPolicyLoader>
|
| + extension_loader_;
|
| CloudPolicyCore core_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyBroker);
|
| @@ -93,7 +109,8 @@ class DeviceLocalAccountPolicyService : public CloudPolicyStore::Observer {
|
| chromeos::SessionManagerClient* session_manager_client,
|
| chromeos::DeviceSettingsService* device_settings_service,
|
| chromeos::CrosSettings* cros_settings,
|
| - scoped_refptr<base::SequencedTaskRunner> background_task_runner);
|
| + scoped_refptr<base::SequencedTaskRunner> store_background_task_runner,
|
| + scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner);
|
| virtual ~DeviceLocalAccountPolicyService();
|
|
|
| // Initializes the cloud policy service connection.
|
| @@ -118,31 +135,32 @@ class DeviceLocalAccountPolicyService : public CloudPolicyStore::Observer {
|
| virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE;
|
|
|
| private:
|
| - struct PolicyBrokerWrapper {
|
| - PolicyBrokerWrapper();
|
| - ~PolicyBrokerWrapper();
|
| + typedef std::map<std::string, DeviceLocalAccountPolicyBroker*>
|
| + PolicyBrokerMap;
|
|
|
| - // Return the |broker|, creating it first if necessary.
|
| - DeviceLocalAccountPolicyBroker* GetBroker();
|
| + // Returns |true| if the directory in which force-installed extensions are
|
| + // cached for |account_id| is busy, either because a broker that was using
|
| + // this directory has not shut down completely yet or because the directory is
|
| + // being deleted.
|
| + bool IsExtensionCacheDirectoryBusy(const std::string& account_id);
|
|
|
| - // Fire up the cloud connection for fetching policy for the account from the
|
| - // cloud if this is an enterprise-managed device.
|
| - void ConnectIfPossible();
|
| + // Starts any extension caches that are not running yet but can be started now
|
| + // because their cache directories are no longer busy.
|
| + void StartExtensionCachesIfPossible();
|
|
|
| - // Destroy the cloud connection.
|
| - void Disconnect();
|
| + // Checks whether a broker exists for |account_id|. If so, starts the broker's
|
| + // extension cache and returns |true|. Otherwise, returns |false|.
|
| + bool StartExtensionCacheForAccountIfPresent(const std::string& account_id);
|
|
|
| - // Delete the broker.
|
| - void DeleteBroker();
|
| + // Called back when any extension caches belonging to device-local accounts
|
| + // that no longer exist have been removed at start-up.
|
| + void OnOrphanedExtensionCachesDeleted();
|
|
|
| - std::string user_id;
|
| - std::string account_id;
|
| - DeviceLocalAccountPolicyService* parent;
|
| - DeviceLocalAccountPolicyBroker* broker;
|
| - scoped_refptr<base::SequencedTaskRunner> background_task_runner;
|
| - };
|
| + // Called back when the extension cache for |account_id| has been shut down.
|
| + void OnObsoleteExtensionCacheShutdown(const std::string& account_id);
|
|
|
| - typedef std::map<std::string, PolicyBrokerWrapper> PolicyBrokerMap;
|
| + // Called back when the extension cache for |account_id| has been removed.
|
| + void OnObsoleteExtensionCacheDeleted(const std::string& account_id);
|
|
|
| // Re-queries the list of defined device-local accounts from device settings
|
| // and updates |policy_brokers_| to match that list.
|
| @@ -166,16 +184,33 @@ class DeviceLocalAccountPolicyService : public CloudPolicyStore::Observer {
|
| // The device-local account policy brokers, keyed by user ID.
|
| PolicyBrokerMap policy_brokers_;
|
|
|
| + // Whether a call to UpdateAccountList() is pending because |cros_settings_|
|
| + // are not trusted yet.
|
| + bool waiting_for_cros_settings_;
|
| +
|
| + // Orphaned extension caches are removed at startup. This tracks the status of
|
| + // that process.
|
| + enum OrphanCacheDeletionState {
|
| + NOT_STARTED,
|
| + IN_PROGRESS,
|
| + DONE,
|
| + };
|
| + OrphanCacheDeletionState orphan_cache_deletion_state_;
|
| +
|
| + // Account IDs whose extension cache directories are busy, either because a
|
| + // broker for the account has not shut down completely yet or because the
|
| + // directory is being deleted.
|
| + std::set<std::string> busy_extension_cache_directories_;
|
| +
|
| + const scoped_refptr<base::SequencedTaskRunner> store_background_task_runner_;
|
| + const scoped_refptr<base::SequencedTaskRunner> extension_cache_task_runner_;
|
| +
|
| ObserverList<Observer, true> observers_;
|
|
|
| - scoped_ptr<chromeos::CrosSettings::ObserverSubscription>
|
| + const scoped_ptr<chromeos::CrosSettings::ObserverSubscription>
|
| local_accounts_subscription_;
|
|
|
| - scoped_refptr<base::SequencedTaskRunner> background_task_runner_;
|
| -
|
| - // Weak pointer factory for cros_settings_->PrepareTrustedValues() callbacks.
|
| - base::WeakPtrFactory<DeviceLocalAccountPolicyService>
|
| - cros_settings_callback_factory_;
|
| + base::WeakPtrFactory<DeviceLocalAccountPolicyService> weak_factory_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyService);
|
| };
|
|
|