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