Commit 692512f9 authored by Swapnil's avatar Swapnil Committed by Commit Bot

Refactor ManifestFetchData

Change AddExtension method in ManifestFetchData class so that it
accepts the Manifest::Location instead of std::string as we would need
it in case of offline installation from cache in
https://crbug.com/1051870.

Bug: 1061402
Change-Id: I336e240d659095f94796d3aec06c51f4b577d6ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2100820
Commit-Queue: Swapnil Gupta <swapnilgupta@google.com>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Reviewed-by: default avatarOleg Davydov <burunduk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751177}
parent 432fefd5
...@@ -396,9 +396,6 @@ bool ExtensionDownloader::AddExtensionData( ...@@ -396,9 +396,6 @@ bool ExtensionDownloader::AddExtensionData(
if (extra.is_corrupt_reinstall) if (extra.is_corrupt_reinstall)
install_source = kReinstallInstallSource; install_source = kReinstallInstallSource;
const std::string install_location =
ManifestFetchData::GetSimpleLocationString(extension_location);
ManifestFetchData::PingData ping_data; ManifestFetchData::PingData ping_data;
ManifestFetchData::PingData* optional_ping_data = NULL; ManifestFetchData::PingData* optional_ping_data = NULL;
if (delegate_->GetPingDataForExtension(id, &ping_data)) if (delegate_->GetPingDataForExtension(id, &ping_data))
...@@ -414,7 +411,7 @@ bool ExtensionDownloader::AddExtensionData( ...@@ -414,7 +411,7 @@ bool ExtensionDownloader::AddExtensionData(
ManifestFetchData* existing_fetch = existing_iter->second.back().get(); ManifestFetchData* existing_fetch = existing_iter->second.back().get();
if (existing_fetch->AddExtension( if (existing_fetch->AddExtension(
id, version.GetString(), optional_ping_data, extra.update_url_data, id, version.GetString(), optional_ping_data, extra.update_url_data,
install_source, install_location, fetch_priority)) { install_source, extension_location, fetch_priority)) {
added = true; added = true;
} }
} }
...@@ -428,7 +425,7 @@ bool ExtensionDownloader::AddExtensionData( ...@@ -428,7 +425,7 @@ bool ExtensionDownloader::AddExtensionData(
std::move(fetch)); std::move(fetch));
added = fetch_ptr->AddExtension(id, version.GetString(), optional_ping_data, added = fetch_ptr->AddExtension(id, version.GetString(), optional_ping_data,
extra.update_url_data, install_source, extra.update_url_data, install_source,
install_location, fetch_priority); extension_location, fetch_priority);
DCHECK(added); DCHECK(added);
} }
......
...@@ -45,7 +45,8 @@ class ExtensionDownloaderTest : public ExtensionsTest { ...@@ -45,7 +45,8 @@ class ExtensionDownloaderTest : public ExtensionsTest {
std::unique_ptr<ManifestFetchData> fetch( std::unique_ptr<ManifestFetchData> fetch(
CreateManifestFetchData(kUpdateUrl)); CreateManifestFetchData(kUpdateUrl));
ManifestFetchData::PingData zero_days(0, 0, true, 0); ManifestFetchData::PingData zero_days(0, 0, true, 0);
fetch->AddExtension(kTestExtensionId, "1.0", &zero_days, "", "", "", fetch->AddExtension(kTestExtensionId, "1.0", &zero_days, "", "",
Manifest::Location::INTERNAL,
ManifestFetchData::FetchPriority::BACKGROUND); ManifestFetchData::FetchPriority::BACKGROUND);
return fetch; return fetch;
} }
......
...@@ -126,7 +126,7 @@ bool ManifestFetchData::AddExtension(const std::string& id, ...@@ -126,7 +126,7 @@ bool ManifestFetchData::AddExtension(const std::string& id,
const PingData* ping_data, const PingData* ping_data,
const std::string& update_url_data, const std::string& update_url_data,
const std::string& install_source, const std::string& install_source,
const std::string& install_location, Manifest::Location extension_location,
FetchPriority fetch_priority) { FetchPriority fetch_priority) {
if (extension_ids_.find(id) != extension_ids_.end()) { if (extension_ids_.find(id) != extension_ids_.end()) {
NOTREACHED() << "Duplicate extension id " << id; NOTREACHED() << "Duplicate extension id " << id;
...@@ -137,6 +137,9 @@ bool ManifestFetchData::AddExtension(const std::string& id, ...@@ -137,6 +137,9 @@ bool ManifestFetchData::AddExtension(const std::string& id,
fetch_priority_ = fetch_priority; fetch_priority_ = fetch_priority;
} }
const std::string install_location =
GetSimpleLocationString(extension_location);
// Compute the string we'd append onto the full_url_, and see if it fits. // Compute the string we'd append onto the full_url_, and see if it fits.
std::vector<std::string> parts; std::vector<std::string> parts;
parts.push_back("id=" + id); parts.push_back("id=" + id);
......
...@@ -103,7 +103,7 @@ class ManifestFetchData { ...@@ -103,7 +103,7 @@ class ManifestFetchData {
const PingData* ping_data, const PingData* ping_data,
const std::string& update_url_data, const std::string& update_url_data,
const std::string& install_source, const std::string& install_source,
const std::string& install_location, Manifest::Location install_location,
FetchPriority fetch_priority); FetchPriority fetch_priority);
const GURL& base_url() const { return base_url_; } const GURL& base_url() const { return base_url_; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment