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

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: First Review Pass 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..24d7ceb376e42c37a5e5915fd8763b935d51d5ab 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,11 @@ enum UpdateType {
namespace component_updater {
+ComponentInfo::ComponentInfo() {
+}
+ComponentInfo::~ComponentInfo() {
+}
+
CrxUpdateService::CrxUpdateService(
const scoped_refptr<Configurator>& config,
const scoped_refptr<UpdateClient>& update_client)
@@ -122,6 +128,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 +193,21 @@ 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 == NULL)
Bernhard Bauer 2016/07/28 10:25:10 nullptr :) Or just directly use it in the check.
waffles 2016/07/28 20:06:27 Done.
+ return false;
+ info->id = GetCrxComponentID(*component);
+ base::UTF8ToUTF16(component->name.c_str(), component->name.size(),
Bernhard Bauer 2016/07/28 10:25:10 I would use the version of UTF8ToUTF16 that takes
waffles 2016/07/28 20:06:27 Done.
+ &info->name);
+ return true;
+}
+
OnDemandUpdater& CrxUpdateService::GetOnDemandUpdater() {
DCHECK(thread_checker_.CalledOnValidThread());
return *this;

Powered by Google App Engine
This is Rietveld 408576698