Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: chrome/browser/transport_security_persister.cc

Issue 7966005: Move TransportSecurityPersister completely to IO thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/transport_security_persister.h" 5 #include "chrome/browser/transport_security_persister.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "chrome/common/chrome_paths.h" 11 #include "chrome/common/chrome_paths.h"
12 #include "content/browser/browser_thread.h" 12 #include "content/browser/browser_thread.h"
13 #include "net/base/transport_security_state.h" 13 #include "net/base/transport_security_state.h"
14 14
15 TransportSecurityPersister::TransportSecurityPersister( 15 TransportSecurityPersister::TransportSecurityPersister(
16 net::TransportSecurityState* state, 16 net::TransportSecurityState* state,
17 const FilePath& profile_path, 17 const FilePath& profile_path,
18 bool readonly) 18 bool readonly)
19 : transport_security_state_(state), 19 : transport_security_state_(state),
20 writer_(profile_path.AppendASCII("TransportSecurity"), 20 writer_(profile_path.AppendASCII("TransportSecurity"),
21 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)), 21 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)),
22 readonly_(readonly) { 22 readonly_(readonly) {
23 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 23 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
24 24
25 transport_security_state_->SetDelegate(this); 25 transport_security_state_->SetDelegate(this);
26 } 26 }
27 27
28 TransportSecurityPersister::~TransportSecurityPersister() { 28 TransportSecurityPersister::~TransportSecurityPersister() {
29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
30
29 if (writer_.HasPendingWrite()) 31 if (writer_.HasPendingWrite())
30 writer_.DoScheduledWrite(); 32 writer_.DoScheduledWrite();
31 33
32 transport_security_state_->SetDelegate(NULL); 34 transport_security_state_->SetDelegate(NULL);
33 } 35 }
34 36
35 void TransportSecurityPersister::Init() { 37 void TransportSecurityPersister::Init() {
36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
37 BrowserThread::PostTask( 39 BrowserThread::PostTask(
willchan no longer on Chromium 2011/09/20 01:29:51 Can you use BrowserThread::PostTaskAndReply() and
38 BrowserThread::FILE, FROM_HERE, 40 BrowserThread::FILE, FROM_HERE,
39 NewRunnableMethod(this, &TransportSecurityPersister::Load)); 41 NewRunnableMethod(this, &TransportSecurityPersister::Load));
40 } 42 }
41 43
42 void TransportSecurityPersister::Load() { 44 void TransportSecurityPersister::Load() {
43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
44 46
45 std::string state; 47 std::string state;
46 if (!file_util::ReadFileToString(writer_.path(), &state)) 48 if (!file_util::ReadFileToString(writer_.path(), &state))
47 return; 49 return;
(...skipping 20 matching lines...) Expand all
68 void TransportSecurityPersister::StateIsDirty( 70 void TransportSecurityPersister::StateIsDirty(
69 net::TransportSecurityState* state) { 71 net::TransportSecurityState* state) {
70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
71 DCHECK_EQ(transport_security_state_, state); 73 DCHECK_EQ(transport_security_state_, state);
72 74
73 if (!readonly_) 75 if (!readonly_)
74 writer_.ScheduleWrite(this); 76 writer_.ScheduleWrite(this);
75 } 77 }
76 78
77 bool TransportSecurityPersister::SerializeData(std::string* data) { 79 bool TransportSecurityPersister::SerializeData(std::string* data) {
80 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
78 return transport_security_state_->Serialise(data); 81 return transport_security_state_->Serialise(data);
79 } 82 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698