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

Unified Diff: components/component_updater/component_updater_service.cc

Issue 2154773002: Implement Just-In-Time Flash updates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Through #27 + lint/format + offline comments Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: components/component_updater/component_updater_service.cc
diff --git a/components/component_updater/component_updater_service.cc b/components/component_updater/component_updater_service.cc
index ab4ad19a24074eb33c711eeaa958a8fb4927f8cf..465493853fcf8894e8dde61685f8a8d58f77177a 100644
--- a/components/component_updater/component_updater_service.cc
+++ b/components/component_updater/component_updater_service.cc
@@ -21,6 +21,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/thread_checker.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -49,6 +50,9 @@ enum UpdateType {
namespace component_updater {
+ComponentInfo::ComponentInfo() {}
+ComponentInfo::~ComponentInfo() {}
+
CrxUpdateService::CrxUpdateService(
const scoped_refptr<Configurator>& config,
const scoped_refptr<UpdateClient>& update_client)
@@ -122,6 +126,8 @@ bool CrxUpdateService::RegisterComponent(const CrxComponent& component) {
components_.insert(std::make_pair(id, component));
components_order_.push_back(id);
+ for (const auto& mime_type : component.handled_mime_types)
+ component_ids_by_mime_type_[mime_type] = id;
// Create an initial state for this component. The state is mutated in
// response to events from the UpdateClient instance.
@@ -185,6 +191,20 @@ std::vector<std::string> CrxUpdateService::GetComponentIDs() const {
return ids;
}
+bool CrxUpdateService::GetComponentForMimeType(const std::string& mime_type,
+ ComponentInfo* info) const {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ const auto it = component_ids_by_mime_type_.find(mime_type);
+ if (it == component_ids_by_mime_type_.end())
+ return false;
+ const auto component = GetComponent(it->second);
+ if (!component)
+ return false;
+ info->id = GetCrxComponentID(*component);
+ info->name = base::UTF8ToUTF16(component->name);
+ return true;
+}
+
OnDemandUpdater& CrxUpdateService::GetOnDemandUpdater() {
DCHECK(thread_checker_.CalledOnValidThread());
return *this;

Powered by Google App Engine
This is Rietveld 408576698