Chromium Code Reviews| Index: chrome/browser/policy/asynchronous_policy_loader.h |
| diff --git a/chrome/browser/policy/asynchronous_policy_loader.h b/chrome/browser/policy/asynchronous_policy_loader.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7622c95c14b00bb0d7604dd9c2251a2cc0861288 |
| --- /dev/null |
| +++ b/chrome/browser/policy/asynchronous_policy_loader.h |
| @@ -0,0 +1,91 @@ |
| +// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_LOADER_H_ |
| +#define CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_LOADER_H_ |
| +#pragma once |
| + |
| +#include "base/ref_counted.h" |
| +#include "base/values.h" |
| +#include "chrome/browser/policy/asynchronous_policy_provider.h" |
| + |
| +namespace policy { |
| + |
| +class ConfigurationPolicyProvider; |
| + |
| +class AsynchronousPolicyLoader |
| + : public base::RefCountedThreadSafe<AsynchronousPolicyLoader> { |
| + public: |
| + AsynchronousPolicyLoader( |
| + base::WeakPtr<ConfigurationPolicyProvider> provider, |
|
Mattias Nissler (ping if slow)
2010/12/02 18:16:00
I thought the idea was to change the notification
danno
2010/12/03 17:05:38
There's plenty left to do, this work is only the f
|
| + AsynchronousPolicyProvider::Delegate* delegate, |
| + int reload_interval_minutes); |
| + |
| + // Triggers initial policy load and schedules fallback reload. |
| + void Init(); |
| + |
| + // Gets the current dictionary value object. Ownership of the returned value |
| + // is transferred to the caller. |
| + DictionaryValue* GetPolicy(); |
| + |
| + // Reloads policy, sending notification of changes if necessary. Must be |
| + // called on the file thread. |
| + void Reload(); |
| + |
| + // Stops any pending reload tasks. |
| + void Stop(); |
| + |
| + private: |
| + friend class AsynchronousPolicyLoaderTest; |
| + // FileBasedPolicyLoader objects should only be deleted by |
|
Mattias Nissler (ping if slow)
2010/12/02 18:16:00
newline before comment?
danno
2010/12/03 17:05:38
Done.
|
| + // RefCountedThreadSafe. |
| + friend class base::RefCountedThreadSafe<AsynchronousPolicyLoader>; |
| + virtual ~AsynchronousPolicyLoader() {} |
| + |
| + // Schedules a reload task to run when |delay| expires. Must be called on the |
| + // file thread. |
| + void ScheduleReloadTask(const base::TimeDelta& delay); |
| + |
| + // Schedules a reload task to run after the number of minutes specified |
| + // in |reload_interval_minutes_|. Must be called on the file thread. |
| + void ScheduleFallbackReloadTask(); |
| + |
| + // Invoked from the reload task on the file thread. |
| + void ReloadFromTask(); |
| + |
| + // Notifies the policy provider to send out a policy changed notification. |
| + // Must be called on |origin_loop_|. |
| + void NotifyPolicyChanged(); |
| + |
| + // The provider this loader is associated with. Access only on the thread that |
| + // called the constructor. See |origin_loop_| below. |
| + base::WeakPtr<ConfigurationPolicyProvider> provider_; |
| + |
| + scoped_ptr<AsynchronousPolicyProvider::Delegate> delegate_; |
| + |
| + // Protects |policy_|. |
|
Mattias Nissler (ping if slow)
2010/12/02 18:16:00
Is that still necessary? I thought we decided to a
danno
2010/12/03 17:05:38
Done.
|
| + Lock lock_; |
| + |
| + // The current policy definition. |
| + scoped_ptr<DictionaryValue> policy_; |
| + |
| + // The message loop on which this object was constructed and |provider_| |
| + // received on. Recorded so we can call back into the non thread safe provider |
| + // to fire the notification. |
| + MessageLoop* origin_loop_; |
| + |
| + // The reload task. Access only on the file thread. Holds a reference to the |
| + // currently posted task, so we can cancel and repost it if necessary. |
| + CancelableTask* reload_task_; |
| + |
| + // The interval in minutes that a policy reload will be triggered as a |
| + // fallback even if the delegate doesn't indicate that one is needed. |
| + const int reload_interval_minutes_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AsynchronousPolicyLoader); |
| +}; |
| + |
| +} // namespace policy |
| + |
| +#endif // CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_LOADER_H_ |