Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Unified Diff: chrome/browser/policy/asynchronous_policy_loader.h

Issue 5562002: Refactor FileBasedPolicyProvider, introduce AsynchronousPolicyProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nits Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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,
+ AsynchronousPolicyProvider::Delegate* delegate,
+ int reload_interval_minutes);
battre (please use the other) 2010/12/02 17:40:25 Should we make |reload_interval_minutes| a TimeDel
danno 2010/12/03 17:05:38 Internally, it's now a TimeDelta, but it's much ni
+
+ // 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
battre (please use the other) 2010/12/02 17:40:25 Is this a copy and paste error? The header file co
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_|.
+ 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_;
battre (please use the other) 2010/12/02 17:40:25 Should we make this a TimeDelta?
danno 2010/12/03 17:05:38 Done.
+
+ DISALLOW_COPY_AND_ASSIGN(AsynchronousPolicyLoader);
+};
+
+} // namespace policy
+
+#endif // CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_LOADER_H_

Powered by Google App Engine
This is Rietveld 408576698