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

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: git pull && gclient sync 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..4964bb07c94339a094cbb3a7c2bf7da970990112 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,10 @@ enum UpdateType {
namespace component_updater {
+ComponentInfo::ComponentInfo(const std::string& id, const base::string16& name)
+ : id(id), name(name) {}
+ComponentInfo::~ComponentInfo() {}
+
CrxUpdateService::CrxUpdateService(
const scoped_refptr<Configurator>& config,
const scoped_refptr<UpdateClient>& update_client)
@@ -122,6 +127,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 +192,19 @@ std::vector<std::string> CrxUpdateService::GetComponentIDs() const {
return ids;
}
+std::unique_ptr<ComponentInfo> CrxUpdateService::GetComponentForMimeType(
+ const std::string& mime_type) 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 nullptr;
+ const auto component = GetComponent(it->second);
+ if (!component)
+ return nullptr;
+ return base::MakeUnique<ComponentInfo>(GetCrxComponentID(*component),
+ base::UTF8ToUTF16(component->name));
+}
+
OnDemandUpdater& CrxUpdateService::GetOnDemandUpdater() {
DCHECK(thread_checker_.CalledOnValidThread());
return *this;

Powered by Google App Engine
This is Rietveld 408576698