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 "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
11 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/message_loop/message_loop_proxy.h" | |
15 #include "base/sequenced_task_runner.h" | 14 #include "base/sequenced_task_runner.h" |
16 #include "base/task_runner_util.h" | 15 #include "base/task_runner_util.h" |
17 #include "base/values.h" | 16 #include "base/values.h" |
18 #include "crypto/sha2.h" | 17 #include "crypto/sha2.h" |
19 #include "net/cert/x509_certificate.h" | 18 #include "net/cert/x509_certificate.h" |
20 #include "net/http/transport_security_state.h" | 19 #include "net/http/transport_security_state.h" |
21 | 20 |
22 namespace net { | 21 namespace net { |
23 | 22 |
24 namespace { | 23 namespace { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 87 |
89 } // namespace | 88 } // namespace |
90 | 89 |
91 TransportSecurityPersister::TransportSecurityPersister( | 90 TransportSecurityPersister::TransportSecurityPersister( |
92 TransportSecurityState* state, | 91 TransportSecurityState* state, |
93 const base::FilePath& profile_path, | 92 const base::FilePath& profile_path, |
94 const scoped_refptr<base::SequencedTaskRunner>& background_runner, | 93 const scoped_refptr<base::SequencedTaskRunner>& background_runner, |
95 bool readonly) | 94 bool readonly) |
96 : transport_security_state_(state), | 95 : transport_security_state_(state), |
97 writer_(profile_path.AppendASCII("TransportSecurity"), background_runner), | 96 writer_(profile_path.AppendASCII("TransportSecurity"), background_runner), |
98 foreground_runner_(base::MessageLoop::current()->message_loop_proxy()), | 97 foreground_runner_(base::MessageLoop::current()->task_runner()), |
99 background_runner_(background_runner), | 98 background_runner_(background_runner), |
100 readonly_(readonly), | 99 readonly_(readonly), |
101 weak_ptr_factory_(this) { | 100 weak_ptr_factory_(this) { |
102 transport_security_state_->SetDelegate(this); | 101 transport_security_state_->SetDelegate(this); |
103 | 102 |
104 base::PostTaskAndReplyWithResult( | 103 base::PostTaskAndReplyWithResult( |
105 background_runner_.get(), FROM_HERE, | 104 background_runner_.get(), FROM_HERE, |
106 base::Bind(&LoadState, writer_.path()), | 105 base::Bind(&LoadState, writer_.path()), |
107 base::Bind(&TransportSecurityPersister::CompleteLoad, | 106 base::Bind(&TransportSecurityPersister::CompleteLoad, |
108 weak_ptr_factory_.GetWeakPtr())); | 107 weak_ptr_factory_.GetWeakPtr())); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 bool dirty = false; | 310 bool dirty = false; |
312 if (!LoadEntries(state, &dirty)) { | 311 if (!LoadEntries(state, &dirty)) { |
313 LOG(ERROR) << "Failed to deserialize state: " << state; | 312 LOG(ERROR) << "Failed to deserialize state: " << state; |
314 return; | 313 return; |
315 } | 314 } |
316 if (dirty) | 315 if (dirty) |
317 StateIsDirty(transport_security_state_); | 316 StateIsDirty(transport_security_state_); |
318 } | 317 } |
319 | 318 |
320 } // namespace net | 319 } // namespace net |
OLD | NEW |