1 // Copyright (c) 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_POLICY_CLOUD_COMPONENT_CLOUD_POLICY_UPDATER_H_ 6 #define CHROME_BROWSER_POLICY_CLOUD_COMPONENT_CLOUD_POLICY_UPDATER_H_ 7 8 #include "base/basictypes.h" 9 #include "base/memory/ref_counted.h" 10 #include "base/memory/scoped_ptr.h" 11 #include "chrome/browser/policy/cloud/external_policy_data_updater.h" 12 13 namespace base { 14 class SequencedTaskRunner; 15 } 16 17 namespace enterprise_management { 18 class PolicyFetchResponse; 19 } 20 21 namespace net { 22 class URLRequestContextGetter; 23 } 24 25 namespace policy { 26 27 class ComponentCloudPolicyStore; 28 29 // This class downloads external policy data, given PolicyFetchResponses. 30 // It validates the PolicyFetchResponse and its corresponding data, and caches 31 // them in a ComponentCloudPolicyStore. It also enforces size limits on what's 32 // cached. 33 // It retries to download the policy data periodically when a download fails. 34 class ComponentCloudPolicyUpdater { 35 public: 36 // |task_runner| must support file I/O, and is used to post delayed retry 37 // tasks. 38 // |request_context| will be used for the download fetchers. 39 // |store| must outlive the updater, and is where the downloaded data will 40 // be cached. 41 ComponentCloudPolicyUpdater( 42 scoped_refptr<base::SequencedTaskRunner> task_runner, 43 scoped_refptr<net::URLRequestContextGetter> request_context, 44 ComponentCloudPolicyStore* store); 45 ~ComponentCloudPolicyUpdater(); 46 47 // |response| is the latest policy information fetched for some component. 48 // This method schedules the download of the policy data, if |response| is 49 // validated. If the downloaded data also passes validation then that data 50 // will be passed to the |store_|. 51 void UpdateExternalPolicy( 52 scoped_ptr<enterprise_management::PolicyFetchResponse> response); 53 54 private: 55 ComponentCloudPolicyStore* store_; 56 ExternalPolicyDataUpdater external_policy_data_updater_; 57 58 DISALLOW_COPY_AND_ASSIGN(ComponentCloudPolicyUpdater); 59 }; 60 61 } // namespace policy 62 63 #endif // CHROME_BROWSER_POLICY_CLOUD_COMPONENT_CLOUD_POLICY_UPDATER_H_ 64