Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_LOADER_H_ | |
| 6 #define CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_LOADER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/ref_counted.h" | |
| 10 #include "base/values.h" | |
| 11 #include "chrome/browser/policy/asynchronous_policy_provider.h" | |
| 12 | |
| 13 namespace policy { | |
| 14 | |
| 15 class ConfigurationPolicyProvider; | |
| 16 | |
| 17 class AsynchronousPolicyLoader | |
| 18 : public base::RefCountedThreadSafe<AsynchronousPolicyLoader> { | |
| 19 public: | |
| 20 AsynchronousPolicyLoader( | |
| 21 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
| |
| 22 AsynchronousPolicyProvider::Delegate* delegate, | |
| 23 int reload_interval_minutes); | |
| 24 | |
| 25 // Triggers initial policy load and schedules fallback reload. | |
| 26 void Init(); | |
| 27 | |
| 28 // Gets the current dictionary value object. Ownership of the returned value | |
| 29 // is transferred to the caller. | |
| 30 DictionaryValue* GetPolicy(); | |
| 31 | |
| 32 // Reloads policy, sending notification of changes if necessary. Must be | |
| 33 // called on the file thread. | |
| 34 void Reload(); | |
| 35 | |
| 36 // Stops any pending reload tasks. | |
| 37 void Stop(); | |
| 38 | |
| 39 private: | |
| 40 friend class AsynchronousPolicyLoaderTest; | |
| 41 // 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.
| |
| 42 // RefCountedThreadSafe. | |
| 43 friend class base::RefCountedThreadSafe<AsynchronousPolicyLoader>; | |
| 44 virtual ~AsynchronousPolicyLoader() {} | |
| 45 | |
| 46 // Schedules a reload task to run when |delay| expires. Must be called on the | |
| 47 // file thread. | |
| 48 void ScheduleReloadTask(const base::TimeDelta& delay); | |
| 49 | |
| 50 // Schedules a reload task to run after the number of minutes specified | |
| 51 // in |reload_interval_minutes_|. Must be called on the file thread. | |
| 52 void ScheduleFallbackReloadTask(); | |
| 53 | |
| 54 // Invoked from the reload task on the file thread. | |
| 55 void ReloadFromTask(); | |
| 56 | |
| 57 // Notifies the policy provider to send out a policy changed notification. | |
| 58 // Must be called on |origin_loop_|. | |
| 59 void NotifyPolicyChanged(); | |
| 60 | |
| 61 // The provider this loader is associated with. Access only on the thread that | |
| 62 // called the constructor. See |origin_loop_| below. | |
| 63 base::WeakPtr<ConfigurationPolicyProvider> provider_; | |
| 64 | |
| 65 scoped_ptr<AsynchronousPolicyProvider::Delegate> delegate_; | |
| 66 | |
| 67 // 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.
| |
| 68 Lock lock_; | |
| 69 | |
| 70 // The current policy definition. | |
| 71 scoped_ptr<DictionaryValue> policy_; | |
| 72 | |
| 73 // The message loop on which this object was constructed and |provider_| | |
| 74 // received on. Recorded so we can call back into the non thread safe provider | |
| 75 // to fire the notification. | |
| 76 MessageLoop* origin_loop_; | |
| 77 | |
| 78 // The reload task. Access only on the file thread. Holds a reference to the | |
| 79 // currently posted task, so we can cancel and repost it if necessary. | |
| 80 CancelableTask* reload_task_; | |
| 81 | |
| 82 // The interval in minutes that a policy reload will be triggered as a | |
| 83 // fallback even if the delegate doesn't indicate that one is needed. | |
| 84 const int reload_interval_minutes_; | |
| 85 | |
| 86 DISALLOW_COPY_AND_ASSIGN(AsynchronousPolicyLoader); | |
| 87 }; | |
| 88 | |
| 89 } // namespace policy | |
| 90 | |
| 91 #endif // CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_LOADER_H_ | |
| OLD | NEW |