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

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

Issue 10092010: Add CloudPolicyService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nit. 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
« no previous file with comments | « no previous file | chrome/browser/policy/cloud_policy_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/cloud_policy_service.h
diff --git a/chrome/browser/policy/cloud_policy_service.h b/chrome/browser/policy/cloud_policy_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..fe5cc345e10fa2970ba5bd26c1a30a5aa85def9b
--- /dev/null
+++ b/chrome/browser/policy/cloud_policy_service.h
@@ -0,0 +1,80 @@
+// 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_CLOUD_POLICY_SERVICE_H_
+#define CHROME_BROWSER_POLICY_CLOUD_POLICY_SERVICE_H_
+#pragma once
+
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/callback_forward.h"
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/policy/cloud_policy_client.h"
+#include "chrome/browser/policy/cloud_policy_constants.h"
+#include "chrome/browser/policy/cloud_policy_store.h"
+
+namespace policy {
+
+// Coordinates cloud policy handling, hosting the cloud policy client, fetching
+// new policy, and updating the local policy cache when new policy becomes
+// available.
+class CloudPolicyService : public CloudPolicyClient::Observer,
+ public CloudPolicyStore::Observer {
+ public:
+ CloudPolicyService(scoped_ptr<CloudPolicyClient> client,
+ scoped_ptr<CloudPolicyStore> store);
+ virtual ~CloudPolicyService();
+
+ // Returns the domain that manages this user/device, according to the current
+ // policy blob. Empty if not managed/not available.
+ std::string ManagedBy() const;
+
+ // Refreshes policy. |callback| will be invoked after the operation completes
+ // or aborts because of errors.
+ void RefreshPolicy(const base::Closure& callback);
+
+ CloudPolicyClient* client() { return client_.get(); }
+ CloudPolicyStore* store() { return store_.get(); }
+
+ // CloudPolicyClient::Observer:
+ virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE;
+ virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE;
+ virtual void OnClientError(CloudPolicyClient* client) OVERRIDE;
+
+ // CloudPolicyStore::Observer:
+ virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE;
+ virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE;
+
+ private:
+ // Invokes the refresh callbacks and clears refresh state.
+ void RefreshCompleted();
+
+ // The client used to talk to the cloud.
+ scoped_ptr<CloudPolicyClient> client_;
+
+ // Takes care of persisting and decoding cloud policy.
+ scoped_ptr<CloudPolicyStore> store_;
+
+ // Tracks the state of a pending refresh operation, if any.
+ enum {
+ // No refresh pending.
+ REFRESH_NONE,
+ // Policy fetch is pending.
+ REFRESH_POLICY_FETCH,
+ // Policy store is pending.
+ REFRESH_POLICY_STORE,
+ } refresh_state_;
+
+ // Callbacks to invoke upon policy refresh.
+ std::vector<base::Closure> refresh_callbacks_;
+
+ DISALLOW_COPY_AND_ASSIGN(CloudPolicyService);
+};
+
+} // namespace policy
+
+#endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_SERVICE_H_
« no previous file with comments | « no previous file | chrome/browser/policy/cloud_policy_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698