| OLD | NEW | 
|---|
| 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 "net/http/transport_security_persister.h" | 5 #include "net/http/transport_security_persister.h" | 
| 6 | 6 | 
| 7 #include <memory> | 7 #include <memory> | 
| 8 #include <utility> | 8 #include <utility> | 
| 9 | 9 | 
| 10 #include "base/base64.h" | 10 #include "base/base64.h" | 
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 85 const char kPkpObserved[] = "pkp_observed"; | 85 const char kPkpObserved[] = "pkp_observed"; | 
| 86 const char kReportUri[] = "report-uri"; | 86 const char kReportUri[] = "report-uri"; | 
| 87 // The keys below are contained in a subdictionary keyed as | 87 // The keys below are contained in a subdictionary keyed as | 
| 88 // |kExpectCTSubdictionary|. | 88 // |kExpectCTSubdictionary|. | 
| 89 const char kExpectCTSubdictionary[] = "expect_ct"; | 89 const char kExpectCTSubdictionary[] = "expect_ct"; | 
| 90 const char kExpectCTExpiry[] = "expect_ct_expiry"; | 90 const char kExpectCTExpiry[] = "expect_ct_expiry"; | 
| 91 const char kExpectCTObserved[] = "expect_ct_observed"; | 91 const char kExpectCTObserved[] = "expect_ct_observed"; | 
| 92 const char kExpectCTEnforce[] = "expect_ct_enforce"; | 92 const char kExpectCTEnforce[] = "expect_ct_enforce"; | 
| 93 const char kExpectCTReportUri[] = "expect_ct_report_uri"; | 93 const char kExpectCTReportUri[] = "expect_ct_report_uri"; | 
| 94 | 94 | 
| 95 std::string LoadState(const base::FilePath& path) { | 95 std::string LoadState2(const base::FilePath& path) { | 
| 96   std::string result; | 96   std::string result; | 
| 97   if (!base::ReadFileToString(path, &result)) { | 97   if (!base::ReadFileToString(path, &result)) { | 
| 98     return ""; | 98     return ""; | 
| 99   } | 99   } | 
| 100   return result; | 100   return result; | 
| 101 } | 101 } | 
| 102 | 102 | 
| 103 bool IsDynamicExpectCTEnabled() { | 103 bool IsDynamicExpectCTEnabled() { | 
| 104   return base::FeatureList::IsEnabled( | 104   return base::FeatureList::IsEnabled( | 
| 105       TransportSecurityState::kDynamicExpectCTFeature); | 105       TransportSecurityState::kDynamicExpectCTFeature); | 
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 295     : transport_security_state_(state), | 295     : transport_security_state_(state), | 
| 296       writer_(profile_path.AppendASCII("TransportSecurity"), background_runner), | 296       writer_(profile_path.AppendASCII("TransportSecurity"), background_runner), | 
| 297       foreground_runner_(base::ThreadTaskRunnerHandle::Get()), | 297       foreground_runner_(base::ThreadTaskRunnerHandle::Get()), | 
| 298       background_runner_(background_runner), | 298       background_runner_(background_runner), | 
| 299       readonly_(readonly), | 299       readonly_(readonly), | 
| 300       weak_ptr_factory_(this) { | 300       weak_ptr_factory_(this) { | 
| 301   transport_security_state_->SetDelegate(this); | 301   transport_security_state_->SetDelegate(this); | 
| 302 | 302 | 
| 303   base::PostTaskAndReplyWithResult( | 303   base::PostTaskAndReplyWithResult( | 
| 304       background_runner_.get(), FROM_HERE, | 304       background_runner_.get(), FROM_HERE, | 
| 305       base::Bind(&LoadState, writer_.path()), | 305       base::Bind(&LoadState2, writer_.path()), | 
| 306       base::Bind(&TransportSecurityPersister::CompleteLoad, | 306       base::Bind(&TransportSecurityPersister::CompleteLoad, | 
| 307                  weak_ptr_factory_.GetWeakPtr())); | 307                  weak_ptr_factory_.GetWeakPtr())); | 
| 308 } | 308 } | 
| 309 | 309 | 
| 310 TransportSecurityPersister::~TransportSecurityPersister() { | 310 TransportSecurityPersister::~TransportSecurityPersister() { | 
| 311   DCHECK(foreground_runner_->RunsTasksInCurrentSequence()); | 311   DCHECK(foreground_runner_->RunsTasksInCurrentSequence()); | 
| 312 | 312 | 
| 313   if (writer_.HasPendingWrite()) | 313   if (writer_.HasPendingWrite()) | 
| 314     writer_.DoScheduledWrite(); | 314     writer_.DoScheduledWrite(); | 
| 315 | 315 | 
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 501   bool dirty = false; | 501   bool dirty = false; | 
| 502   if (!LoadEntries(state, &dirty)) { | 502   if (!LoadEntries(state, &dirty)) { | 
| 503     LOG(ERROR) << "Failed to deserialize state: " << state; | 503     LOG(ERROR) << "Failed to deserialize state: " << state; | 
| 504     return; | 504     return; | 
| 505   } | 505   } | 
| 506   if (dirty) | 506   if (dirty) | 
| 507     StateIsDirty(transport_security_state_); | 507     StateIsDirty(transport_security_state_); | 
| 508 } | 508 } | 
| 509 | 509 | 
| 510 }  // namespace net | 510 }  // namespace net | 
| OLD | NEW | 
|---|