1 // Copyright (c) 2012 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_NET_CRL_SET_FETCHER_H_ 6 #define CHROME_BROWSER_NET_CRL_SET_FETCHER_H_ 7 8 #include <string> 9 10 #include "base/compiler_specific.h" 11 #include "base/files/file_path.h" 12 #include "base/memory/ref_counted.h" 13 #include "components/component_updater/component_updater_service.h" 14 15 namespace base { 16 class DictionaryValue; 17 class FilePath; 18 } 19 20 namespace net { 21 class CRLSet; 22 } 23 24 class CRLSetFetcher : public component_updater::ComponentInstaller, 25 public base::RefCountedThreadSafe<CRLSetFetcher> { 26 public: 27 CRLSetFetcher(); 28 29 void StartInitialLoad(component_updater::ComponentUpdateService* cus, 30 const base::FilePath& path); 31 32 // DeleteFromDisk asynchronously delete the CRLSet file. 33 void DeleteFromDisk(const base::FilePath& path); 34 35 // ComponentInstaller interface 36 virtual void OnUpdateError(int error) OVERRIDE; 37 virtual bool Install(const base::DictionaryValue& manifest, 38 const base::FilePath& unpack_path) OVERRIDE; 39 virtual bool GetInstalledFile(const std::string& file, 40 base::FilePath* installed_file) OVERRIDE; 41 42 private: 43 friend class base::RefCountedThreadSafe<CRLSetFetcher>; 44 45 virtual ~CRLSetFetcher(); 46 47 // GetCRLSetbase::FilePath gets the path of the CRL set file in the user data 48 // dir. 49 base::FilePath GetCRLSetFilePath() const; 50 51 // Sets the path of the CRL set file in the user data dir. 52 void SetCRLSetFilePath(const base::FilePath& path); 53 54 // DoInitialLoadFromDisk runs on the FILE thread and attempts to load a CRL 55 // set from the user-data dir. It then registers this object as a component 56 // in order to get updates. 57 void DoInitialLoadFromDisk(); 58 59 // LoadFromDisk runs on the FILE thread and attempts to load a CRL set 60 // from |load_from|. 61 void LoadFromDisk(base::FilePath load_from, 62 scoped_refptr<net::CRLSet>* out_crl_set); 63 64 // SetCRLSetIfNewer runs on the IO thread and installs a CRL set 65 // as the global CRL set if it's newer than the existing one. 66 void SetCRLSetIfNewer(scoped_refptr<net::CRLSet> crl_set); 67 68 // RegisterComponent registers this object as a component updater. 69 void RegisterComponent(uint32 sequence_of_loaded_crl); 70 71 // DoDeleteFromDisk runs on the FILE thread and removes the CRLSet file from 72 // the disk. 73 void DoDeleteFromDisk(); 74 75 component_updater::ComponentUpdateService* cus_; 76 77 // Path where the CRL file is stored. 78 base::FilePath crl_path_; 79 80 // We keep a pointer to the current CRLSet for use on the FILE thread when 81 // applying delta updates. 82 scoped_refptr<net::CRLSet> crl_set_; 83 84 DISALLOW_COPY_AND_ASSIGN(CRLSetFetcher); 85 }; 86 87 #endif // CHROME_BROWSER_NET_CRL_SET_FETCHER_H_ 88