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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_server_bound_cert_helper.cc

Issue 11742037: Make ServerBoundCertStore interface async, move SQLiteServerBoundCertStore load onto DB thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix login_utils_browsertest Created 7 years, 11 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browsing_data/browsing_data_server_bound_cert_helper.h" 5 #include "chrome/browser/browsing_data/browsing_data_server_bound_cert_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 13 matching lines...) Expand all
24 // BrowsingDataServerBoundCertHelper methods. 24 // BrowsingDataServerBoundCertHelper methods.
25 virtual void StartFetching(const FetchResultCallback& callback) OVERRIDE; 25 virtual void StartFetching(const FetchResultCallback& callback) OVERRIDE;
26 virtual void DeleteServerBoundCert(const std::string& server_id) OVERRIDE; 26 virtual void DeleteServerBoundCert(const std::string& server_id) OVERRIDE;
27 27
28 private: 28 private:
29 virtual ~BrowsingDataServerBoundCertHelperImpl(); 29 virtual ~BrowsingDataServerBoundCertHelperImpl();
30 30
31 // Fetch the certs. This must be called in the IO thread. 31 // Fetch the certs. This must be called in the IO thread.
32 void FetchOnIOThread(); 32 void FetchOnIOThread();
33 33
34 void OnFetchComplete(
35 const net::ServerBoundCertStore::ServerBoundCertList& cert_list);
36
34 // Notifies the completion callback. This must be called in the UI thread. 37 // Notifies the completion callback. This must be called in the UI thread.
35 void NotifyInUIThread(); 38 void NotifyInUIThread(
39 const net::ServerBoundCertStore::ServerBoundCertList& cert_list);
36 40
37 // Delete a single cert. This must be called in IO thread. 41 // Delete a single cert. This must be called in IO thread.
38 void DeleteOnIOThread(const std::string& server_id); 42 void DeleteOnIOThread(const std::string& server_id);
39 43
40 // Access to |server_bound_cert_list_| is triggered indirectly via the UI 44 // Called when deletion is done.
41 // thread and guarded by |is_fetching_|. This means |server_bound_cert_list_| 45 void DeleteCallback();
42 // is only accessed while |is_fetching_| is true. The flag |is_fetching_| is
43 // only accessed on the UI thread.
44 net::ServerBoundCertStore::ServerBoundCertList server_bound_cert_list_;
45 46
46 // Indicates whether or not we're currently fetching information: 47 // Indicates whether or not we're currently fetching information:
47 // it's true when StartFetching() is called in the UI thread, and it's reset 48 // it's true when StartFetching() is called in the UI thread, and it's reset
48 // after we notify the callback in the UI thread. 49 // after we notify the callback in the UI thread.
49 // This only mutates on the UI thread. 50 // This only mutates on the UI thread.
50 bool is_fetching_; 51 bool is_fetching_;
51 52
52 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 53 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
53 54
54 // This only mutates on the UI thread. 55 // This only mutates on the UI thread.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 base::Bind(&BrowsingDataServerBoundCertHelperImpl::DeleteOnIOThread, 91 base::Bind(&BrowsingDataServerBoundCertHelperImpl::DeleteOnIOThread,
91 this, server_id)); 92 this, server_id));
92 } 93 }
93 94
94 void BrowsingDataServerBoundCertHelperImpl::FetchOnIOThread() { 95 void BrowsingDataServerBoundCertHelperImpl::FetchOnIOThread() {
95 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 96 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
96 net::ServerBoundCertStore* cert_store = 97 net::ServerBoundCertStore* cert_store =
97 request_context_getter_->GetURLRequestContext()-> 98 request_context_getter_->GetURLRequestContext()->
98 server_bound_cert_service()->GetCertStore(); 99 server_bound_cert_service()->GetCertStore();
99 if (cert_store) { 100 if (cert_store) {
100 server_bound_cert_list_.clear(); 101 cert_store->GetAllServerBoundCerts(base::Bind(
101 cert_store->GetAllServerBoundCerts(&server_bound_cert_list_); 102 &BrowsingDataServerBoundCertHelperImpl::OnFetchComplete, this));
102 content::BrowserThread::PostTask( 103 } else {
103 content::BrowserThread::UI, FROM_HERE, 104 OnFetchComplete(net::ServerBoundCertStore::ServerBoundCertList());
104 base::Bind(&BrowsingDataServerBoundCertHelperImpl::NotifyInUIThread,
105 this));
106 } 105 }
107 } 106 }
108 107
109 void BrowsingDataServerBoundCertHelperImpl::NotifyInUIThread() { 108 void BrowsingDataServerBoundCertHelperImpl::OnFetchComplete(
109 const net::ServerBoundCertStore::ServerBoundCertList& cert_list) {
110 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
111 content::BrowserThread::PostTask(
112 content::BrowserThread::UI, FROM_HERE,
113 base::Bind(&BrowsingDataServerBoundCertHelperImpl::NotifyInUIThread,
114 this, cert_list));
115 }
116
117 void BrowsingDataServerBoundCertHelperImpl::NotifyInUIThread(
118 const net::ServerBoundCertStore::ServerBoundCertList& cert_list) {
110 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 119 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
111 DCHECK(is_fetching_); 120 DCHECK(is_fetching_);
112 is_fetching_ = false; 121 is_fetching_ = false;
113 completion_callback_.Run(server_bound_cert_list_); 122 completion_callback_.Run(cert_list);
114 completion_callback_.Reset(); 123 completion_callback_.Reset();
115 } 124 }
116 125
117 void BrowsingDataServerBoundCertHelperImpl::DeleteOnIOThread( 126 void BrowsingDataServerBoundCertHelperImpl::DeleteOnIOThread(
118 const std::string& server_id) { 127 const std::string& server_id) {
119 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 128 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
120 net::ServerBoundCertStore* cert_store = 129 net::ServerBoundCertStore* cert_store =
121 request_context_getter_->GetURLRequestContext()-> 130 request_context_getter_->GetURLRequestContext()->
122 server_bound_cert_service()->GetCertStore(); 131 server_bound_cert_service()->GetCertStore();
123 if (cert_store) { 132 if (cert_store) {
124 cert_store->DeleteServerBoundCert(server_id); 133 cert_store->DeleteServerBoundCert(
125 // Need to close open SSL connections which may be using the channel ids we 134 server_id,
126 // are deleting. 135 base::Bind(&BrowsingDataServerBoundCertHelperImpl::DeleteCallback,
127 // TODO(mattm): http://crbug.com/166069 Make the server bound cert 136 this));
128 // service/store have observers that can notify relevant things directly.
129 request_context_getter_->GetURLRequestContext()->ssl_config_service()->
130 NotifySSLConfigChange();
131 } 137 }
132 } 138 }
133 139
140 void BrowsingDataServerBoundCertHelperImpl::DeleteCallback() {
141 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
142 // Need to close open SSL connections which may be using the channel ids we
143 // are deleting.
144 // TODO(mattm): http://crbug.com/166069 Make the server bound cert
145 // service/store have observers that can notify relevant things directly.
146 request_context_getter_->GetURLRequestContext()->ssl_config_service()->
147 NotifySSLConfigChange();
148 }
149
134 } // namespace 150 } // namespace
135 151
136 // static 152 // static
137 BrowsingDataServerBoundCertHelper* 153 BrowsingDataServerBoundCertHelper*
138 BrowsingDataServerBoundCertHelper::Create(Profile* profile) { 154 BrowsingDataServerBoundCertHelper::Create(Profile* profile) {
139 return new BrowsingDataServerBoundCertHelperImpl(profile); 155 return new BrowsingDataServerBoundCertHelperImpl(profile);
140 } 156 }
141 157
142 CannedBrowsingDataServerBoundCertHelper:: 158 CannedBrowsingDataServerBoundCertHelper::
143 CannedBrowsingDataServerBoundCertHelper() {} 159 CannedBrowsingDataServerBoundCertHelper() {}
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 for (ServerBoundCertMap::iterator i = server_bound_cert_map_.begin(); 210 for (ServerBoundCertMap::iterator i = server_bound_cert_map_.begin();
195 i != server_bound_cert_map_.end(); ++i) 211 i != server_bound_cert_map_.end(); ++i)
196 cert_list.push_back(i->second); 212 cert_list.push_back(i->second);
197 completion_callback_.Run(cert_list); 213 completion_callback_.Run(cert_list);
198 } 214 }
199 215
200 void CannedBrowsingDataServerBoundCertHelper::DeleteServerBoundCert( 216 void CannedBrowsingDataServerBoundCertHelper::DeleteServerBoundCert(
201 const std::string& server_id) { 217 const std::string& server_id) {
202 NOTREACHED(); 218 NOTREACHED();
203 } 219 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_remover_unittest.cc ('k') | chrome/browser/chromeos/login/profile_auth_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698