OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_POLICY_CLOUD_CLOUD_EXTERNAL_DATA_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_CLOUD_EXTERNAL_DATA_MANAGER_H_ |
6 #define CHROME_BROWSER_POLICY_CLOUD_CLOUD_EXTERNAL_DATA_MANAGER_H_ | 6 #define CHROME_BROWSER_POLICY_CLOUD_CLOUD_EXTERNAL_DATA_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" |
11 #include "chrome/browser/policy/external_data_manager.h" | 14 #include "chrome/browser/policy/external_data_manager.h" |
12 | 15 |
| 16 namespace net { |
| 17 class URLRequestContextGetter; |
| 18 } |
| 19 |
13 namespace policy { | 20 namespace policy { |
14 | 21 |
| 22 class CloudPolicyStore; |
| 23 |
15 // Downloads, verifies, caches and retrieves external data referenced by | 24 // Downloads, verifies, caches and retrieves external data referenced by |
16 // policies. | 25 // policies. |
17 // This a common base class used by cloud policy implementations and mocks. | 26 // This a common base class used by cloud policy implementations and mocks. |
18 class CloudExternalDataManager : public ExternalDataManager { | 27 class CloudExternalDataManager : public ExternalDataManager { |
19 public: | 28 public: |
20 struct MetadataEntry { | 29 struct MetadataEntry { |
21 MetadataEntry(); | 30 MetadataEntry(); |
22 MetadataEntry(const std::string& url, const std::string& hash); | 31 MetadataEntry(const std::string& url, const std::string& hash); |
23 | 32 |
| 33 bool operator!=(const MetadataEntry& other) const; |
| 34 |
24 std::string url; | 35 std::string url; |
25 std::string hash; | 36 std::string hash; |
26 }; | 37 }; |
27 // Maps from policy names to the metadata specifying the external data that | 38 // Maps from policy names to the metadata specifying the external data that |
28 // each of the policies references. | 39 // each of the policies references. |
29 typedef std::map<std::string, MetadataEntry> Metadata; | 40 typedef std::map<std::string, MetadataEntry> Metadata; |
| 41 |
| 42 CloudExternalDataManager(); |
| 43 virtual ~CloudExternalDataManager(); |
| 44 |
| 45 // Sets the source of external data references to |policy_store|. The manager |
| 46 // will start observing |policy_store| so that when external data references |
| 47 // change, obsolete data can be deleted and new data can be downloaded. If the |
| 48 // |policy_store| is destroyed before the manager, the connection must be |
| 49 // severed first by calling SetPolicyStore(NULL). |
| 50 virtual void SetPolicyStore(CloudPolicyStore* policy_store); |
| 51 |
| 52 // Called by the |policy_store_| when policy changes. |
| 53 virtual void OnPolicyStoreLoaded() = 0; |
| 54 |
| 55 // Allows the manager to download external data by constructing URLFetchers |
| 56 // from |request_context|. |
| 57 virtual void Connect( |
| 58 scoped_refptr<net::URLRequestContextGetter> request_context) = 0; |
| 59 |
| 60 // Prevents further external data downloads and aborts any downloads currently |
| 61 // in progress. |
| 62 virtual void Disconnect() = 0; |
| 63 |
| 64 protected: |
| 65 CloudPolicyStore* policy_store_; // Not owned. |
| 66 |
| 67 base::WeakPtrFactory<CloudExternalDataManager> weak_factory_; |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(CloudExternalDataManager); |
30 }; | 70 }; |
31 | 71 |
32 } // namespace policy | 72 } // namespace policy |
33 | 73 |
34 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_EXTERNAL_DATA_MANAGER_H_ | 74 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_EXTERNAL_DATA_MANAGER_H_ |
OLD | NEW |