Chromium Code Reviews| 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 <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 CrxComponent::BANDAID, | 56 CrxComponent::BANDAID, |
| 57 CrxComponent::CWS_PUBLIC, | 57 CrxComponent::CWS_PUBLIC, |
| 58 CrxComponent::CWS_SANDBOX, | 58 CrxComponent::CWS_SANDBOX, |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 // Extends an omaha compatible update check url |query| string. Does | 61 // Extends an omaha compatible update check url |query| string. Does |
| 62 // not mutate the string if it would be longer than |limit| chars. | 62 // not mutate the string if it would be longer than |limit| chars. |
| 63 bool AddQueryString(const std::string& id, | 63 bool AddQueryString(const std::string& id, |
| 64 const std::string& version, | 64 const std::string& version, |
| 65 const std::string& fingerprint, | 65 const std::string& fingerprint, |
| 66 bool ondemand, | |
| 66 size_t limit, | 67 size_t limit, |
| 67 std::string* query) { | 68 std::string* query) { |
| 68 std::string additional = | 69 std::string additional = |
| 69 base::StringPrintf("id=%s&v=%s&fp=%s&uc", | 70 base::StringPrintf("id=%s&v=%s&fp=%s&uc%s", |
| 70 id.c_str(), version.c_str(), fingerprint.c_str()); | 71 id.c_str(), |
| 72 version.c_str(), | |
| 73 fingerprint.c_str(), | |
| 74 ondemand ? "&installsource=ondemand" : ""); | |
| 71 additional = "x=" + net::EscapeQueryParamValue(additional, true); | 75 additional = "x=" + net::EscapeQueryParamValue(additional, true); |
| 72 if ((additional.size() + query->size() + 1) > limit) | 76 if ((additional.size() + query->size() + 1) > limit) |
| 73 return false; | 77 return false; |
| 74 if (!query->empty()) | 78 if (!query->empty()) |
| 75 query->append(1, '&'); | 79 query->append(1, '&'); |
| 76 query->append(additional); | 80 query->append(additional); |
| 77 return true; | 81 return true; |
| 78 } | 82 } |
| 79 | 83 |
| 80 // Create the final omaha compatible query. The |extra| is optional and can | 84 // Create the final omaha compatible query. The |extra| is optional and can |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 560 work_items_.push_back(uit); | 564 work_items_.push_back(uit); |
| 561 // If this is the first component registered we call Start to | 565 // If this is the first component registered we call Start to |
| 562 // schedule the first timer. | 566 // schedule the first timer. |
| 563 if (running_ && (work_items_.size() == 1)) | 567 if (running_ && (work_items_.size() == 1)) |
| 564 Start(); | 568 Start(); |
| 565 | 569 |
| 566 return kOk; | 570 return kOk; |
| 567 } | 571 } |
| 568 | 572 |
| 569 // Sets a component to be checked for updates. | 573 // Sets a component to be checked for updates. |
| 570 // The component to add is |crxit| and the |query| string is modified with the | 574 // The component to add is |crxit| and the |query| string is modified with the |
|
asargent_no_longer_on_chrome
2013/06/24 17:34:51
nit: should this be "|item|" instead of "|crxit|"
waffles
2013/06/24 17:39:30
Done.
| |
| 571 // required omaha compatible query. Returns false when the query strings | 575 // required omaha compatible query. Returns false when the query strings |
|
asargent_no_longer_on_chrome
2013/06/24 17:34:51
nit: "when the query strings" -> "when the query s
waffles
2013/06/24 17:39:30
Done.
| |
| 572 // is longer than specified by UrlSizeLimit(). | 576 // is longer than specified by UrlSizeLimit(). |
| 573 bool CrxUpdateService::AddItemToUpdateCheck(CrxUpdateItem* item, | 577 bool CrxUpdateService::AddItemToUpdateCheck(CrxUpdateItem* item, |
| 574 std::string* query) { | 578 std::string* query) { |
| 575 if (!AddQueryString(item->id, | 579 if (!AddQueryString(item->id, |
| 576 item->component.version.GetString(), | 580 item->component.version.GetString(), |
| 577 item->component.fingerprint, | 581 item->component.fingerprint, |
| 578 config_->UrlSizeLimit(), query)) | 582 requested_work_items_.count(item), |
|
Sorin Jianu
2013/06/24 17:25:57
I would consider using a
const bool is_ondemand =
asargent_no_longer_on_chrome
2013/06/24 17:34:51
This is a good suggestion. A slightly more compact
waffles
2013/06/24 17:39:30
Done.
| |
| 583 config_->UrlSizeLimit(), | |
| 584 query)) | |
| 579 return false; | 585 return false; |
| 580 | 586 |
| 581 item->status = CrxUpdateItem::kChecking; | 587 item->status = CrxUpdateItem::kChecking; |
| 582 item->last_check = base::Time::Now(); | 588 item->last_check = base::Time::Now(); |
| 583 item->previous_version = item->component.version; | 589 item->previous_version = item->component.version; |
| 584 item->next_version = Version(); | 590 item->next_version = Version(); |
| 585 item->previous_fp = item->component.fingerprint; | 591 item->previous_fp = item->component.fingerprint; |
| 586 item->next_fp.clear(); | 592 item->next_fp.clear(); |
| 587 item->diff_update_failed = false; | 593 item->diff_update_failed = false; |
| 588 return true; | 594 return true; |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 994 ScheduleNextRun(false); | 1000 ScheduleNextRun(false); |
| 995 } | 1001 } |
| 996 | 1002 |
| 997 // The component update factory. Using the component updater as a singleton | 1003 // The component update factory. Using the component updater as a singleton |
| 998 // is the job of the browser process. | 1004 // is the job of the browser process. |
| 999 ComponentUpdateService* ComponentUpdateServiceFactory( | 1005 ComponentUpdateService* ComponentUpdateServiceFactory( |
| 1000 ComponentUpdateService::Configurator* config) { | 1006 ComponentUpdateService::Configurator* config) { |
| 1001 DCHECK(config); | 1007 DCHECK(config); |
| 1002 return new CrxUpdateService(config); | 1008 return new CrxUpdateService(config); |
| 1003 } | 1009 } |
| OLD | NEW |