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

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

Issue 356713005: Rename ServerBoundCert => ChannelID to reflect the current name (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix cookies_list.js Created 6 years, 5 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_channel_id_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/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "net/ssl/server_bound_cert_service.h" 13 #include "net/ssl/channel_id_service.h"
14 #include "net/url_request/url_request_context.h" 14 #include "net/url_request/url_request_context.h"
15 #include "net/url_request/url_request_context_getter.h" 15 #include "net/url_request/url_request_context_getter.h"
16 16
17 namespace { 17 namespace {
18 18
19 class BrowsingDataServerBoundCertHelperImpl 19 class BrowsingDataChannelIDHelperImpl
20 : public BrowsingDataServerBoundCertHelper { 20 : public BrowsingDataChannelIDHelper {
21 public: 21 public:
22 explicit BrowsingDataServerBoundCertHelperImpl(Profile* profile); 22 explicit BrowsingDataChannelIDHelperImpl(Profile* profile);
23 23
24 // BrowsingDataServerBoundCertHelper methods. 24 // BrowsingDataChannelIDHelper 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 DeleteChannelID(const std::string& server_id) OVERRIDE;
27 27
28 private: 28 private:
29 virtual ~BrowsingDataServerBoundCertHelperImpl(); 29 virtual ~BrowsingDataChannelIDHelperImpl();
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( 34 void OnFetchComplete(
35 const net::ServerBoundCertStore::ServerBoundCertList& cert_list); 35 const net::ChannelIDStore::ChannelIDList& channel_id_list);
36 36
37 // 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.
38 void NotifyInUIThread( 38 void NotifyInUIThread(
39 const net::ServerBoundCertStore::ServerBoundCertList& cert_list); 39 const net::ChannelIDStore::ChannelIDList& channel_id_list);
40 40
41 // Delete a single cert. This must be called in IO thread. 41 // Delete a single cert. This must be called in IO thread.
42 void DeleteOnIOThread(const std::string& server_id); 42 void DeleteOnIOThread(const std::string& server_id);
43 43
44 // Called when deletion is done. 44 // Called when deletion is done.
45 void DeleteCallback(); 45 void DeleteCallback();
46 46
47 // Indicates whether or not we're currently fetching information: 47 // Indicates whether or not we're currently fetching information:
48 // 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
49 // after we notify the callback in the UI thread. 49 // after we notify the callback in the UI thread.
50 // This only mutates on the UI thread. 50 // This only mutates on the UI thread.
51 bool is_fetching_; 51 bool is_fetching_;
52 52
53 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 53 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
54 54
55 // This only mutates on the UI thread. 55 // This only mutates on the UI thread.
56 FetchResultCallback completion_callback_; 56 FetchResultCallback completion_callback_;
57 57
58 DISALLOW_COPY_AND_ASSIGN(BrowsingDataServerBoundCertHelperImpl); 58 DISALLOW_COPY_AND_ASSIGN(BrowsingDataChannelIDHelperImpl);
59 }; 59 };
60 60
61 BrowsingDataServerBoundCertHelperImpl:: 61 BrowsingDataChannelIDHelperImpl::
62 BrowsingDataServerBoundCertHelperImpl(Profile* profile) 62 BrowsingDataChannelIDHelperImpl(Profile* profile)
63 : is_fetching_(false), 63 : is_fetching_(false),
64 request_context_getter_(profile->GetRequestContext()) { 64 request_context_getter_(profile->GetRequestContext()) {
65 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 65 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
66 } 66 }
67 67
68 BrowsingDataServerBoundCertHelperImpl:: 68 BrowsingDataChannelIDHelperImpl::
69 ~BrowsingDataServerBoundCertHelperImpl() { 69 ~BrowsingDataChannelIDHelperImpl() {
70 } 70 }
71 71
72 void BrowsingDataServerBoundCertHelperImpl::StartFetching( 72 void BrowsingDataChannelIDHelperImpl::StartFetching(
73 const FetchResultCallback& callback) { 73 const FetchResultCallback& callback) {
74 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 74 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
75 DCHECK(!is_fetching_); 75 DCHECK(!is_fetching_);
76 DCHECK(!callback.is_null()); 76 DCHECK(!callback.is_null());
77 DCHECK(completion_callback_.is_null()); 77 DCHECK(completion_callback_.is_null());
78 is_fetching_ = true; 78 is_fetching_ = true;
79 completion_callback_ = callback; 79 completion_callback_ = callback;
80 content::BrowserThread::PostTask( 80 content::BrowserThread::PostTask(
81 content::BrowserThread::IO, FROM_HERE, 81 content::BrowserThread::IO, FROM_HERE,
82 base::Bind(&BrowsingDataServerBoundCertHelperImpl::FetchOnIOThread, 82 base::Bind(&BrowsingDataChannelIDHelperImpl::FetchOnIOThread,
83 this)); 83 this));
84 } 84 }
85 85
86 void BrowsingDataServerBoundCertHelperImpl::DeleteServerBoundCert( 86 void BrowsingDataChannelIDHelperImpl::DeleteChannelID(
87 const std::string& server_id) { 87 const std::string& server_id) {
88 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 88 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
89 content::BrowserThread::PostTask( 89 content::BrowserThread::PostTask(
90 content::BrowserThread::IO, FROM_HERE, 90 content::BrowserThread::IO, FROM_HERE,
91 base::Bind(&BrowsingDataServerBoundCertHelperImpl::DeleteOnIOThread, 91 base::Bind(&BrowsingDataChannelIDHelperImpl::DeleteOnIOThread,
92 this, server_id)); 92 this, server_id));
93 } 93 }
94 94
95 void BrowsingDataServerBoundCertHelperImpl::FetchOnIOThread() { 95 void BrowsingDataChannelIDHelperImpl::FetchOnIOThread() {
96 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 96 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
97 net::ServerBoundCertStore* cert_store = 97 net::ChannelIDStore* cert_store =
98 request_context_getter_->GetURLRequestContext()-> 98 request_context_getter_->GetURLRequestContext()->
99 server_bound_cert_service()->GetCertStore(); 99 channel_id_service()->GetChannelIDStore();
100 if (cert_store) { 100 if (cert_store) {
101 cert_store->GetAllServerBoundCerts(base::Bind( 101 cert_store->GetAllChannelIDs(base::Bind(
102 &BrowsingDataServerBoundCertHelperImpl::OnFetchComplete, this)); 102 &BrowsingDataChannelIDHelperImpl::OnFetchComplete, this));
103 } else { 103 } else {
104 OnFetchComplete(net::ServerBoundCertStore::ServerBoundCertList()); 104 OnFetchComplete(net::ChannelIDStore::ChannelIDList());
105 } 105 }
106 } 106 }
107 107
108 void BrowsingDataServerBoundCertHelperImpl::OnFetchComplete( 108 void BrowsingDataChannelIDHelperImpl::OnFetchComplete(
109 const net::ServerBoundCertStore::ServerBoundCertList& cert_list) { 109 const net::ChannelIDStore::ChannelIDList& channel_id_list) {
110 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 110 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
111 content::BrowserThread::PostTask( 111 content::BrowserThread::PostTask(
112 content::BrowserThread::UI, FROM_HERE, 112 content::BrowserThread::UI, FROM_HERE,
113 base::Bind(&BrowsingDataServerBoundCertHelperImpl::NotifyInUIThread, 113 base::Bind(&BrowsingDataChannelIDHelperImpl::NotifyInUIThread,
114 this, cert_list)); 114 this, channel_id_list));
115 } 115 }
116 116
117 void BrowsingDataServerBoundCertHelperImpl::NotifyInUIThread( 117 void BrowsingDataChannelIDHelperImpl::NotifyInUIThread(
118 const net::ServerBoundCertStore::ServerBoundCertList& cert_list) { 118 const net::ChannelIDStore::ChannelIDList& channel_id_list) {
119 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 119 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
120 DCHECK(is_fetching_); 120 DCHECK(is_fetching_);
121 is_fetching_ = false; 121 is_fetching_ = false;
122 completion_callback_.Run(cert_list); 122 completion_callback_.Run(channel_id_list);
123 completion_callback_.Reset(); 123 completion_callback_.Reset();
124 } 124 }
125 125
126 void BrowsingDataServerBoundCertHelperImpl::DeleteOnIOThread( 126 void BrowsingDataChannelIDHelperImpl::DeleteOnIOThread(
127 const std::string& server_id) { 127 const std::string& server_id) {
128 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 128 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
129 net::ServerBoundCertStore* cert_store = 129 net::ChannelIDStore* cert_store =
130 request_context_getter_->GetURLRequestContext()-> 130 request_context_getter_->GetURLRequestContext()->
131 server_bound_cert_service()->GetCertStore(); 131 channel_id_service()->GetChannelIDStore();
132 if (cert_store) { 132 if (cert_store) {
133 cert_store->DeleteServerBoundCert( 133 cert_store->DeleteChannelID(
134 server_id, 134 server_id,
135 base::Bind(&BrowsingDataServerBoundCertHelperImpl::DeleteCallback, 135 base::Bind(&BrowsingDataChannelIDHelperImpl::DeleteCallback,
136 this)); 136 this));
137 } 137 }
138 } 138 }
139 139
140 void BrowsingDataServerBoundCertHelperImpl::DeleteCallback() { 140 void BrowsingDataChannelIDHelperImpl::DeleteCallback() {
141 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 141 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
142 // Need to close open SSL connections which may be using the channel ids we 142 // Need to close open SSL connections which may be using the channel ids we
143 // are deleting. 143 // are deleting.
144 // TODO(mattm): http://crbug.com/166069 Make the server bound cert 144 // TODO(mattm): http://crbug.com/166069 Make the server bound cert
145 // service/store have observers that can notify relevant things directly. 145 // service/store have observers that can notify relevant things directly.
146 request_context_getter_->GetURLRequestContext()->ssl_config_service()-> 146 request_context_getter_->GetURLRequestContext()->ssl_config_service()->
147 NotifySSLConfigChange(); 147 NotifySSLConfigChange();
148 } 148 }
149 149
150 } // namespace 150 } // namespace
151 151
152 // static 152 // static
153 BrowsingDataServerBoundCertHelper* 153 BrowsingDataChannelIDHelper*
154 BrowsingDataServerBoundCertHelper::Create(Profile* profile) { 154 BrowsingDataChannelIDHelper::Create(Profile* profile) {
155 return new BrowsingDataServerBoundCertHelperImpl(profile); 155 return new BrowsingDataChannelIDHelperImpl(profile);
156 } 156 }
157 157
158 CannedBrowsingDataServerBoundCertHelper:: 158 CannedBrowsingDataChannelIDHelper::
159 CannedBrowsingDataServerBoundCertHelper() {} 159 CannedBrowsingDataChannelIDHelper() {}
160 160
161 CannedBrowsingDataServerBoundCertHelper:: 161 CannedBrowsingDataChannelIDHelper::
162 ~CannedBrowsingDataServerBoundCertHelper() {} 162 ~CannedBrowsingDataChannelIDHelper() {}
163 163
164 CannedBrowsingDataServerBoundCertHelper* 164 CannedBrowsingDataChannelIDHelper*
165 CannedBrowsingDataServerBoundCertHelper::Clone() { 165 CannedBrowsingDataChannelIDHelper::Clone() {
166 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 166 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
167 CannedBrowsingDataServerBoundCertHelper* clone = 167 CannedBrowsingDataChannelIDHelper* clone =
168 new CannedBrowsingDataServerBoundCertHelper(); 168 new CannedBrowsingDataChannelIDHelper();
169 169
170 clone->server_bound_cert_map_ = server_bound_cert_map_; 170 clone->channel_id_map_ = channel_id_map_;
171 return clone; 171 return clone;
172 } 172 }
173 173
174 void CannedBrowsingDataServerBoundCertHelper::AddServerBoundCert( 174 void CannedBrowsingDataChannelIDHelper::AddChannelID(
175 const net::ServerBoundCertStore::ServerBoundCert& server_bound_cert) { 175 const net::ChannelIDStore::ChannelID& channel_id) {
176 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 176 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
177 server_bound_cert_map_[server_bound_cert.server_identifier()] = 177 channel_id_map_[channel_id.server_identifier()] =
178 server_bound_cert; 178 channel_id;
179 } 179 }
180 180
181 void CannedBrowsingDataServerBoundCertHelper::Reset() { 181 void CannedBrowsingDataChannelIDHelper::Reset() {
182 server_bound_cert_map_.clear(); 182 channel_id_map_.clear();
183 } 183 }
184 184
185 bool CannedBrowsingDataServerBoundCertHelper::empty() const { 185 bool CannedBrowsingDataChannelIDHelper::empty() const {
186 return server_bound_cert_map_.empty(); 186 return channel_id_map_.empty();
187 } 187 }
188 188
189 size_t CannedBrowsingDataServerBoundCertHelper::GetCertCount() const { 189 size_t CannedBrowsingDataChannelIDHelper::GetChannelIDCount() const {
190 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 190 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
191 return server_bound_cert_map_.size(); 191 return channel_id_map_.size();
192 } 192 }
193 193
194 void CannedBrowsingDataServerBoundCertHelper::StartFetching( 194 void CannedBrowsingDataChannelIDHelper::StartFetching(
195 const FetchResultCallback& callback) { 195 const FetchResultCallback& callback) {
196 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 196 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
197 if (callback.is_null()) 197 if (callback.is_null())
198 return; 198 return;
199 // We post a task to emulate async fetching behavior. 199 // We post a task to emulate async fetching behavior.
200 completion_callback_ = callback; 200 completion_callback_ = callback;
201 base::MessageLoop::current()->PostTask( 201 base::MessageLoop::current()->PostTask(
202 FROM_HERE, 202 FROM_HERE,
203 base::Bind(&CannedBrowsingDataServerBoundCertHelper::FinishFetching, 203 base::Bind(&CannedBrowsingDataChannelIDHelper::FinishFetching,
204 this)); 204 this));
205 } 205 }
206 206
207 void CannedBrowsingDataServerBoundCertHelper::FinishFetching() { 207 void CannedBrowsingDataChannelIDHelper::FinishFetching() {
208 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 208 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
209 net::ServerBoundCertStore::ServerBoundCertList cert_list; 209 net::ChannelIDStore::ChannelIDList channel_id_list;
210 for (ServerBoundCertMap::iterator i = server_bound_cert_map_.begin(); 210 for (ChannelIDMap::iterator i = channel_id_map_.begin();
211 i != server_bound_cert_map_.end(); ++i) 211 i != channel_id_map_.end(); ++i)
212 cert_list.push_back(i->second); 212 channel_id_list.push_back(i->second);
213 completion_callback_.Run(cert_list); 213 completion_callback_.Run(channel_id_list);
214 } 214 }
215 215
216 void CannedBrowsingDataServerBoundCertHelper::DeleteServerBoundCert( 216 void CannedBrowsingDataChannelIDHelper::DeleteChannelID(
217 const std::string& server_id) { 217 const std::string& server_id) {
218 NOTREACHED(); 218 NOTREACHED();
219 } 219 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698