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

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

Issue 12184029: Make pnacl install on demand when it is not already installed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: forward decl Created 7 years, 10 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 <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 public: 248 public:
249 explicit CrxUpdateService(ComponentUpdateService::Configurator* config); 249 explicit CrxUpdateService(ComponentUpdateService::Configurator* config);
250 250
251 virtual ~CrxUpdateService(); 251 virtual ~CrxUpdateService();
252 252
253 // Overrides for ComponentUpdateService. 253 // Overrides for ComponentUpdateService.
254 virtual Status Start() OVERRIDE; 254 virtual Status Start() OVERRIDE;
255 virtual Status Stop() OVERRIDE; 255 virtual Status Stop() OVERRIDE;
256 virtual Status RegisterComponent(const CrxComponent& component) OVERRIDE; 256 virtual Status RegisterComponent(const CrxComponent& component) OVERRIDE;
257 virtual Status CheckForUpdateSoon(const CrxComponent& component) OVERRIDE; 257 virtual Status CheckForUpdateSoon(const CrxComponent& component) OVERRIDE;
258 virtual bool FindRegisteredComponent(const std::vector<uint8>& pk_hash,
259 CrxComponent* component) OVERRIDE;
258 260
259 // The only purpose of this class is to forward the 261 // The only purpose of this class is to forward the
260 // UtilityProcessHostClient callbacks so CrxUpdateService does 262 // UtilityProcessHostClient callbacks so CrxUpdateService does
261 // not have to derive from it because that is refcounted. 263 // not have to derive from it because that is refcounted.
262 class ManifestParserBridge : public UtilityProcessHostClient { 264 class ManifestParserBridge : public UtilityProcessHostClient {
263 public: 265 public:
264 explicit ManifestParserBridge(CrxUpdateService* service) 266 explicit ManifestParserBridge(CrxUpdateService* service)
265 : service_(service) {} 267 : service_(service) {}
266 268
267 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { 269 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 uit->component = component; 494 uit->component = component;
493 work_items_.push_back(uit); 495 work_items_.push_back(uit);
494 // If this is the first component registered we call Start to 496 // If this is the first component registered we call Start to
495 // schedule the first timer. 497 // schedule the first timer.
496 if (running_ && (work_items_.size() == 1)) 498 if (running_ && (work_items_.size() == 1))
497 Start(); 499 Start();
498 500
499 return kOk; 501 return kOk;
500 } 502 }
501 503
504 bool CrxUpdateService::FindRegisteredComponent(
505 const std::vector<uint8>& pk_hash,
506 CrxComponent* component) {
507 std::string id =
508 HexStringToID(StringToLowerASCII(base::HexEncode(&pk_hash[0],
509 pk_hash.size()/2)));
510 CrxUpdateItem* uit = FindUpdateItemById(id);
511 if (uit) {
512 *component = uit->component;
513 return true;
514 }
515 return false;
516 }
517
518
502 // Sets a component to be checked for updates. 519 // Sets a component to be checked for updates.
503 // The componet to add is |crxit| and the |query| string is modified with the 520 // The componet to add is |crxit| and the |query| string is modified with the
504 // required omaha compatible query. Returns false when the query strings 521 // required omaha compatible query. Returns false when the query strings
505 // is longer than specified by UrlSizeLimit(). 522 // is longer than specified by UrlSizeLimit().
506 bool CrxUpdateService::AddItemToUpdateCheck(CrxUpdateItem* item, 523 bool CrxUpdateService::AddItemToUpdateCheck(CrxUpdateItem* item,
507 std::string* query) { 524 std::string* query) {
508 if (!AddQueryString(item->id, 525 if (!AddQueryString(item->id,
509 item->component.version.GetString(), 526 item->component.version.GetString(),
510 config_->UrlSizeLimit(), query)) 527 config_->UrlSizeLimit(), query))
511 return false; 528 return false;
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 ScheduleNextRun(false); 889 ScheduleNextRun(false);
873 } 890 }
874 891
875 // The component update factory. Using the component updater as a singleton 892 // The component update factory. Using the component updater as a singleton
876 // is the job of the browser process. 893 // is the job of the browser process.
877 ComponentUpdateService* ComponentUpdateServiceFactory( 894 ComponentUpdateService* ComponentUpdateServiceFactory(
878 ComponentUpdateService::Configurator* config) { 895 ComponentUpdateService::Configurator* config) {
879 DCHECK(config); 896 DCHECK(config);
880 return new CrxUpdateService(config); 897 return new CrxUpdateService(config);
881 } 898 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698