diff options
author | asargent <asargent@chromium.org> | 2015-02-13 16:31:53 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-14 00:32:28 +0000 |
commit | d71a7a6b1d878a5c0077863e03b6f12eabaee2b7 (patch) | |
tree | ea43a3d235293e1a8e395055e10343a915d6f2dd | |
parent | 7dc2605574f04851cc6d2bc000a5a65e055d7e56 (diff) | |
download | chromium_src-d71a7a6b1d878a5c0077863e03b6f12eabaee2b7.zip chromium_src-d71a7a6b1d878a5c0077863e03b6f12eabaee2b7.tar.gz chromium_src-d71a7a6b1d878a5c0077863e03b6f12eabaee2b7.tar.bz2 |
Remove ManifestFetchData parameter from SafeManifestParser
All it was doing with it is passing it through to its completion
callback (apart from 2 VLOG statements). This CL changes to binding it
to the callback directly with the base::Bind call.
Also rename UpdateCallback to ResultsCallback, because that seemed like
a better name to me. And run our autoformatting thing As Required By Law.
BUG=458373
Review URL: https://codereview.chromium.org/924603003
Cr-Commit-Position: refs/heads/master@{#316342}
5 files changed, 26 insertions, 34 deletions
diff --git a/chrome/browser/extensions/updater/extension_updater_unittest.cc b/chrome/browser/extensions/updater/extension_updater_unittest.cc index 6afb075..4dcc727 100644 --- a/chrome/browser/extensions/updater/extension_updater_unittest.cc +++ b/chrome/browser/extensions/updater/extension_updater_unittest.cc @@ -1780,7 +1780,7 @@ class ExtensionUpdaterTest : public testing::Test { UpdateManifest::Results results; results.daystart_elapsed_seconds = 750; - updater.downloader_->HandleManifestResults(*fetch_data, &results); + updater.downloader_->HandleManifestResults(fetch_data.get(), &results); Time last_ping_day = service.extension_prefs()->LastPingDay(extension->id()); EXPECT_FALSE(last_ping_day.is_null()); diff --git a/extensions/browser/updater/extension_downloader.cc b/extensions/browser/updater/extension_downloader.cc index 3e06083..f572fa0 100644 --- a/extensions/browser/updater/extension_downloader.cc +++ b/extensions/browser/updater/extension_downloader.cc @@ -528,9 +528,10 @@ void ExtensionDownloader::OnManifestFetchComplete( VLOG(2) << "beginning manifest parse for " << url; scoped_refptr<SafeManifestParser> safe_parser(new SafeManifestParser( data, - manifests_queue_.reset_active_request().release(), - base::Bind(&ExtensionDownloader::HandleManifestResults, - weak_ptr_factory_.GetWeakPtr()))); + base::Bind( + &ExtensionDownloader::HandleManifestResults, + weak_ptr_factory_.GetWeakPtr(), + base::Owned(manifests_queue_.reset_active_request().release())))); safe_parser->Start(); } else { VLOG(1) << "Failed to fetch manifest '" << url.possibly_invalid_spec() @@ -556,23 +557,25 @@ void ExtensionDownloader::OnManifestFetchComplete( } void ExtensionDownloader::HandleManifestResults( - const ManifestFetchData& fetch_data, + const ManifestFetchData* fetch_data, const UpdateManifest::Results* results) { // Keep a list of extensions that will not be updated, so that the |delegate_| // can be notified once we're done here. - std::set<std::string> not_updated(fetch_data.extension_ids()); + std::set<std::string> not_updated(fetch_data->extension_ids()); if (!results) { + VLOG(2) << "parsing manifest failed (" << fetch_data->full_url() << ")"; NotifyExtensionsDownloadFailed( - not_updated, - fetch_data.request_ids(), + not_updated, fetch_data->request_ids(), ExtensionDownloaderDelegate::MANIFEST_INVALID); return; + } else { + VLOG(2) << "parsing manifest succeeded (" << fetch_data->full_url() << ")"; } // Examine the parsed manifest and kick off fetches of any new crx files. std::vector<int> updates; - DetermineUpdates(fetch_data, *results, &updates); + DetermineUpdates(*fetch_data, *results, &updates); for (size_t i = 0; i < updates.size(); i++) { const UpdateManifest::Result* update = &(results->list.at(updates[i])); const std::string& id = update->extension_id; @@ -597,34 +600,30 @@ void ExtensionDownloader::HandleManifestResults( } } scoped_ptr<ExtensionFetch> fetch( - new ExtensionFetch(update->extension_id, - crx_url, - update->package_hash, - update->version, - fetch_data.request_ids())); + new ExtensionFetch(update->extension_id, crx_url, update->package_hash, + update->version, fetch_data->request_ids())); FetchUpdatedExtension(fetch.Pass()); } // If the manifest response included a <daystart> element, we want to save // that value for any extensions which had sent a ping in the request. - if (fetch_data.base_url().DomainIs(kGoogleDotCom) && + if (fetch_data->base_url().DomainIs(kGoogleDotCom) && results->daystart_elapsed_seconds >= 0) { Time day_start = Time::Now() - TimeDelta::FromSeconds(results->daystart_elapsed_seconds); - const std::set<std::string>& extension_ids = fetch_data.extension_ids(); + const std::set<std::string>& extension_ids = fetch_data->extension_ids(); std::set<std::string>::const_iterator i; for (i = extension_ids.begin(); i != extension_ids.end(); i++) { const std::string& id = *i; ExtensionDownloaderDelegate::PingResult& result = ping_results_[id]; - result.did_ping = fetch_data.DidPing(id, ManifestFetchData::ROLLCALL); + result.did_ping = fetch_data->DidPing(id, ManifestFetchData::ROLLCALL); result.day_start = day_start; } } NotifyExtensionsDownloadFailed( - not_updated, - fetch_data.request_ids(), + not_updated, fetch_data->request_ids(), ExtensionDownloaderDelegate::NO_UPDATE_AVAILABLE); } diff --git a/extensions/browser/updater/extension_downloader.h b/extensions/browser/updater/extension_downloader.h index d987a059..4a93def 100644 --- a/extensions/browser/updater/extension_downloader.h +++ b/extensions/browser/updater/extension_downloader.h @@ -207,7 +207,7 @@ class ExtensionDownloader : public net::URLFetcherDelegate, // Once a manifest is parsed, this starts fetches of any relevant crx files. // If |results| is null, it means something went wrong when parsing it. - void HandleManifestResults(const ManifestFetchData& fetch_data, + void HandleManifestResults(const ManifestFetchData* fetch_data, const UpdateManifest::Results* results); // Given a list of potential updates, returns the indices of the ones that are diff --git a/extensions/browser/updater/safe_manifest_parser.cc b/extensions/browser/updater/safe_manifest_parser.cc index 2ab9a05..f40fc13 100644 --- a/extensions/browser/updater/safe_manifest_parser.cc +++ b/extensions/browser/updater/safe_manifest_parser.cc @@ -19,9 +19,8 @@ using content::BrowserThread; namespace extensions { SafeManifestParser::SafeManifestParser(const std::string& xml, - ManifestFetchData* fetch_data, - const UpdateCallback& update_callback) - : xml_(xml), fetch_data_(fetch_data), update_callback_(update_callback) { + const ResultsCallback& results_callback) + : xml_(xml), results_callback_(results_callback) { DCHECK_CURRENTLY_ON(BrowserThread::UI); } @@ -63,17 +62,15 @@ bool SafeManifestParser::OnMessageReceived(const IPC::Message& message) { void SafeManifestParser::OnParseUpdateManifestSucceeded( const UpdateManifest::Results& results) { - VLOG(2) << "parsing manifest succeeded (" << fetch_data_->full_url() << ")"; DCHECK_CURRENTLY_ON(BrowserThread::UI); - update_callback_.Run(*fetch_data_, &results); + results_callback_.Run(&results); } void SafeManifestParser::OnParseUpdateManifestFailed( const std::string& error_message) { - VLOG(2) << "parsing manifest failed (" << fetch_data_->full_url() << ")"; DCHECK_CURRENTLY_ON(BrowserThread::UI); LOG(WARNING) << "Error parsing update manifest:\n" << error_message; - update_callback_.Run(*fetch_data_, NULL); + results_callback_.Run(NULL); } } // namespace extensions diff --git a/extensions/browser/updater/safe_manifest_parser.h b/extensions/browser/updater/safe_manifest_parser.h index 3215fa3..9f31ab6 100644 --- a/extensions/browser/updater/safe_manifest_parser.h +++ b/extensions/browser/updater/safe_manifest_parser.h @@ -20,13 +20,10 @@ namespace extensions { class SafeManifestParser : public content::UtilityProcessHostClient { public: // Callback that is invoked when the manifest results are ready. - typedef base::Callback<void(const ManifestFetchData&, - const UpdateManifest::Results*)> UpdateCallback; + typedef base::Callback<void(const UpdateManifest::Results*)> ResultsCallback; - // Takes ownership of |fetch_data|. SafeManifestParser(const std::string& xml, - ManifestFetchData* fetch_data, - const UpdateCallback& update_callback); + const ResultsCallback& results_callback); // Posts a task over to the IO loop to start the parsing of xml_ in a // utility process. @@ -47,8 +44,7 @@ class SafeManifestParser : public content::UtilityProcessHostClient { const std::string xml_; // Should be accessed only on UI thread. - scoped_ptr<ManifestFetchData> fetch_data_; - UpdateCallback update_callback_; + ResultsCallback results_callback_; DISALLOW_COPY_AND_ASSIGN(SafeManifestParser); }; |