| 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 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 public base::ImportantFileWriter::DataSerializer { | 58 public base::ImportantFileWriter::DataSerializer { |
| 59 public: | 59 public: |
| 60 TransportSecurityPersister( | 60 TransportSecurityPersister( |
| 61 TransportSecurityState* state, | 61 TransportSecurityState* state, |
| 62 const base::FilePath& profile_path, | 62 const base::FilePath& profile_path, |
| 63 const scoped_refptr<base::SequencedTaskRunner>& background_runner, | 63 const scoped_refptr<base::SequencedTaskRunner>& background_runner, |
| 64 bool readonly); | 64 bool readonly); |
| 65 virtual ~TransportSecurityPersister(); | 65 virtual ~TransportSecurityPersister(); |
| 66 | 66 |
| 67 // Called by the TransportSecurityState when it changes its state. | 67 // Called by the TransportSecurityState when it changes its state. |
| 68 virtual void StateIsDirty(TransportSecurityState*) OVERRIDE; | 68 virtual void StateIsDirty(TransportSecurityState*) override; |
| 69 | 69 |
| 70 // ImportantFileWriter::DataSerializer: | 70 // ImportantFileWriter::DataSerializer: |
| 71 // | 71 // |
| 72 // Serializes |transport_security_state_| into |*output|. Returns true if | 72 // Serializes |transport_security_state_| into |*output|. Returns true if |
| 73 // all DomainStates were serialized correctly. | 73 // all DomainStates were serialized correctly. |
| 74 // | 74 // |
| 75 // The serialization format is JSON; the JSON represents a dictionary of | 75 // The serialization format is JSON; the JSON represents a dictionary of |
| 76 // host:DomainState pairs (host is a string). The DomainState is | 76 // host:DomainState pairs (host is a string). The DomainState is |
| 77 // represented as a dictionary containing the following keys and value | 77 // represented as a dictionary containing the following keys and value |
| 78 // types (not all keys will always be present): | 78 // types (not all keys will always be present): |
| (...skipping 11 matching lines...) Expand all Loading... |
| 90 // legacy key synonym "preloaded_spki_hashes" | 90 // legacy key synonym "preloaded_spki_hashes" |
| 91 // "bad_static_spki_hashes": list of strings | 91 // "bad_static_spki_hashes": list of strings |
| 92 // legacy key synonym "bad_preloaded_spki_hashes" | 92 // legacy key synonym "bad_preloaded_spki_hashes" |
| 93 // "dynamic_spki_hashes": list of strings | 93 // "dynamic_spki_hashes": list of strings |
| 94 // | 94 // |
| 95 // The JSON dictionary keys are strings containing | 95 // The JSON dictionary keys are strings containing |
| 96 // Base64(SHA256(TransportSecurityState::CanonicalizeHost(domain))). | 96 // Base64(SHA256(TransportSecurityState::CanonicalizeHost(domain))). |
| 97 // The reason for hashing them is so that the stored state does not | 97 // The reason for hashing them is so that the stored state does not |
| 98 // trivially reveal a user's browsing history to an attacker reading the | 98 // trivially reveal a user's browsing history to an attacker reading the |
| 99 // serialized state on disk. | 99 // serialized state on disk. |
| 100 virtual bool SerializeData(std::string* data) OVERRIDE; | 100 virtual bool SerializeData(std::string* data) override; |
| 101 | 101 |
| 102 // Clears any existing non-static entries, and then re-populates | 102 // Clears any existing non-static entries, and then re-populates |
| 103 // |transport_security_state_|. | 103 // |transport_security_state_|. |
| 104 // | 104 // |
| 105 // Sets |*dirty| to true if the new state differs from the persisted | 105 // Sets |*dirty| to true if the new state differs from the persisted |
| 106 // state; false otherwise. | 106 // state; false otherwise. |
| 107 bool LoadEntries(const std::string& serialized, bool* dirty); | 107 bool LoadEntries(const std::string& serialized, bool* dirty); |
| 108 | 108 |
| 109 private: | 109 private: |
| 110 // Populates |state| from the JSON string |serialized|. Returns true if | 110 // Populates |state| from the JSON string |serialized|. Returns true if |
| (...skipping 19 matching lines...) Expand all Loading... |
| 130 const bool readonly_; | 130 const bool readonly_; |
| 131 | 131 |
| 132 base::WeakPtrFactory<TransportSecurityPersister> weak_ptr_factory_; | 132 base::WeakPtrFactory<TransportSecurityPersister> weak_ptr_factory_; |
| 133 | 133 |
| 134 DISALLOW_COPY_AND_ASSIGN(TransportSecurityPersister); | 134 DISALLOW_COPY_AND_ASSIGN(TransportSecurityPersister); |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 } // namespace net | 137 } // namespace net |
| 138 | 138 |
| 139 #endif // NET_HTTP_TRANSPORT_SECURITY_PERSISTER_H_ | 139 #endif // NET_HTTP_TRANSPORT_SECURITY_PERSISTER_H_ |
| OLD | NEW |