| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "net/ssl/default_channel_id_store.h" | 5 #include "net/ssl/default_channel_id_store.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "crypto/ec_private_key.h" | 10 #include "crypto/ec_private_key.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 void DefaultChannelIDStore::InitStore() { | 295 void DefaultChannelIDStore::InitStore() { |
| 296 DCHECK(CalledOnValidThread()); | 296 DCHECK(CalledOnValidThread()); |
| 297 DCHECK(store_.get()) << "Store must exist to initialize"; | 297 DCHECK(store_.get()) << "Store must exist to initialize"; |
| 298 DCHECK(!loaded_); | 298 DCHECK(!loaded_); |
| 299 | 299 |
| 300 store_->Load(base::Bind(&DefaultChannelIDStore::OnLoaded, | 300 store_->Load(base::Bind(&DefaultChannelIDStore::OnLoaded, |
| 301 weak_ptr_factory_.GetWeakPtr())); | 301 weak_ptr_factory_.GetWeakPtr())); |
| 302 } | 302 } |
| 303 | 303 |
| 304 void DefaultChannelIDStore::OnLoaded( | 304 void DefaultChannelIDStore::OnLoaded( |
| 305 scoped_ptr<ScopedVector<ChannelID> > channel_ids) { | 305 scoped_ptr<std::vector<scoped_ptr<ChannelID>>> channel_ids) { |
| 306 DCHECK(CalledOnValidThread()); | 306 DCHECK(CalledOnValidThread()); |
| 307 | 307 for (std::vector<scoped_ptr<ChannelID>>::iterator it = channel_ids->begin(); |
| 308 for (std::vector<ChannelID*>::const_iterator it = channel_ids->begin(); | |
| 309 it != channel_ids->end(); ++it) { | 308 it != channel_ids->end(); ++it) { |
| 310 DCHECK(channel_ids_.find((*it)->server_identifier()) == | 309 DCHECK(channel_ids_.find((*it)->server_identifier()) == |
| 311 channel_ids_.end()); | 310 channel_ids_.end()); |
| 312 channel_ids_[(*it)->server_identifier()] = *it; | 311 std::string ident = (*it)->server_identifier(); |
| 312 channel_ids_[ident] = it->release(); |
| 313 } | 313 } |
| 314 channel_ids->weak_clear(); | 314 channel_ids->clear(); |
| 315 | 315 |
| 316 loaded_ = true; | 316 loaded_ = true; |
| 317 | 317 |
| 318 base::TimeDelta wait_time; | 318 base::TimeDelta wait_time; |
| 319 if (!waiting_tasks_.empty()) | 319 if (!waiting_tasks_.empty()) |
| 320 wait_time = base::TimeTicks::Now() - waiting_tasks_start_time_; | 320 wait_time = base::TimeTicks::Now() - waiting_tasks_start_time_; |
| 321 DVLOG(1) << "Task delay " << wait_time.InMilliseconds(); | 321 DVLOG(1) << "Task delay " << wait_time.InMilliseconds(); |
| 322 UMA_HISTOGRAM_CUSTOM_TIMES("DomainBoundCerts.TaskMaxWaitTime", | 322 UMA_HISTOGRAM_CUSTOM_TIMES("DomainBoundCerts.TaskMaxWaitTime", |
| 323 wait_time, | 323 wait_time, |
| 324 base::TimeDelta::FromMilliseconds(1), | 324 base::TimeDelta::FromMilliseconds(1), |
| 325 base::TimeDelta::FromMinutes(1), | 325 base::TimeDelta::FromMinutes(1), |
| 326 50); | 326 50); |
| 327 UMA_HISTOGRAM_COUNTS_100("DomainBoundCerts.TaskWaitCount", | 327 UMA_HISTOGRAM_COUNTS_100("DomainBoundCerts.TaskWaitCount", |
| 328 waiting_tasks_.size()); | 328 waiting_tasks_.size()); |
| 329 | 329 |
| 330 | 330 for (scoped_ptr<Task>& i : waiting_tasks_) |
| 331 for (ScopedVector<Task>::iterator i = waiting_tasks_.begin(); | 331 i->Run(this); |
| 332 i != waiting_tasks_.end(); ++i) | |
| 333 (*i)->Run(this); | |
| 334 waiting_tasks_.clear(); | 332 waiting_tasks_.clear(); |
| 335 } | 333 } |
| 336 | 334 |
| 337 void DefaultChannelIDStore::SyncSetChannelID(scoped_ptr<ChannelID> channel_id) { | 335 void DefaultChannelIDStore::SyncSetChannelID(scoped_ptr<ChannelID> channel_id) { |
| 338 DCHECK(CalledOnValidThread()); | 336 DCHECK(CalledOnValidThread()); |
| 339 DCHECK(loaded_); | 337 DCHECK(loaded_); |
| 340 | 338 |
| 341 InternalDeleteChannelID(channel_id->server_identifier()); | 339 InternalDeleteChannelID(channel_id->server_identifier()); |
| 342 InternalInsertChannelID(channel_id.Pass()); | 340 InternalInsertChannelID(channel_id.Pass()); |
| 343 } | 341 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 store_->AddChannelID(*(channel_id.get())); | 422 store_->AddChannelID(*(channel_id.get())); |
| 425 const std::string& server_identifier = channel_id->server_identifier(); | 423 const std::string& server_identifier = channel_id->server_identifier(); |
| 426 channel_ids_[server_identifier] = channel_id.release(); | 424 channel_ids_[server_identifier] = channel_id.release(); |
| 427 } | 425 } |
| 428 | 426 |
| 429 DefaultChannelIDStore::PersistentStore::PersistentStore() {} | 427 DefaultChannelIDStore::PersistentStore::PersistentStore() {} |
| 430 | 428 |
| 431 DefaultChannelIDStore::PersistentStore::~PersistentStore() {} | 429 DefaultChannelIDStore::PersistentStore::~PersistentStore() {} |
| 432 | 430 |
| 433 } // namespace net | 431 } // namespace net |
| OLD | NEW |