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/extensions/updater/extension_updater.h" | 5 #include "chrome/browser/extensions/updater/extension_updater.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 InProgressCheck& request = requests_in_progress_[*it]; | 566 InProgressCheck& request = requests_in_progress_[*it]; |
567 if (request.install_immediately) { | 567 if (request.install_immediately) { |
568 installer->set_install_immediately(true); | 568 installer->set_install_immediately(true); |
569 break; | 569 break; |
570 } | 570 } |
571 } | 571 } |
572 | 572 |
573 // Source parameter ensures that we only see the completion event for the | 573 // Source parameter ensures that we only see the completion event for the |
574 // the installer we started. | 574 // the installer we started. |
575 registrar_.Add(this, | 575 registrar_.Add(this, |
576 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 576 extensions::NOTIFICATION_CRX_INSTALLER_DONE, |
577 content::Source<CrxInstaller>(installer)); | 577 content::Source<CrxInstaller>(installer)); |
578 } else { | 578 } else { |
579 for (std::set<int>::const_iterator it = crx_file.request_ids.begin(); | 579 for (std::set<int>::const_iterator it = crx_file.request_ids.begin(); |
580 it != crx_file.request_ids.end(); ++it) { | 580 it != crx_file.request_ids.end(); ++it) { |
581 InProgressCheck& request = requests_in_progress_[*it]; | 581 InProgressCheck& request = requests_in_progress_[*it]; |
582 request.in_progress_ids_.remove(crx_file.extension_id); | 582 request.in_progress_ids_.remove(crx_file.extension_id); |
583 } | 583 } |
584 request_ids.insert(crx_file.request_ids.begin(), | 584 request_ids.insert(crx_file.request_ids.begin(), |
585 crx_file.request_ids.end()); | 585 crx_file.request_ids.end()); |
586 } | 586 } |
587 fetched_crx_files_.pop(); | 587 fetched_crx_files_.pop(); |
588 } | 588 } |
589 | 589 |
590 for (std::set<int>::const_iterator it = request_ids.begin(); | 590 for (std::set<int>::const_iterator it = request_ids.begin(); |
591 it != request_ids.end(); ++it) { | 591 it != request_ids.end(); ++it) { |
592 NotifyIfFinished(*it); | 592 NotifyIfFinished(*it); |
593 } | 593 } |
594 } | 594 } |
595 | 595 |
596 void ExtensionUpdater::Observe(int type, | 596 void ExtensionUpdater::Observe(int type, |
597 const content::NotificationSource& source, | 597 const content::NotificationSource& source, |
598 const content::NotificationDetails& details) { | 598 const content::NotificationDetails& details) { |
599 DCHECK_EQ(type, chrome::NOTIFICATION_CRX_INSTALLER_DONE); | 599 DCHECK_EQ(type, extensions::NOTIFICATION_CRX_INSTALLER_DONE); |
600 | 600 |
601 registrar_.Remove(this, | 601 registrar_.Remove(this, extensions::NOTIFICATION_CRX_INSTALLER_DONE, source); |
602 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | |
603 source); | |
604 crx_install_is_running_ = false; | 602 crx_install_is_running_ = false; |
605 | 603 |
606 const FetchedCRXFile& crx_file = current_crx_file_; | 604 const FetchedCRXFile& crx_file = current_crx_file_; |
607 for (std::set<int>::const_iterator it = crx_file.request_ids.begin(); | 605 for (std::set<int>::const_iterator it = crx_file.request_ids.begin(); |
608 it != crx_file.request_ids.end(); ++it) { | 606 it != crx_file.request_ids.end(); ++it) { |
609 InProgressCheck& request = requests_in_progress_[*it]; | 607 InProgressCheck& request = requests_in_progress_[*it]; |
610 request.in_progress_ids_.remove(crx_file.extension_id); | 608 request.in_progress_ids_.remove(crx_file.extension_id); |
611 NotifyIfFinished(*it); | 609 NotifyIfFinished(*it); |
612 } | 610 } |
613 | 611 |
614 // If any files are available to update, start one. | 612 // If any files are available to update, start one. |
615 MaybeInstallCRXFile(); | 613 MaybeInstallCRXFile(); |
616 } | 614 } |
617 | 615 |
618 void ExtensionUpdater::OnExtensionWillBeInstalled( | 616 void ExtensionUpdater::OnExtensionWillBeInstalled( |
619 content::BrowserContext* browser_context, | 617 content::BrowserContext* browser_context, |
620 const Extension* extension, | 618 const Extension* extension, |
621 bool is_update, | 619 bool is_update, |
622 bool from_ephemeral, | 620 bool from_ephemeral, |
623 const std::string& old_name) { | 621 const std::string& old_name) { |
624 throttle_info_.erase(extension->id()); | 622 throttle_info_.erase(extension->id()); |
625 } | 623 } |
626 | 624 |
627 void ExtensionUpdater::NotifyStarted() { | 625 void ExtensionUpdater::NotifyStarted() { |
628 content::NotificationService::current()->Notify( | 626 content::NotificationService::current()->Notify( |
629 chrome::NOTIFICATION_EXTENSION_UPDATING_STARTED, | 627 extensions::NOTIFICATION_EXTENSION_UPDATING_STARTED, |
630 content::Source<Profile>(profile_), | 628 content::Source<Profile>(profile_), |
631 content::NotificationService::NoDetails()); | 629 content::NotificationService::NoDetails()); |
632 } | 630 } |
633 | 631 |
634 void ExtensionUpdater::NotifyIfFinished(int request_id) { | 632 void ExtensionUpdater::NotifyIfFinished(int request_id) { |
635 DCHECK(ContainsKey(requests_in_progress_, request_id)); | 633 DCHECK(ContainsKey(requests_in_progress_, request_id)); |
636 const InProgressCheck& request = requests_in_progress_[request_id]; | 634 const InProgressCheck& request = requests_in_progress_[request_id]; |
637 if (request.in_progress_ids_.empty()) { | 635 if (request.in_progress_ids_.empty()) { |
638 VLOG(2) << "Finished update check " << request_id; | 636 VLOG(2) << "Finished update check " << request_id; |
639 if (!request.callback.is_null()) | 637 if (!request.callback.is_null()) |
640 request.callback.Run(); | 638 request.callback.Run(); |
641 requests_in_progress_.erase(request_id); | 639 requests_in_progress_.erase(request_id); |
642 } | 640 } |
643 } | 641 } |
644 | 642 |
645 } // namespace extensions | 643 } // namespace extensions |
OLD | NEW |