OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // StrictTransportSecurityState maintains an in memory database containing the | 5 // StrictTransportSecurityState maintains an in memory database containing the |
6 // list of hosts that currently have strict transport security enabled. This | 6 // list of hosts that currently have strict 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 strict transport security state from the | 10 // At startup we need to load the strict transport security state from the |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 #include "base/file_path.h" | 36 #include "base/file_path.h" |
37 #include "base/lock.h" | 37 #include "base/lock.h" |
38 #include "base/ref_counted.h" | 38 #include "base/ref_counted.h" |
39 #include "net/base/strict_transport_security_state.h" | 39 #include "net/base/strict_transport_security_state.h" |
40 | 40 |
41 class StrictTransportSecurityPersister | 41 class StrictTransportSecurityPersister |
42 : public base::RefCountedThreadSafe<StrictTransportSecurityPersister>, | 42 : public base::RefCountedThreadSafe<StrictTransportSecurityPersister>, |
43 public net::StrictTransportSecurityState::Delegate { | 43 public net::StrictTransportSecurityState::Delegate { |
44 public: | 44 public: |
45 StrictTransportSecurityPersister(net::StrictTransportSecurityState* state, | 45 StrictTransportSecurityPersister(); |
46 const FilePath& profile_path); | 46 void Initialize(net::StrictTransportSecurityState* state, |
| 47 const FilePath& profile_path); |
47 | 48 |
48 // Called by the StrictTransportSecurityState when it changes its state. | 49 // Called by the StrictTransportSecurityState when it changes its state. |
49 virtual void StateIsDirty(net::StrictTransportSecurityState*); | 50 virtual void StateIsDirty(net::StrictTransportSecurityState*); |
50 | 51 |
51 private: | 52 private: |
52 friend class base::RefCountedThreadSafe<StrictTransportSecurityPersister>; | 53 friend class base::RefCountedThreadSafe<StrictTransportSecurityPersister>; |
53 | 54 |
54 ~StrictTransportSecurityPersister(); | 55 ~StrictTransportSecurityPersister(); |
55 | 56 |
56 // a Task callback for when the state needs to be written out. | 57 // a Task callback for when the state needs to be written out. |
57 void SerialiseState(); | 58 void SerialiseState(); |
58 | 59 |
59 // a Task callback for when the state needs to be loaded from disk at startup. | 60 // a Task callback for when the state needs to be loaded from disk at startup. |
60 void LoadState(); | 61 void LoadState(); |
61 | 62 |
62 Lock lock_; // protects all the members | 63 Lock lock_; // protects all the members |
63 | 64 |
64 // true when the state object has signaled that we're dirty and we haven't | 65 // true when the state object has signaled that we're dirty and we haven't |
65 // serialised the state yet. | 66 // serialised the state yet. |
66 bool state_is_dirty_; | 67 bool state_is_dirty_; |
67 | 68 |
68 scoped_refptr<net::StrictTransportSecurityState> | 69 scoped_refptr<net::StrictTransportSecurityState> |
69 strict_transport_security_state_; | 70 strict_transport_security_state_; |
70 // The path to the file in which we store the serialised state. | 71 // The path to the file in which we store the serialised state. |
71 const FilePath state_file_; | 72 FilePath state_file_; |
72 }; | 73 }; |
73 | 74 |
74 #endif // CHROME_BROWSER_STRICT_TRANSPORT_SECURITY_PERSISTER_H_ | 75 #endif // CHROME_BROWSER_STRICT_TRANSPORT_SECURITY_PERSISTER_H_ |
OLD | NEW |