Chromium Code Reviews| Index: chrome/browser/net/crl_set_fetcher.cc |
| diff --git a/chrome/browser/net/crl_set_fetcher.cc b/chrome/browser/net/crl_set_fetcher.cc |
| index f4c1648b59b562f35dcba067982ed6c448afb9a2..93b1bd4f216662e937ee0099051cb0007e1f2779 100644 |
| --- a/chrome/browser/net/crl_set_fetcher.cc |
| +++ b/chrome/browser/net/crl_set_fetcher.cc |
| @@ -20,40 +20,71 @@ |
| #include "net/cert/crl_set.h" |
| #include "net/cert/crl_set_storage.h" |
| #include "net/ssl/ssl_config_service.h" |
| +#if defined(OS_CHROMEOS) |
| +#include "chrome/browser/chromeos/profiles/profile_helper.h" |
| +#endif |
| using component_updater::ComponentUpdateService; |
| using content::BrowserThread; |
| CRLSetFetcher::CRLSetFetcher() : cus_(NULL) {} |
| -bool CRLSetFetcher::GetCRLSetFilePath(base::FilePath* path) const { |
| - bool ok = PathService::Get(chrome::DIR_USER_DATA, path); |
| +bool CRLSetFetcher::SetCRLSetFilePath(const std::string* user_id_hash) { |
| + |
| + base::FilePath path; |
| + bool ok = PathService::Get(chrome::DIR_USER_DATA, &path); |
| if (!ok) { |
| NOTREACHED(); |
| return false; |
| } |
| - *path = path->Append(chrome::kCRLSetFilename); |
| +#if defined(OS_CHROMEOS) |
|
Ryan Sleevi
2014/07/16 19:39:28
Every #ifdef makes for a sad panda. We should try
|
| + if (user_id_hash) |
| + path = |
| + path.Append(chromeos::ProfileHelper::GetUserProfileDir(*user_id_hash)); |
|
Jorge Lucangeli Obes
2014/07/16 16:36:34
Four-space indentation (double indentation) after
|
| +#endif |
| + crl_path_ = path.Append(chrome::kCRLSetFilename); |
| return true; |
| } |
| +base::FilePath CRLSetFetcher::GetCRLSetFilePath() const { |
| + return crl_path_; |
| +} |
| + |
| void CRLSetFetcher::StartInitialLoad(ComponentUpdateService* cus) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| - cus_ = cus; |
| + if (!SetCRLSetFilePath(NULL)) |
| + return; |
| + PostInitialLoad(cus); |
| +} |
| + |
| +void CRLSetFetcher::StartInitialLoadWithHash(ComponentUpdateService* cus, |
| + const std::string& user_id_hash) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + |
| + if (!SetCRLSetFilePath(&user_id_hash)) |
| + return; |
| + PostInitialLoad(cus); |
| +} |
| + |
| +void CRLSetFetcher::DeleteFromDisk() { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + if (!SetCRLSetFilePath(NULL)) |
| + return; |
| if (!BrowserThread::PostTask( |
| BrowserThread::FILE, FROM_HERE, |
| - base::Bind(&CRLSetFetcher::DoInitialLoadFromDisk, this))) { |
| + base::Bind(&CRLSetFetcher::DoDeleteFromDisk, this))) { |
| NOTREACHED(); |
| } |
| } |
| -void CRLSetFetcher::DeleteFromDisk() { |
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| +void CRLSetFetcher::PostInitialLoad(ComponentUpdateService* cus) { |
| + cus_ = cus; |
| if (!BrowserThread::PostTask( |
| BrowserThread::FILE, FROM_HERE, |
| - base::Bind(&CRLSetFetcher::DoDeleteFromDisk, this))) { |
| + base::Bind(&CRLSetFetcher::DoInitialLoadFromDisk, this))) { |
| NOTREACHED(); |
| } |
| } |
| @@ -61,11 +92,7 @@ void CRLSetFetcher::DeleteFromDisk() { |
| void CRLSetFetcher::DoInitialLoadFromDisk() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| - base::FilePath crl_set_file_path; |
| - if (!GetCRLSetFilePath(&crl_set_file_path)) |
| - return; |
| - |
| - LoadFromDisk(crl_set_file_path, &crl_set_); |
| + LoadFromDisk(GetCRLSetFilePath(), &crl_set_); |
| uint32 sequence_of_loaded_crl = 0; |
| if (crl_set_.get()) |
| @@ -160,11 +187,7 @@ void CRLSetFetcher::RegisterComponent(uint32 sequence_of_loaded_crl) { |
| void CRLSetFetcher::DoDeleteFromDisk() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| - base::FilePath crl_set_file_path; |
| - if (!GetCRLSetFilePath(&crl_set_file_path)) |
| - return; |
| - |
| - DeleteFile(crl_set_file_path, false /* not recursive */); |
| + DeleteFile(GetCRLSetFilePath(), false /* not recursive */); |
| } |
| void CRLSetFetcher::OnUpdateError(int error) { |
| @@ -176,9 +199,7 @@ bool CRLSetFetcher::Install(const base::DictionaryValue& manifest, |
| const base::FilePath& unpack_path) { |
| base::FilePath crl_set_file_path = |
| unpack_path.Append(FILE_PATH_LITERAL("crl-set")); |
| - base::FilePath save_to; |
| - if (!GetCRLSetFilePath(&save_to)) |
| - return true; |
| + base::FilePath save_to = GetCRLSetFilePath(); |
| std::string crl_set_bytes; |
| if (!base::ReadFileToString(crl_set_file_path, &crl_set_bytes)) { |