OLD | NEW |
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/component_updater/component_updater_service.h" | 5 #include "chrome/browser/component_updater/component_updater_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 CrxUpdateItem::kUpdating); | 696 CrxUpdateItem::kUpdating); |
697 DCHECK_EQ(count, 1ul); | 697 DCHECK_EQ(count, 1ul); |
698 url_fetcher_.reset(); | 698 url_fetcher_.reset(); |
699 | 699 |
700 content::NotificationService::current()->Notify( | 700 content::NotificationService::current()->Notify( |
701 chrome::NOTIFICATION_COMPONENT_UPDATE_READY, | 701 chrome::NOTIFICATION_COMPONENT_UPDATE_READY, |
702 content::Source<std::string>(&context->id), | 702 content::Source<std::string>(&context->id), |
703 content::NotificationService::NoDetails()); | 703 content::NotificationService::NoDetails()); |
704 | 704 |
705 // Why unretained? See comment at top of file. | 705 // Why unretained? See comment at top of file. |
706 BrowserThread::PostDelayedTask(BrowserThread::FILE, FROM_HERE, | 706 BrowserThread::PostDelayedTask( |
| 707 BrowserThread::FILE, |
| 708 FROM_HERE, |
707 base::Bind(&CrxUpdateService::Install, | 709 base::Bind(&CrxUpdateService::Install, |
708 base::Unretained(this), | 710 base::Unretained(this), |
709 context, | 711 context, |
710 temp_crx_path), | 712 temp_crx_path), |
711 config_->StepDelay()); | 713 base::TimeDelta::FromMilliseconds(config_->StepDelay())); |
712 } | 714 } |
713 } | 715 } |
714 | 716 |
715 // Install consists of digital signature verification, unpacking and then | 717 // Install consists of digital signature verification, unpacking and then |
716 // calling the component specific installer. All that is handled by the | 718 // calling the component specific installer. All that is handled by the |
717 // |unpacker|. If there is an error this function is in charge of deleting | 719 // |unpacker|. If there is an error this function is in charge of deleting |
718 // the files created. | 720 // the files created. |
719 void CrxUpdateService::Install(const CRXContext* context, | 721 void CrxUpdateService::Install(const CRXContext* context, |
720 const FilePath& crx_path) { | 722 const FilePath& crx_path) { |
721 // This function owns the |crx_path| and the |context| object. | 723 // This function owns the |crx_path| and the |context| object. |
722 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 724 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
723 ComponentUnpacker | 725 ComponentUnpacker |
724 unpacker(context->pk_hash, crx_path, context->installer); | 726 unpacker(context->pk_hash, crx_path, context->installer); |
725 if (!file_util::Delete(crx_path, false)) { | 727 if (!file_util::Delete(crx_path, false)) { |
726 NOTREACHED() << crx_path.value(); | 728 NOTREACHED() << crx_path.value(); |
727 } | 729 } |
728 // Why unretained? See comment at top of file. | 730 // Why unretained? See comment at top of file. |
729 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, | 731 BrowserThread::PostDelayedTask( |
| 732 BrowserThread::UI, |
| 733 FROM_HERE, |
730 base::Bind(&CrxUpdateService::DoneInstalling, base::Unretained(this), | 734 base::Bind(&CrxUpdateService::DoneInstalling, base::Unretained(this), |
731 context->id, unpacker.error()), | 735 context->id, unpacker.error()), |
732 config_->StepDelay()); | 736 base::TimeDelta::FromMilliseconds(config_->StepDelay())); |
733 delete context; | 737 delete context; |
734 } | 738 } |
735 | 739 |
736 // Installation has been completed. Adjust the component status and | 740 // Installation has been completed. Adjust the component status and |
737 // schedule the next check. | 741 // schedule the next check. |
738 void CrxUpdateService::DoneInstalling(const std::string& component_id, | 742 void CrxUpdateService::DoneInstalling(const std::string& component_id, |
739 ComponentUnpacker::Error error) { | 743 ComponentUnpacker::Error error) { |
740 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 744 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
741 | 745 |
742 CrxUpdateItem* item = FindUpdateItemById(component_id); | 746 CrxUpdateItem* item = FindUpdateItemById(component_id); |
(...skipping 19 matching lines...) Expand all Loading... |
762 ScheduleNextRun(false); | 766 ScheduleNextRun(false); |
763 } | 767 } |
764 | 768 |
765 // The component update factory. Using the component updater as a singleton | 769 // The component update factory. Using the component updater as a singleton |
766 // is the job of the browser process. | 770 // is the job of the browser process. |
767 ComponentUpdateService* ComponentUpdateServiceFactory( | 771 ComponentUpdateService* ComponentUpdateServiceFactory( |
768 ComponentUpdateService::Configurator* config) { | 772 ComponentUpdateService::Configurator* config) { |
769 DCHECK(config); | 773 DCHECK(config); |
770 return new CrxUpdateService(config); | 774 return new CrxUpdateService(config); |
771 } | 775 } |
OLD | NEW |