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

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

Issue 10448118: Add the AsyncPolicyProvider and AsyncPolicyLoader (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unittest Created 8 years, 7 months 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/async_policy_provider.h
diff --git a/chrome/browser/policy/async_policy_provider.h b/chrome/browser/policy/async_policy_provider.h
new file mode 100644
index 0000000000000000000000000000000000000000..8a66e7f75c3282e5b9f92043decd67c27a1479cd
--- /dev/null
+++ b/chrome/browser/policy/async_policy_provider.h
@@ -0,0 +1,61 @@
+// Copyright (c) 2012 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_ASYNC_POLICY_PROVIDER_H_
+#define CHROME_BROWSER_POLICY_ASYNC_POLICY_PROVIDER_H_
+#pragma once
+
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/policy/configuration_policy_provider.h"
+
+namespace policy {
+
+class AsyncPolicyLoader;
+class PolicyBundle;
+
+// A policy provider that loads its policies asynchronously in the FILE thread.
Mattias Nissler (ping if slow) 2012/06/04 08:48:26 in or on? on is more familiar to me.
Joao da Silva 2012/06/04 14:05:06 Done.
+// Platform-specific providers are created by passing an implementation of
+// AsyncPolicyLoader to a new AsyncPolicyProvider.
+class AsyncPolicyProvider : public ConfigurationPolicyProvider {
+ public:
+ // Takes ownership of |loader|.
+ AsyncPolicyProvider(const PolicyDefinitionList* policy_list,
+ AsyncPolicyLoader* loader);
Mattias Nissler (ping if slow) 2012/06/04 08:48:26 should declare a scoped_ptr<AsyncPolicyLoader> arg
Joao da Silva 2012/06/04 14:05:06 Done.
+ virtual ~AsyncPolicyProvider();
+
+ // ConfigurationPolicyProvider implementation.
+ virtual void RefreshPolicies() OVERRIDE;
+
+ private:
+ // Resumes initialization once the loops are spinning.
+ void InitWithLoopsReady();
+
+ // Helper for RefreshPolicies().
+ void PostRefreshingReload();
+
+ // Invoked with the latest bundle loaded by the |loader_|.
+ void OnLoaderReloaded(scoped_ptr<PolicyBundle> bundle);
+
+ // The |loader_| that does the platform-specific policy loading. It lives
+ // in the FILE thread, and always outlives |this|.
+ AsyncPolicyLoader* loader_;
+
+ // Used to get WeakPtrs() to |this| on UI. These are used for the update
+ // callback passed to |loader_| and for the RefreshPolicies() tasks.
+ base::WeakPtrFactory<AsyncPolicyProvider> weak_factory_;
+
+ // Number of RefreshPolicies() calls that have been received before
+ // OnLoaderReloaded() has been invoked. Updates are only triggered after the
+ // last RefreshPolicies() request has triggered its reload, to make sure
+ // its observer will see the policy changes made before calling
+ // RefreshPolicies().
+ int pending_refreshes_;
+
+ DISALLOW_COPY_AND_ASSIGN(AsyncPolicyProvider);
+};
+
+} // namespace policy
+
+#endif // CHROME_BROWSER_POLICY_ASYNC_POLICY_PROVIDER_H_

Powered by Google App Engine
This is Rietveld 408576698