| 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 // TransportSecurityState maintains an in memory database containing the | 5 // TransportSecurityState maintains an in memory database containing the |
| 6 // list of hosts that currently have transport security enabled. This | 6 // list of hosts that currently have transport security enabled. This |
| 7 // singleton object deals with writing that data out to disk as needed and | 7 // singleton object deals with writing that data out to disk as needed and |
| 8 // loading it at startup. | 8 // loading it at startup. |
| 9 | 9 |
| 10 // At startup we need to load the transport security state from the | 10 // At startup we need to load the transport security state from the |
| 11 // disk. For the moment, we don't want to delay startup for this load, so we | 11 // disk. For the moment, we don't want to delay startup for this load, so we |
| 12 // let the TransportSecurityState run for a while without being loaded. | 12 // let the TransportSecurityState run for a while without being loaded. |
| 13 // This means that it's possible for pages opened very quickly not to get the | 13 // This means that it's possible for pages opened very quickly not to get the |
| 14 // correct transport security information. | 14 // correct transport security information. |
| 15 // | 15 // |
| 16 // To load the state, we schedule a Task on background_runner, which | 16 // To load the state, we schedule a Task on file_task_runner, which |
| 17 // deserializes and configures the TransportSecurityState. | 17 // deserializes and configures the TransportSecurityState. |
| 18 // | 18 // |
| 19 // The TransportSecurityState object supports running a callback function | 19 // The TransportSecurityState object supports running a callback function |
| 20 // when it changes. This object registers the callback, pointing at itself. | 20 // when it changes. This object registers the callback, pointing at itself. |
| 21 // | 21 // |
| 22 // TransportSecurityState calls... | 22 // TransportSecurityState calls... |
| 23 // TransportSecurityPersister::StateIsDirty | 23 // TransportSecurityPersister::StateIsDirty |
| 24 // since the callback isn't allowed to block or reenter, we schedule a Task | 24 // since the callback isn't allowed to block or reenter, we schedule a Task |
| 25 // on the file task runner after some small amount of time | 25 // on the file task runner after some small amount of time |
| 26 // | 26 // |
| (...skipping 17 matching lines...) Expand all Loading... |
| 44 | 44 |
| 45 namespace base { | 45 namespace base { |
| 46 class SequencedTaskRunner; | 46 class SequencedTaskRunner; |
| 47 } | 47 } |
| 48 | 48 |
| 49 namespace net { | 49 namespace net { |
| 50 | 50 |
| 51 // Reads and updates on-disk TransportSecurity state. Clients of this class | 51 // Reads and updates on-disk TransportSecurity state. Clients of this class |
| 52 // should create, destroy, and call into it from one thread. | 52 // should create, destroy, and call into it from one thread. |
| 53 // | 53 // |
| 54 // background_runner is the task runner this class should use internally to | 54 // file_task_runner is the task runner this class should use internally to |
| 55 // perform file IO, and can optionally be associated with a different thread. | 55 // perform file IO, and can optionally be associated with a different thread. |
| 56 class NET_EXPORT TransportSecurityPersister | 56 class NET_EXPORT TransportSecurityPersister |
| 57 : public TransportSecurityState::Delegate, | 57 : public TransportSecurityState::Delegate, |
| 58 public base::ImportantFileWriter::DataSerializer { | 58 public base::ImportantFileWriter::DataSerializer { |
| 59 public: | 59 public: |
| 60 TransportSecurityPersister( | 60 TransportSecurityPersister(TransportSecurityState* state, |
| 61 TransportSecurityState* state, | 61 const base::FilePath& profile_path, |
| 62 const base::FilePath& profile_path, | 62 base::SequencedTaskRunner* file_task_runner, |
| 63 const scoped_refptr<base::SequencedTaskRunner>& background_runner, | 63 bool readonly); |
| 64 bool readonly); | |
| 65 virtual ~TransportSecurityPersister(); | 64 virtual ~TransportSecurityPersister(); |
| 66 | 65 |
| 67 // Called by the TransportSecurityState when it changes its state. | 66 // Called by the TransportSecurityState when it changes its state. |
| 68 virtual void StateIsDirty(TransportSecurityState*) OVERRIDE; | 67 virtual void StateIsDirty(TransportSecurityState*) OVERRIDE; |
| 69 | 68 |
| 70 // ImportantFileWriter::DataSerializer: | 69 // ImportantFileWriter::DataSerializer: |
| 71 // | 70 // |
| 72 // Serializes |transport_security_state_| into |*output|. Returns true if | 71 // Serializes |transport_security_state_| into |*output|. Returns true if |
| 73 // all DomainStates were serialized correctly. | 72 // all DomainStates were serialized correctly. |
| 74 // | 73 // |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 const bool readonly_; | 129 const bool readonly_; |
| 131 | 130 |
| 132 base::WeakPtrFactory<TransportSecurityPersister> weak_ptr_factory_; | 131 base::WeakPtrFactory<TransportSecurityPersister> weak_ptr_factory_; |
| 133 | 132 |
| 134 DISALLOW_COPY_AND_ASSIGN(TransportSecurityPersister); | 133 DISALLOW_COPY_AND_ASSIGN(TransportSecurityPersister); |
| 135 }; | 134 }; |
| 136 | 135 |
| 137 } // namespace net | 136 } // namespace net |
| 138 | 137 |
| 139 #endif // NET_HTTP_TRANSPORT_SECURITY_PERSISTER_H_ | 138 #endif // NET_HTTP_TRANSPORT_SECURITY_PERSISTER_H_ |
| OLD | NEW |