Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / net / crl_set_fetcher.h
blob9c23a872056176d6fd077bf6d580f41c57137d14
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.
5 #ifndef CHROME_BROWSER_NET_CRL_SET_FETCHER_H_
6 #define CHROME_BROWSER_NET_CRL_SET_FETCHER_H_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "base/files/file_path.h"
12 #include "base/memory/ref_counted.h"
13 #include "components/update_client/update_client.h"
15 namespace base {
16 class DictionaryValue;
17 class FilePath;
20 namespace net {
21 class CRLSet;
24 namespace component_updater {
25 class ComponentUpdateService;
28 class CRLSetFetcher : public update_client::CrxInstaller {
29 public:
30 CRLSetFetcher();
32 void StartInitialLoad(component_updater::ComponentUpdateService* cus,
33 const base::FilePath& path);
35 // DeleteFromDisk asynchronously delete the CRLSet file.
36 void DeleteFromDisk(const base::FilePath& path);
38 // ComponentInstaller interface
39 void OnUpdateError(int error) override;
40 bool Install(const base::DictionaryValue& manifest,
41 const base::FilePath& unpack_path) override;
42 bool GetInstalledFile(const std::string& file,
43 base::FilePath* installed_file) override;
44 bool Uninstall() override;
46 private:
47 friend class base::RefCountedThreadSafe<CRLSetFetcher>;
49 ~CRLSetFetcher() override;
51 // GetCRLSetbase::FilePath gets the path of the CRL set file in the user data
52 // dir.
53 base::FilePath GetCRLSetFilePath() const;
55 // Sets the path of the CRL set file in the user data dir.
56 void SetCRLSetFilePath(const base::FilePath& path);
58 // DoInitialLoadFromDisk runs on the FILE thread and attempts to load a CRL
59 // set from the user-data dir. It then registers this object as a component
60 // in order to get updates.
61 void DoInitialLoadFromDisk();
63 // LoadFromDisk runs on the FILE thread and attempts to load a CRL set
64 // from |load_from|.
65 void LoadFromDisk(base::FilePath load_from,
66 scoped_refptr<net::CRLSet>* out_crl_set);
68 // SetCRLSetIfNewer runs on the IO thread and installs a CRL set
69 // as the global CRL set if it's newer than the existing one.
70 void SetCRLSetIfNewer(scoped_refptr<net::CRLSet> crl_set);
72 // RegisterComponent registers this object as a component updater.
73 void RegisterComponent(uint32 sequence_of_loaded_crl);
75 // DoDeleteFromDisk runs on the FILE thread and removes the CRLSet file from
76 // the disk.
77 void DoDeleteFromDisk();
79 component_updater::ComponentUpdateService* cus_;
81 // Path where the CRL file is stored.
82 base::FilePath crl_path_;
84 // We keep a pointer to the current CRLSet for use on the FILE thread when
85 // applying delta updates.
86 scoped_refptr<net::CRLSet> crl_set_;
88 DISALLOW_COPY_AND_ASSIGN(CRLSetFetcher);
91 #endif // CHROME_BROWSER_NET_CRL_SET_FETCHER_H_