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

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

Issue 12163003: Add FilePath to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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') | chrome/browser/net/net_log_logger.h » ('j') | 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/file_util.h" 8 #include "base/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "base/time.h" 12 #include "base/time.h"
13 #include "chrome/browser/component_updater/component_updater_service.h" 13 #include "chrome/browser/component_updater/component_updater_service.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/common/chrome_constants.h" 15 #include "chrome/common/chrome_constants.h"
16 #include "chrome/common/chrome_paths.h" 16 #include "chrome/common/chrome_paths.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "net/base/crl_set.h" 18 #include "net/base/crl_set.h"
19 #include "net/base/ssl_config_service.h" 19 #include "net/base/ssl_config_service.h"
20 20
21 using content::BrowserThread; 21 using content::BrowserThread;
22 22
23 CRLSetFetcher::CRLSetFetcher() : cus_(NULL) {} 23 CRLSetFetcher::CRLSetFetcher() : cus_(NULL) {}
24 24
25 bool CRLSetFetcher::GetCRLSetFilePath(FilePath* path) const { 25 bool CRLSetFetcher::GetCRLSetFilePath(base::FilePath* path) const {
26 bool ok = PathService::Get(chrome::DIR_USER_DATA, path); 26 bool ok = PathService::Get(chrome::DIR_USER_DATA, path);
27 if (!ok) { 27 if (!ok) {
28 NOTREACHED(); 28 NOTREACHED();
29 return false; 29 return false;
30 } 30 }
31 *path = path->Append(chrome::kCRLSetFilename); 31 *path = path->Append(chrome::kCRLSetFilename);
32 return true; 32 return true;
33 } 33 }
34 34
35 void CRLSetFetcher::StartInitialLoad(ComponentUpdateService* cus) { 35 void CRLSetFetcher::StartInitialLoad(ComponentUpdateService* cus) {
36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
37 37
38 cus_ = cus; 38 cus_ = cus;
39 39
40 if (!BrowserThread::PostTask( 40 if (!BrowserThread::PostTask(
41 BrowserThread::FILE, FROM_HERE, 41 BrowserThread::FILE, FROM_HERE,
42 base::Bind(&CRLSetFetcher::DoInitialLoadFromDisk, this))) { 42 base::Bind(&CRLSetFetcher::DoInitialLoadFromDisk, this))) {
43 NOTREACHED(); 43 NOTREACHED();
44 } 44 }
45 } 45 }
46 46
47 void CRLSetFetcher::DoInitialLoadFromDisk() { 47 void CRLSetFetcher::DoInitialLoadFromDisk() {
48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
49 49
50 FilePath crl_set_file_path; 50 base::FilePath crl_set_file_path;
51 if (!GetCRLSetFilePath(&crl_set_file_path)) 51 if (!GetCRLSetFilePath(&crl_set_file_path))
52 return; 52 return;
53 53
54 LoadFromDisk(crl_set_file_path, &crl_set_); 54 LoadFromDisk(crl_set_file_path, &crl_set_);
55 55
56 uint32 sequence_of_loaded_crl = 0; 56 uint32 sequence_of_loaded_crl = 0;
57 if (crl_set_.get()) 57 if (crl_set_.get())
58 sequence_of_loaded_crl = crl_set_->sequence(); 58 sequence_of_loaded_crl = crl_set_->sequence();
59 59
60 // Get updates, advertising the sequence number of the CRL set that we just 60 // Get updates, advertising the sequence number of the CRL set that we just
61 // loaded, if any. 61 // loaded, if any.
62 if (!BrowserThread::PostTask( 62 if (!BrowserThread::PostTask(
63 BrowserThread::UI, FROM_HERE, 63 BrowserThread::UI, FROM_HERE,
64 base::Bind( 64 base::Bind(
65 &CRLSetFetcher::RegisterComponent, 65 &CRLSetFetcher::RegisterComponent,
66 this, 66 this,
67 sequence_of_loaded_crl))) { 67 sequence_of_loaded_crl))) {
68 NOTREACHED(); 68 NOTREACHED();
69 } 69 }
70 } 70 }
71 71
72 void CRLSetFetcher::LoadFromDisk(FilePath path, 72 void CRLSetFetcher::LoadFromDisk(base::FilePath path,
73 scoped_refptr<net::CRLSet>* out_crl_set) { 73 scoped_refptr<net::CRLSet>* out_crl_set) {
74 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 74 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
75 75
76 std::string crl_set_bytes; 76 std::string crl_set_bytes;
77 if (!file_util::ReadFileToString(path, &crl_set_bytes)) 77 if (!file_util::ReadFileToString(path, &crl_set_bytes))
78 return; 78 return;
79 79
80 if (!net::CRLSet::Parse(crl_set_bytes, out_crl_set)) { 80 if (!net::CRLSet::Parse(crl_set_bytes, out_crl_set)) {
81 LOG(WARNING) << "Failed to parse CRL set from " << path.MaybeAsASCII(); 81 LOG(WARNING) << "Failed to parse CRL set from " << path.MaybeAsASCII();
82 return; 82 return;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 NOTREACHED() << "RegisterComponent returned error"; 136 NOTREACHED() << "RegisterComponent returned error";
137 } 137 }
138 } 138 }
139 139
140 void CRLSetFetcher::OnUpdateError(int error) { 140 void CRLSetFetcher::OnUpdateError(int error) {
141 LOG(WARNING) << "CRLSetFetcher got error " << error 141 LOG(WARNING) << "CRLSetFetcher got error " << error
142 << " from component installer"; 142 << " from component installer";
143 } 143 }
144 144
145 bool CRLSetFetcher::Install(base::DictionaryValue* manifest, 145 bool CRLSetFetcher::Install(base::DictionaryValue* manifest,
146 const FilePath& unpack_path) { 146 const base::FilePath& unpack_path) {
147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 147 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
148 148
149 FilePath crl_set_file_path = unpack_path.Append(FILE_PATH_LITERAL("crl-set")); 149 base::FilePath crl_set_file_path =
150 FilePath save_to; 150 unpack_path.Append(FILE_PATH_LITERAL("crl-set"));
151 base::FilePath save_to;
151 if (!GetCRLSetFilePath(&save_to)) 152 if (!GetCRLSetFilePath(&save_to))
152 return true; 153 return true;
153 154
154 std::string crl_set_bytes; 155 std::string crl_set_bytes;
155 if (!file_util::ReadFileToString(crl_set_file_path, &crl_set_bytes)) { 156 if (!file_util::ReadFileToString(crl_set_file_path, &crl_set_bytes)) {
156 LOG(WARNING) << "Failed to find crl-set file inside CRX"; 157 LOG(WARNING) << "Failed to find crl-set file inside CRX";
157 return false; 158 return false;
158 } 159 }
159 160
160 bool is_delta; 161 bool is_delta;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 BrowserThread::IO, FROM_HERE, 199 BrowserThread::IO, FROM_HERE,
199 base::Bind( 200 base::Bind(
200 &CRLSetFetcher::SetCRLSetIfNewer, this, crl_set_))) { 201 &CRLSetFetcher::SetCRLSetIfNewer, this, crl_set_))) {
201 NOTREACHED(); 202 NOTREACHED();
202 } 203 }
203 204
204 return true; 205 return true;
205 } 206 }
206 207
207 CRLSetFetcher::~CRLSetFetcher() {} 208 CRLSetFetcher::~CRLSetFetcher() {}
OLDNEW
« no previous file with comments | « chrome/browser/net/crl_set_fetcher.h ('k') | chrome/browser/net/net_log_logger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698