Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: chrome/browser/net/crl_set_fetcher.cc

Issue 391783003: Enabling CRLSet for ChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tidy ifdefs Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/net/crl_set_fetcher.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 #include "chrome/browser/net/crl_set_fetcher.h" 5 #include "chrome/browser/net/crl_set_fetcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/numerics/safe_conversions.h" 10 #include "base/numerics/safe_conversions.h"
11 #include "base/path_service.h"
12 #include "base/rand_util.h" 11 #include "base/rand_util.h"
13 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
14 #include "base/time/time.h" 13 #include "base/time/time.h"
15 #include "chrome/browser/component_updater/component_updater_service.h" 14 #include "chrome/browser/component_updater/component_updater_service.h"
16 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/common/chrome_constants.h" 16 #include "chrome/common/chrome_constants.h"
18 #include "chrome/common/chrome_paths.h" 17 #include "chrome/common/chrome_paths.h"
19 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
20 #include "net/cert/crl_set.h" 19 #include "net/cert/crl_set.h"
21 #include "net/cert/crl_set_storage.h" 20 #include "net/cert/crl_set_storage.h"
22 #include "net/ssl/ssl_config_service.h" 21 #include "net/ssl/ssl_config_service.h"
23 22
24 using component_updater::ComponentUpdateService; 23 using component_updater::ComponentUpdateService;
25 using content::BrowserThread; 24 using content::BrowserThread;
26 25
27 CRLSetFetcher::CRLSetFetcher() : cus_(NULL) {} 26 CRLSetFetcher::CRLSetFetcher() : cus_(NULL) {}
28 27
29 bool CRLSetFetcher::GetCRLSetFilePath(base::FilePath* path) const { 28 void CRLSetFetcher::SetCRLSetFilePath(const base::FilePath& path) {
30 bool ok = PathService::Get(chrome::DIR_USER_DATA, path); 29 crl_path_ = path.Append(chrome::kCRLSetFilename);
31 if (!ok) {
32 NOTREACHED();
33 return false;
34 }
35 *path = path->Append(chrome::kCRLSetFilename);
36 return true;
37 } 30 }
38 31
39 void CRLSetFetcher::StartInitialLoad(ComponentUpdateService* cus) { 32 base::FilePath CRLSetFetcher::GetCRLSetFilePath() const {
33 return crl_path_;
34 }
35
36 void CRLSetFetcher::StartInitialLoad(ComponentUpdateService* cus,
37 const base::FilePath& path) {
40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
41 39 if (path.empty())
40 return;
41 SetCRLSetFilePath(path);
42 cus_ = cus; 42 cus_ = cus;
43 43
44 if (!BrowserThread::PostTask( 44 if (!BrowserThread::PostTask(
45 BrowserThread::FILE, FROM_HERE, 45 BrowserThread::FILE, FROM_HERE,
46 base::Bind(&CRLSetFetcher::DoInitialLoadFromDisk, this))) { 46 base::Bind(&CRLSetFetcher::DoInitialLoadFromDisk, this))) {
47 NOTREACHED(); 47 NOTREACHED();
48 } 48 }
49 } 49 }
50 50
51 void CRLSetFetcher::DeleteFromDisk() { 51 void CRLSetFetcher::DeleteFromDisk(const base::FilePath& path) {
52 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 52 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
53 53
54 if (path.empty())
55 return;
56 SetCRLSetFilePath(path);
54 if (!BrowserThread::PostTask( 57 if (!BrowserThread::PostTask(
55 BrowserThread::FILE, FROM_HERE, 58 BrowserThread::FILE, FROM_HERE,
56 base::Bind(&CRLSetFetcher::DoDeleteFromDisk, this))) { 59 base::Bind(&CRLSetFetcher::DoDeleteFromDisk, this))) {
57 NOTREACHED(); 60 NOTREACHED();
58 } 61 }
59 } 62 }
60 63
61 void CRLSetFetcher::DoInitialLoadFromDisk() { 64 void CRLSetFetcher::DoInitialLoadFromDisk() {
62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
63 66
64 base::FilePath crl_set_file_path; 67 LoadFromDisk(GetCRLSetFilePath(), &crl_set_);
65 if (!GetCRLSetFilePath(&crl_set_file_path))
66 return;
67
68 LoadFromDisk(crl_set_file_path, &crl_set_);
69 68
70 uint32 sequence_of_loaded_crl = 0; 69 uint32 sequence_of_loaded_crl = 0;
71 if (crl_set_.get()) 70 if (crl_set_.get())
72 sequence_of_loaded_crl = crl_set_->sequence(); 71 sequence_of_loaded_crl = crl_set_->sequence();
73 72
74 // Get updates, advertising the sequence number of the CRL set that we just 73 // Get updates, advertising the sequence number of the CRL set that we just
75 // loaded, if any. 74 // loaded, if any.
76 if (!BrowserThread::PostTask( 75 if (!BrowserThread::PostTask(
77 BrowserThread::UI, FROM_HERE, 76 BrowserThread::UI, FROM_HERE,
78 base::Bind( 77 base::Bind(
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 152
154 if (cus_->RegisterComponent(component) != 153 if (cus_->RegisterComponent(component) !=
155 ComponentUpdateService::kOk) { 154 ComponentUpdateService::kOk) {
156 NOTREACHED() << "RegisterComponent returned error"; 155 NOTREACHED() << "RegisterComponent returned error";
157 } 156 }
158 } 157 }
159 158
160 void CRLSetFetcher::DoDeleteFromDisk() { 159 void CRLSetFetcher::DoDeleteFromDisk() {
161 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 160 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
162 161
163 base::FilePath crl_set_file_path; 162 DeleteFile(GetCRLSetFilePath(), false /* not recursive */);
164 if (!GetCRLSetFilePath(&crl_set_file_path))
165 return;
166
167 DeleteFile(crl_set_file_path, false /* not recursive */);
168 } 163 }
169 164
170 void CRLSetFetcher::OnUpdateError(int error) { 165 void CRLSetFetcher::OnUpdateError(int error) {
171 LOG(WARNING) << "CRLSetFetcher got error " << error 166 LOG(WARNING) << "CRLSetFetcher got error " << error
172 << " from component installer"; 167 << " from component installer";
173 } 168 }
174 169
175 bool CRLSetFetcher::Install(const base::DictionaryValue& manifest, 170 bool CRLSetFetcher::Install(const base::DictionaryValue& manifest,
176 const base::FilePath& unpack_path) { 171 const base::FilePath& unpack_path) {
177 base::FilePath crl_set_file_path = 172 base::FilePath crl_set_file_path =
178 unpack_path.Append(FILE_PATH_LITERAL("crl-set")); 173 unpack_path.Append(FILE_PATH_LITERAL("crl-set"));
179 base::FilePath save_to; 174 base::FilePath save_to = GetCRLSetFilePath();
180 if (!GetCRLSetFilePath(&save_to))
181 return true;
182 175
183 std::string crl_set_bytes; 176 std::string crl_set_bytes;
184 if (!base::ReadFileToString(crl_set_file_path, &crl_set_bytes)) { 177 if (!base::ReadFileToString(crl_set_file_path, &crl_set_bytes)) {
185 LOG(WARNING) << "Failed to find crl-set file inside CRX"; 178 LOG(WARNING) << "Failed to find crl-set file inside CRX";
186 return false; 179 return false;
187 } 180 }
188 181
189 bool is_delta; 182 bool is_delta;
190 if (!net::CRLSetStorage::GetIsDeltaUpdate(crl_set_bytes, &is_delta)) { 183 if (!net::CRLSetStorage::GetIsDeltaUpdate(crl_set_bytes, &is_delta)) {
191 LOG(WARNING) << "GetIsDeltaUpdate failed on CRL set from update CRX"; 184 LOG(WARNING) << "GetIsDeltaUpdate failed on CRL set from update CRX";
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 227
235 return true; 228 return true;
236 } 229 }
237 230
238 bool CRLSetFetcher::GetInstalledFile( 231 bool CRLSetFetcher::GetInstalledFile(
239 const std::string& file, base::FilePath* installed_file) { 232 const std::string& file, base::FilePath* installed_file) {
240 return false; 233 return false;
241 } 234 }
242 235
243 CRLSetFetcher::~CRLSetFetcher() {} 236 CRLSetFetcher::~CRLSetFetcher() {}
OLDNEW
« no previous file with comments | « chrome/browser/net/crl_set_fetcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698