Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 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_CHROMEOS_EXTENSIONS_DEVICE_LOCAL_ACCOUNT_EXTERNAL_POLICY_ LOADER_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_DEVICE_LOCAL_ACCOUNT_EXTERNAL_POLICY_ LOADER_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/callback_forward.h" | |
| 10 #include "base/compiler_specific.h" | |
| 11 #include "base/files/file_path.h" | |
| 12 #include "base/memory/ref_counted.h" | |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/sequenced_task_runner.h" | |
| 15 #include "chrome/browser/chromeos/extensions/external_cache.h" | |
| 16 #include "chrome/browser/extensions/external_loader.h" | |
| 17 #include "chrome/browser/policy/cloud/cloud_policy_store.h" | |
| 18 | |
| 19 namespace chromeos { | |
| 20 | |
| 21 // A specialization of the ExternalLoader that serves external extensions from | |
| 22 // the enterprise policy force-install list. This class is used for device-local | |
| 23 // accounts in place of the ExternalPolicyLoader. The difference is that while | |
| 24 // the ExternalPolicyLoader requires extensions to be downloaded on-the-fly, | |
| 25 // this class caches them, allowing for offline installation. | |
| 26 class DeviceLocalAccountExternalPolicyLoader | |
| 27 : public extensions::ExternalLoader, | |
| 28 public policy::CloudPolicyStore::Observer, | |
| 29 public ExternalCache::Delegate { | |
| 30 public: | |
| 31 // The list of force-installed extensions will be read from |store| and the | |
| 32 // extensions will be cached in the |cache_dir_|. | |
| 33 DeviceLocalAccountExternalPolicyLoader(policy::CloudPolicyStore* store, | |
| 34 const base::FilePath& cache_dir); | |
| 35 // If the cache was started, it must be stopped before |this| is destroyed. | |
| 36 virtual ~DeviceLocalAccountExternalPolicyLoader(); | |
| 37 | |
| 38 // While running, the cache requires exclusive write access to the | |
| 39 // |cache_dir_|. | |
| 40 bool IsCacheRunning() const; | |
| 41 | |
| 42 // Start the cache. This method must only be invoked when there are no pending | |
| 43 // write operations to |cache_dir_| on any thread and none will be initiated | |
| 44 // while the cache is running. | |
| 45 void StartCache( | |
| 46 const scoped_refptr<base::SequencedTaskRunner>& cache_task_runner); | |
| 47 | |
| 48 // Stop the cache. The |callback| will be invoked when the cache has shut down | |
| 49 // completely and write access to the |cache_dir_| is permitted again. | |
| 50 void StopCache(const base::Closure& callback); | |
| 51 | |
| 52 // extensions::ExternalLoader: | |
| 53 virtual void StartLoading() OVERRIDE; | |
| 54 | |
| 55 // policy::CloudPolicyStore::Observer: | |
| 56 virtual void OnStoreLoaded(policy::CloudPolicyStore* store) OVERRIDE; | |
| 57 virtual void OnStoreError(policy::CloudPolicyStore* store) OVERRIDE; | |
| 58 | |
| 59 // ExternalCache::Delegate: | |
| 60 virtual void OnExtensionListsUpdated( | |
| 61 const base::DictionaryValue* prefs) OVERRIDE; | |
| 62 | |
| 63 private: | |
| 64 // Pass the current list of force-installed extensions from the |store_| to | |
| 65 // the |external_cache_|. | |
| 66 void UpdateExtensionListFromStore(); | |
| 67 | |
| 68 policy::CloudPolicyStore* store_; // Not owned. | |
|
Joao da Silva
2013/10/17 14:57:54
I find this comment pattern quite low value and ju
bartfab (slow)
2013/10/18 12:58:39
A matter of opinion - some reviewers explicitly as
| |
| 69 const base::FilePath cache_dir_; | |
| 70 scoped_ptr<ExternalCache> external_cache_; | |
| 71 | |
| 72 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountExternalPolicyLoader); | |
| 73 }; | |
| 74 | |
| 75 } // namespace chromeos | |
| 76 | |
| 77 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_DEVICE_LOCAL_ACCOUNT_EXTERNAL_POLI CY_LOADER_H_ | |
| OLD | NEW |