Index: net/base/force_tls_state.h |
diff --git a/net/base/force_tls_state.h b/net/base/force_tls_state.h |
index e52adb9c3a46e02f50a0e2c05d028c9534284ee1..6c537ee651e2df49530f1f5d02b481144dbe2158 100644 |
--- a/net/base/force_tls_state.h |
+++ b/net/base/force_tls_state.h |
@@ -5,11 +5,13 @@ |
#ifndef NET_BASE_FORCE_TLS_STATE_H_ |
#define NET_BASE_FORCE_TLS_STATE_H_ |
-#include <set> |
+#include <map> |
#include <string> |
#include "base/basictypes.h" |
#include "base/lock.h" |
+#include "base/ref_counted.h" |
+#include "base/time.h" |
class GURL; |
@@ -21,7 +23,7 @@ namespace net { |
// then we refuse to talk to the host over HTTP, treat all certificate errors as |
// fatal, and refuse to load any mixed content. |
// |
-class ForceTLSState { |
+class ForceTLSState : public base::RefCountedThreadSafe<ForceTLSState> { |
public: |
ForceTLSState(); |
@@ -30,7 +32,8 @@ class ForceTLSState { |
void DidReceiveHeader(const GURL& url, const std::string& value); |
// Enable ForceTLS for |host|. |
- void EnableHost(const std::string& host); |
+ void EnableHost(const std::string& host, base::Time expiry, |
+ bool include_subdomains); |
// Returns whether |host| has had ForceTLS enabled. |
bool IsEnabledForHost(const std::string& host); |
@@ -43,13 +46,33 @@ class ForceTLSState { |
int* max_age, |
bool* include_subdomains); |
+ struct State { |
+ base::Time expiry; // the absolute time (UTC) when this record expires |
+ bool include_subdomains; // subdomains included? |
+ }; |
+ |
+ // Set a callback which is called on an arbitary thread when the state of |
+ // this object is updated. The callback may not block and may not reenter |
+ // this object. |
+ void SetDirtyCallback(void (*callback) (void*), void* userdata); |
+ |
+ bool Serialise(std::string* output); |
+ bool Deserialise(const std::string& state); |
+ |
private: |
+ // If we have a callback configured, call it to let our serialiser know that |
+ // our state is dirty. |
+ void DirtyNotify(); |
+ |
// The set of hosts that have enabled ForceTLS. |
- std::set<std::string> enabled_hosts_; |
+ std::map<std::string, State> enabled_hosts_; |
// Protect access to our data members with this lock. |
Lock lock_; |
+ void (*callback_) (void*); |
+ void* callback_userdata_; |
+ |
DISALLOW_COPY_AND_ASSIGN(ForceTLSState); |
}; |