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

Side by Side Diff: chrome/browser/component_updater/component_updater_service.cc

Issue 10939010: Cleanup: avoid foo ? true : false, part 1. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 8 years, 2 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/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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 91 }
92 } 92 }
93 DCHECK(Extension::IdIsValid(id)); 93 DCHECK(Extension::IdIsValid(id));
94 return id; 94 return id;
95 } 95 }
96 96
97 // Returns given a crx id it returns a small number, less than 100, that has a 97 // Returns given a crx id it returns a small number, less than 100, that has a
98 // decent chance of being unique among the registered components. It also has 98 // decent chance of being unique among the registered components. It also has
99 // the nice property that can be trivially computed by hand. 99 // the nice property that can be trivially computed by hand.
100 static int CrxIdtoUMAId(const std::string& id) { 100 static int CrxIdtoUMAId(const std::string& id) {
101 CHECK(id.size() > 2); 101 CHECK_GT(id.size(), 2U);
102 return id[0] + id[1] + id[2] - ('a' * 3); 102 return id[0] + id[1] + id[2] - ('a' * 3);
103 } 103 }
104 104
105 // Helper to do version check for components. 105 // Helper to do version check for components.
106 bool IsVersionNewer(const Version& current, const std::string& proposed) { 106 bool IsVersionNewer(const Version& current, const std::string& proposed) {
107 Version proposed_ver(proposed); 107 Version proposed_ver(proposed);
108 if (!proposed_ver.IsValid()) 108 if (!proposed_ver.IsValid())
109 return false; 109 return false;
110 return (current.CompareTo(proposed_ver) < 0); 110 return (current.CompareTo(proposed_ver) < 0);
111 } 111 }
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 } 611 }
612 } 612 }
613 613
614 // A valid Omaha update check has arrived, from only the list of components that 614 // A valid Omaha update check has arrived, from only the list of components that
615 // we are currently upgrading we check for a match in which the server side 615 // we are currently upgrading we check for a match in which the server side
616 // version is newer, if so we queue them for an upgrade. The next time we call 616 // version is newer, if so we queue them for an upgrade. The next time we call
617 // ProcessPendingItems() one of them will be drafted for the upgrade process. 617 // ProcessPendingItems() one of them will be drafted for the upgrade process.
618 void CrxUpdateService::OnParseUpdateManifestSucceeded( 618 void CrxUpdateService::OnParseUpdateManifestSucceeded(
619 const UpdateManifest::Results& results) { 619 const UpdateManifest::Results& results) {
620 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 620 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
621 int update_pending = 0; 621 size_t update_pending = 0;
622 std::vector<UpdateManifest::Result>::const_iterator it; 622 std::vector<UpdateManifest::Result>::const_iterator it;
623 for (it = results.list.begin(); it != results.list.end(); ++it) { 623 for (it = results.list.begin(); it != results.list.end(); ++it) {
624 CrxUpdateItem* crx = FindUpdateItemById(it->extension_id); 624 CrxUpdateItem* crx = FindUpdateItemById(it->extension_id);
625 if (!crx) 625 if (!crx)
626 continue; 626 continue;
627 627
628 if (crx->status != CrxUpdateItem::kChecking) 628 if (crx->status != CrxUpdateItem::kChecking)
629 continue; // Not updating this component now. 629 continue; // Not updating this component now.
630 630
631 config_->OnEvent(Configurator::kManifestCheck, CrxIdtoUMAId(crx->id)); 631 config_->OnEvent(Configurator::kManifestCheck, CrxIdtoUMAId(crx->id));
(...skipping 26 matching lines...) Expand all
658 chrome::NOTIFICATION_COMPONENT_UPDATE_FOUND, 658 chrome::NOTIFICATION_COMPONENT_UPDATE_FOUND,
659 content::Source<std::string>(&crx->id), 659 content::Source<std::string>(&crx->id),
660 content::NotificationService::NoDetails()); 660 content::NotificationService::NoDetails());
661 } 661 }
662 662
663 // All the components that are not mentioned in the manifest we 663 // All the components that are not mentioned in the manifest we
664 // consider them up to date. 664 // consider them up to date.
665 ChangeItemStatus(CrxUpdateItem::kChecking, CrxUpdateItem::kUpToDate); 665 ChangeItemStatus(CrxUpdateItem::kChecking, CrxUpdateItem::kUpToDate);
666 666
667 // If there are updates pending we do a short wait. 667 // If there are updates pending we do a short wait.
668 ScheduleNextRun(update_pending ? true : false); 668 ScheduleNextRun(update_pending > 0);
669 } 669 }
670 670
671 void CrxUpdateService::OnParseUpdateManifestFailed( 671 void CrxUpdateService::OnParseUpdateManifestFailed(
672 const std::string& error_message) { 672 const std::string& error_message) {
673 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 673 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
674 size_t count = ChangeItemStatus(CrxUpdateItem::kChecking, 674 size_t count = ChangeItemStatus(CrxUpdateItem::kChecking,
675 CrxUpdateItem::kNoUpdate); 675 CrxUpdateItem::kNoUpdate);
676 config_->OnEvent(Configurator::kManifestError, static_cast<int>(count)); 676 config_->OnEvent(Configurator::kManifestError, static_cast<int>(count));
677 DCHECK_GT(count, 0ul); 677 DCHECK_GT(count, 0ul);
678 ScheduleNextRun(false); 678 ScheduleNextRun(false);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 ScheduleNextRun(false); 770 ScheduleNextRun(false);
771 } 771 }
772 772
773 // The component update factory. Using the component updater as a singleton 773 // The component update factory. Using the component updater as a singleton
774 // is the job of the browser process. 774 // is the job of the browser process.
775 ComponentUpdateService* ComponentUpdateServiceFactory( 775 ComponentUpdateService* ComponentUpdateServiceFactory(
776 ComponentUpdateService::Configurator* config) { 776 ComponentUpdateService::Configurator* config) {
777 DCHECK(config); 777 DCHECK(config);
778 return new CrxUpdateService(config); 778 return new CrxUpdateService(config);
779 } 779 }
OLDNEW
« no previous file with comments | « base/i18n/bidi_line_iterator.cc ('k') | chrome/browser/external_protocol/external_protocol_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698