| 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 "chrome/browser/chromeos/platform_keys/platform_keys_service.h" | 5 #include "chrome/browser/chromeos/platform_keys/platform_keys_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 void PlatformKeysService::SetSelectDelegate( | 569 void PlatformKeysService::SetSelectDelegate( |
| 570 std::unique_ptr<SelectDelegate> delegate) { | 570 std::unique_ptr<SelectDelegate> delegate) { |
| 571 select_delegate_ = std::move(delegate); | 571 select_delegate_ = std::move(delegate); |
| 572 } | 572 } |
| 573 | 573 |
| 574 void PlatformKeysService::GenerateRSAKey(const std::string& token_id, | 574 void PlatformKeysService::GenerateRSAKey(const std::string& token_id, |
| 575 unsigned int modulus_length, | 575 unsigned int modulus_length, |
| 576 const std::string& extension_id, | 576 const std::string& extension_id, |
| 577 const GenerateKeyCallback& callback) { | 577 const GenerateKeyCallback& callback) { |
| 578 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 578 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 579 StartOrQueueTask(base::WrapUnique( | 579 StartOrQueueTask(base::MakeUnique<GenerateRSAKeyTask>( |
| 580 new GenerateRSAKeyTask(token_id, modulus_length, extension_id, callback, | 580 token_id, modulus_length, extension_id, callback, &key_permissions_, this, |
| 581 &key_permissions_, this, browser_context_))); | 581 browser_context_)); |
| 582 } | 582 } |
| 583 | 583 |
| 584 void PlatformKeysService::SignRSAPKCS1Digest( | 584 void PlatformKeysService::SignRSAPKCS1Digest( |
| 585 const std::string& token_id, | 585 const std::string& token_id, |
| 586 const std::string& data, | 586 const std::string& data, |
| 587 const std::string& public_key, | 587 const std::string& public_key, |
| 588 platform_keys::HashAlgorithm hash_algorithm, | 588 platform_keys::HashAlgorithm hash_algorithm, |
| 589 const std::string& extension_id, | 589 const std::string& extension_id, |
| 590 const SignCallback& callback) { | 590 const SignCallback& callback) { |
| 591 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 591 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 607 } | 607 } |
| 608 | 608 |
| 609 void PlatformKeysService::SelectClientCertificates( | 609 void PlatformKeysService::SelectClientCertificates( |
| 610 const platform_keys::ClientCertificateRequest& request, | 610 const platform_keys::ClientCertificateRequest& request, |
| 611 std::unique_ptr<net::CertificateList> client_certificates, | 611 std::unique_ptr<net::CertificateList> client_certificates, |
| 612 bool interactive, | 612 bool interactive, |
| 613 const std::string& extension_id, | 613 const std::string& extension_id, |
| 614 const SelectCertificatesCallback& callback, | 614 const SelectCertificatesCallback& callback, |
| 615 content::WebContents* web_contents) { | 615 content::WebContents* web_contents) { |
| 616 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 616 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 617 StartOrQueueTask(base::WrapUnique(new SelectTask( | 617 StartOrQueueTask(base::MakeUnique<SelectTask>( |
| 618 request, std::move(client_certificates), interactive, extension_id, | 618 request, std::move(client_certificates), interactive, extension_id, |
| 619 callback, web_contents, &key_permissions_, this))); | 619 callback, web_contents, &key_permissions_, this)); |
| 620 } | 620 } |
| 621 | 621 |
| 622 void PlatformKeysService::StartOrQueueTask(std::unique_ptr<Task> task) { | 622 void PlatformKeysService::StartOrQueueTask(std::unique_ptr<Task> task) { |
| 623 tasks_.push(make_linked_ptr(task.release())); | 623 tasks_.push(make_linked_ptr(task.release())); |
| 624 if (tasks_.size() == 1) | 624 if (tasks_.size() == 1) |
| 625 tasks_.front()->Start(); | 625 tasks_.front()->Start(); |
| 626 } | 626 } |
| 627 | 627 |
| 628 void PlatformKeysService::TaskFinished(Task* task) { | 628 void PlatformKeysService::TaskFinished(Task* task) { |
| 629 DCHECK(!tasks_.empty()); | 629 DCHECK(!tasks_.empty()); |
| 630 DCHECK(task == tasks_.front().get()); | 630 DCHECK(task == tasks_.front().get()); |
| 631 // Remove all finished tasks from the queue (should be at most one). | 631 // Remove all finished tasks from the queue (should be at most one). |
| 632 while (!tasks_.empty() && tasks_.front()->IsDone()) | 632 while (!tasks_.empty() && tasks_.front()->IsDone()) |
| 633 tasks_.pop(); | 633 tasks_.pop(); |
| 634 | 634 |
| 635 // Now either the queue is empty or the next task is not finished yet and it | 635 // Now either the queue is empty or the next task is not finished yet and it |
| 636 // can be started. | 636 // can be started. |
| 637 if (!tasks_.empty()) | 637 if (!tasks_.empty()) |
| 638 tasks_.front()->Start(); | 638 tasks_.front()->Start(); |
| 639 } | 639 } |
| 640 | 640 |
| 641 } // namespace chromeos | 641 } // namespace chromeos |
| OLD | NEW |