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

Unified Diff: chrome/browser/chromeos/extensions/device_local_account_external_policy_loader.h

Issue 27548004: Cache force-installed apps/extensions in device-local accounts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Ready to reland after revert due to conflicting concurrent commit. Created 7 years, 2 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/chromeos/extensions/device_local_account_external_policy_loader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/extensions/device_local_account_external_policy_loader.h
diff --git a/chrome/browser/chromeos/extensions/device_local_account_external_policy_loader.h b/chrome/browser/chromeos/extensions/device_local_account_external_policy_loader.h
new file mode 100644
index 0000000000000000000000000000000000000000..c9abf5d0d8d20d1d661c64ceec69ba073ea6382d
--- /dev/null
+++ b/chrome/browser/chromeos/extensions/device_local_account_external_policy_loader.h
@@ -0,0 +1,78 @@
+// Copyright 2013 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_CHROMEOS_EXTENSIONS_DEVICE_LOCAL_ACCOUNT_EXTERNAL_POLICY_LOADER_H_
+#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_DEVICE_LOCAL_ACCOUNT_EXTERNAL_POLICY_LOADER_H_
+
+#include "base/basictypes.h"
+#include "base/callback_forward.h"
+#include "base/compiler_specific.h"
+#include "base/files/file_path.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/sequenced_task_runner.h"
+#include "chrome/browser/chromeos/extensions/external_cache.h"
+#include "chrome/browser/extensions/external_loader.h"
+#include "chrome/browser/policy/cloud/cloud_policy_store.h"
+
+namespace chromeos {
+
+// A specialization of the ExternalLoader that serves external extensions from
+// the enterprise policy force-install list. This class is used for device-local
+// accounts in place of the ExternalPolicyLoader. The difference is that while
+// the ExternalPolicyLoader requires extensions to be downloaded on-the-fly,
+// this class caches them, allowing for offline installation.
+class DeviceLocalAccountExternalPolicyLoader
+ : public extensions::ExternalLoader,
+ public policy::CloudPolicyStore::Observer,
+ public ExternalCache::Delegate {
+ public:
+ // The list of force-installed extensions will be read from |store| and the
+ // extensions will be cached in the |cache_dir_|.
+ DeviceLocalAccountExternalPolicyLoader(policy::CloudPolicyStore* store,
+ const base::FilePath& cache_dir);
+
+ // While running, the cache requires exclusive write access to the
+ // |cache_dir_|.
+ bool IsCacheRunning() const;
+
+ // Start the cache. This method must only be invoked when there are no pending
+ // write operations to |cache_dir_| on any thread and none will be initiated
+ // while the cache is running.
+ void StartCache(
+ const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner);
+
+ // Stop the cache. The |callback| will be invoked when the cache has shut down
+ // completely and write access to the |cache_dir_| is permitted again.
+ void StopCache(const base::Closure& callback);
+
+ // extensions::ExternalLoader:
+ virtual void StartLoading() OVERRIDE;
+
+ // policy::CloudPolicyStore::Observer:
+ virtual void OnStoreLoaded(policy::CloudPolicyStore* store) OVERRIDE;
+ virtual void OnStoreError(policy::CloudPolicyStore* store) OVERRIDE;
+
+ // ExternalCache::Delegate:
+ virtual void OnExtensionListsUpdated(
+ const base::DictionaryValue* prefs) OVERRIDE;
+
+ private:
+ // If the cache was started, it must be stopped before |this| is destroyed.
+ virtual ~DeviceLocalAccountExternalPolicyLoader();
+
+ // Pass the current list of force-installed extensions from the |store_| to
+ // the |external_cache_|.
+ void UpdateExtensionListFromStore();
+
+ policy::CloudPolicyStore* store_;
+ const base::FilePath cache_dir_;
+ scoped_ptr<ExternalCache> external_cache_;
+
+ DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountExternalPolicyLoader);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_DEVICE_LOCAL_ACCOUNT_EXTERNAL_POLICY_LOADER_H_
« no previous file with comments | « no previous file | chrome/browser/chromeos/extensions/device_local_account_external_policy_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698