OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 26 matching lines...) Expand all Loading... |
37 #include <string> | 37 #include <string> |
38 | 38 |
39 #include "base/file_path.h" | 39 #include "base/file_path.h" |
40 #include "base/memory/ref_counted.h" | 40 #include "base/memory/ref_counted.h" |
41 #include "chrome/common/important_file_writer.h" | 41 #include "chrome/common/important_file_writer.h" |
42 #include "content/browser/browser_thread.h" | 42 #include "content/browser/browser_thread.h" |
43 #include "net/base/transport_security_state.h" | 43 #include "net/base/transport_security_state.h" |
44 | 44 |
45 class TransportSecurityPersister | 45 class TransportSecurityPersister |
46 : public base::RefCountedThreadSafe<TransportSecurityPersister, | 46 : public base::RefCountedThreadSafe<TransportSecurityPersister, |
47 BrowserThread::DeleteOnUIThread>, | 47 BrowserThread::DeleteOnIOThread>, |
48 public net::TransportSecurityState::Delegate, | 48 public net::TransportSecurityState::Delegate, |
49 public ImportantFileWriter::DataSerializer { | 49 public ImportantFileWriter::DataSerializer { |
50 public: | 50 public: |
51 TransportSecurityPersister(net::TransportSecurityState* state, | 51 TransportSecurityPersister(net::TransportSecurityState* state, |
52 const FilePath& profile_path, | 52 const FilePath& profile_path, |
53 bool readonly); | 53 bool readonly); |
54 | 54 |
55 // Starts transport security data load on a background thread. | 55 // Starts transport security data load on a background thread. |
56 // Must be called on the UI thread right after construction. | 56 // Must be called on the UI thread right after construction. |
57 void Init(); | 57 void Init(); |
58 | 58 |
59 // Called by the TransportSecurityState when it changes its state. | 59 // Called by the TransportSecurityState when it changes its state. |
60 virtual void StateIsDirty(net::TransportSecurityState*); | 60 virtual void StateIsDirty(net::TransportSecurityState*); |
61 | 61 |
62 // ImportantFileWriter::DataSerializer: | 62 // ImportantFileWriter::DataSerializer: |
63 virtual bool SerializeData(std::string* data); | 63 virtual bool SerializeData(std::string* data); |
64 | 64 |
65 private: | 65 private: |
66 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; | 66 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; |
67 friend class DeleteTask<TransportSecurityPersister>; | 67 friend class DeleteTask<TransportSecurityPersister>; |
68 | 68 |
69 virtual ~TransportSecurityPersister(); | 69 virtual ~TransportSecurityPersister(); |
70 | 70 |
71 void Load(); | 71 void Load(); |
72 void CompleteLoad(const std::string& state); | 72 void CompleteLoad(const std::string& state); |
73 | 73 |
74 // IO thread only. | 74 // IO thread only. |
75 scoped_refptr<net::TransportSecurityState> transport_security_state_; | 75 scoped_refptr<net::TransportSecurityState> transport_security_state_; |
76 | 76 |
77 // Helper for safely writing the data. | 77 // Helper for safely writing the data. |
78 ImportantFileWriter writer_; | 78 ImportantFileWriter writer_; |
79 | 79 |
80 // Whether or not we're in read-only mode. | 80 // Whether or not we're in read-only mode. |
81 const bool readonly_; | 81 const bool readonly_; |
82 | 82 |
83 DISALLOW_COPY_AND_ASSIGN(TransportSecurityPersister); | 83 DISALLOW_COPY_AND_ASSIGN(TransportSecurityPersister); |
84 }; | 84 }; |
85 | 85 |
86 #endif // CHROME_BROWSER_TRANSPORT_SECURITY_PERSISTER_H_ | 86 #endif // CHROME_BROWSER_TRANSPORT_SECURITY_PERSISTER_H_ |
OLD | NEW |