summaryrefslogtreecommitdiffstats
path: root/chrome/browser/transport_security_persister.h
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-09 17:28:40 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-09 17:28:40 +0000
commit19a7a3f845a5c8f29ebc140268b59b964a8f1cf5 (patch)
tree7a7e91c7905d54c2e9ea51e7527be80a582529dd /chrome/browser/transport_security_persister.h
parent67e6b7d7ee262b03e97b6e06c05daf4be92ba54e (diff)
downloadchromium_src-19a7a3f845a5c8f29ebc140268b59b964a8f1cf5.zip
chromium_src-19a7a3f845a5c8f29ebc140268b59b964a8f1cf5.tar.gz
chromium_src-19a7a3f845a5c8f29ebc140268b59b964a8f1cf5.tar.bz2
Switch TransportSecurityPersister to ImportantFileWriter
This is a standard infrastructure for handling file writes in a safe way, and in case of problems enables us to fix bugs in one place. BUG=none Review URL: http://codereview.chromium.org/7860014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100426 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/transport_security_persister.h')
-rw-r--r--chrome/browser/transport_security_persister.h38
1 files changed, 22 insertions, 16 deletions
diff --git a/chrome/browser/transport_security_persister.h b/chrome/browser/transport_security_persister.h
index de0d74d..c7e9ce0 100644
--- a/chrome/browser/transport_security_persister.h
+++ b/chrome/browser/transport_security_persister.h
@@ -34,22 +34,32 @@
#define CHROME_BROWSER_TRANSPORT_SECURITY_PERSISTER_H_
#pragma once
+#include <string>
+
#include "base/file_path.h"
#include "base/memory/ref_counted.h"
-#include "base/task.h"
+#include "chrome/common/important_file_writer.h"
#include "net/base/transport_security_state.h"
class TransportSecurityPersister
: public base::RefCountedThreadSafe<TransportSecurityPersister>,
- public net::TransportSecurityState::Delegate {
+ public net::TransportSecurityState::Delegate,
+ public ImportantFileWriter::DataSerializer {
public:
- explicit TransportSecurityPersister(bool readonly);
- void Initialize(net::TransportSecurityState* state,
- const FilePath& profile_path);
+ TransportSecurityPersister(net::TransportSecurityState* state,
+ const FilePath& profile_path,
+ bool readonly);
+
+ // Starts transport security data load on a background thread.
+ // Must be called on the UI thread right after construction.
+ void Init();
// Called by the TransportSecurityState when it changes its state.
virtual void StateIsDirty(net::TransportSecurityState*);
+ // ImportantFileWriter::DataSerializer:
+ virtual bool SerializeData(std::string* data);
+
private:
friend class base::RefCountedThreadSafe<TransportSecurityPersister>;
@@ -58,20 +68,16 @@ class TransportSecurityPersister
void Load();
void CompleteLoad(const std::string& state);
- void Save();
- void CompleteSave(const std::string& state);
+ // IO thread only.
+ scoped_refptr<net::TransportSecurityState> transport_security_state_;
- // Used on the IO thread to coalesce writes to disk.
- ScopedRunnableMethodFactory<TransportSecurityPersister> save_coalescer_;
-
- scoped_refptr<net::TransportSecurityState>
- transport_security_state_; // IO thread only.
-
- // The path to the file in which we store the serialised state.
- FilePath state_file_;
+ // Helper for safely writing the data.
+ ImportantFileWriter writer_;
// Whether or not we're in read-only mode.
- bool readonly_;
+ const bool readonly_;
+
+ DISALLOW_COPY_AND_ASSIGN(TransportSecurityPersister);
};
#endif // CHROME_BROWSER_TRANSPORT_SECURITY_PERSISTER_H_