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

Side by Side Diff: chrome/browser/net/sqlite_server_bound_cert_store.cc

Issue 10171014: Changed to Reset(bool clear_bound_vars) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix mac build error. Created 8 years, 8 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/net/sqlite_server_bound_cert_store.h" 5 #include "chrome/browser/net/sqlite_server_bound_cert_store.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 while (smt.Step()) { 276 while (smt.Step()) {
277 std::string origin = smt.ColumnString(0); 277 std::string origin = smt.ColumnString(0);
278 std::string cert_from_db; 278 std::string cert_from_db;
279 smt.ColumnBlobAsString(1, &cert_from_db); 279 smt.ColumnBlobAsString(1, &cert_from_db);
280 // Parse the cert and extract the real value and then update the DB. 280 // Parse the cert and extract the real value and then update the DB.
281 scoped_refptr<net::X509Certificate> cert( 281 scoped_refptr<net::X509Certificate> cert(
282 net::X509Certificate::CreateFromBytes( 282 net::X509Certificate::CreateFromBytes(
283 cert_from_db.data(), cert_from_db.size())); 283 cert_from_db.data(), cert_from_db.size()));
284 if (cert) { 284 if (cert) {
285 if (cur_version == 2) { 285 if (cur_version == 2) {
286 update_expires_smt.Reset(); 286 update_expires_smt.Reset(true);
287 update_expires_smt.BindInt64(0, 287 update_expires_smt.BindInt64(0,
288 cert->valid_expiry().ToInternalValue()); 288 cert->valid_expiry().ToInternalValue());
289 update_expires_smt.BindString(1, origin); 289 update_expires_smt.BindString(1, origin);
290 if (!update_expires_smt.Run()) { 290 if (!update_expires_smt.Run()) {
291 LOG(WARNING) << "Unable to update server bound cert database to " 291 LOG(WARNING) << "Unable to update server bound cert database to "
292 << "version 4."; 292 << "version 4.";
293 return false; 293 return false;
294 } 294 }
295 } 295 }
296 296
297 update_creation_smt.Reset(); 297 update_creation_smt.Reset(true);
298 update_creation_smt.BindInt64(0, cert->valid_start().ToInternalValue()); 298 update_creation_smt.BindInt64(0, cert->valid_start().ToInternalValue());
299 update_creation_smt.BindString(1, origin); 299 update_creation_smt.BindString(1, origin);
300 if (!update_creation_smt.Run()) { 300 if (!update_creation_smt.Run()) {
301 LOG(WARNING) << "Unable to update server bound cert database to " 301 LOG(WARNING) << "Unable to update server bound cert database to "
302 << "version 4."; 302 << "version 4.";
303 return false; 303 return false;
304 } 304 }
305 } else { 305 } else {
306 // If there's a cert we can't parse, just leave it. It'll get replaced 306 // If there's a cert we can't parse, just leave it. It'll get replaced
307 // with a new one if we ever try to use it. 307 // with a new one if we ever try to use it.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 sql::Transaction transaction(db_.get()); 399 sql::Transaction transaction(db_.get());
400 if (!transaction.Begin()) 400 if (!transaction.Begin())
401 return; 401 return;
402 402
403 for (PendingOperationsList::iterator it = ops.begin(); 403 for (PendingOperationsList::iterator it = ops.begin();
404 it != ops.end(); ++it) { 404 it != ops.end(); ++it) {
405 // Free the certs as we commit them to the database. 405 // Free the certs as we commit them to the database.
406 scoped_ptr<PendingOperation> po(*it); 406 scoped_ptr<PendingOperation> po(*it);
407 switch (po->op()) { 407 switch (po->op()) {
408 case PendingOperation::CERT_ADD: { 408 case PendingOperation::CERT_ADD: {
409 add_smt.Reset(); 409 add_smt.Reset(true);
410 add_smt.BindString(0, po->cert().server_identifier()); 410 add_smt.BindString(0, po->cert().server_identifier());
411 const std::string& private_key = po->cert().private_key(); 411 const std::string& private_key = po->cert().private_key();
412 add_smt.BindBlob(1, private_key.data(), private_key.size()); 412 add_smt.BindBlob(1, private_key.data(), private_key.size());
413 const std::string& cert = po->cert().cert(); 413 const std::string& cert = po->cert().cert();
414 add_smt.BindBlob(2, cert.data(), cert.size()); 414 add_smt.BindBlob(2, cert.data(), cert.size());
415 add_smt.BindInt(3, po->cert().type()); 415 add_smt.BindInt(3, po->cert().type());
416 add_smt.BindInt64(4, po->cert().expiration_time().ToInternalValue()); 416 add_smt.BindInt64(4, po->cert().expiration_time().ToInternalValue());
417 add_smt.BindInt64(5, po->cert().creation_time().ToInternalValue()); 417 add_smt.BindInt64(5, po->cert().creation_time().ToInternalValue());
418 if (!add_smt.Run()) 418 if (!add_smt.Run())
419 NOTREACHED() << "Could not add a server bound cert to the DB."; 419 NOTREACHED() << "Could not add a server bound cert to the DB.";
420 break; 420 break;
421 } 421 }
422 case PendingOperation::CERT_DELETE: 422 case PendingOperation::CERT_DELETE:
423 del_smt.Reset(); 423 del_smt.Reset(true);
424 del_smt.BindString(0, po->cert().server_identifier()); 424 del_smt.BindString(0, po->cert().server_identifier());
425 if (!del_smt.Run()) 425 if (!del_smt.Run())
426 NOTREACHED() << "Could not delete a server bound cert from the DB."; 426 NOTREACHED() << "Could not delete a server bound cert from the DB.";
427 break; 427 break;
428 428
429 default: 429 default:
430 NOTREACHED(); 430 NOTREACHED();
431 break; 431 break;
432 } 432 }
433 } 433 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 if (backend_.get()) 510 if (backend_.get())
511 backend_->SetClearLocalStateOnExit(clear_local_state); 511 backend_->SetClearLocalStateOnExit(clear_local_state);
512 } 512 }
513 513
514 void SQLiteServerBoundCertStore::Flush(const base::Closure& completion_task) { 514 void SQLiteServerBoundCertStore::Flush(const base::Closure& completion_task) {
515 if (backend_.get()) 515 if (backend_.get())
516 backend_->Flush(completion_task); 516 backend_->Flush(completion_task);
517 else if (!completion_task.is_null()) 517 else if (!completion_task.is_null())
518 MessageLoop::current()->PostTask(FROM_HERE, completion_task); 518 MessageLoop::current()->PostTask(FROM_HERE, completion_task);
519 } 519 }
OLDNEW
« no previous file with comments | « chrome/browser/net/sqlite_persistent_cookie_store.cc ('k') | chrome/browser/webdata/autofill_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698