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

Unified Diff: services/catalog/reader.h

Issue 2651953002: Revert of [Service Manager] Get rid of dynamic service discovery (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « services/catalog/public/tools/generate_manifest.py ('k') | services/catalog/reader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/catalog/reader.h
diff --git a/services/catalog/reader.h b/services/catalog/reader.h
new file mode 100644
index 0000000000000000000000000000000000000000..813a81305f35e919e3d48d9a7b3aa254c8174e0f
--- /dev/null
+++ b/services/catalog/reader.h
@@ -0,0 +1,88 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SERVICES_CATALOG_READER_H_
+#define SERVICES_CATALOG_READER_H_
+
+#include <map>
+#include <memory>
+#include <string>
+
+#include "base/callback.h"
+#include "base/files/file_path.h"
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "services/service_manager/public/interfaces/resolver.mojom.h"
+
+namespace base {
+class SequencedWorkerPool;
+class SingleThreadTaskRunner;
+class Value;
+}
+
+namespace catalog {
+
+class Entry;
+class EntryCache;
+class ManifestProvider;
+
+// Responsible for loading manifests & building the Entry data structures.
+class Reader {
+ public:
+ using ReadManifestCallback = base::Callback<void(std::unique_ptr<Entry>)>;
+ using CreateEntryForNameCallback =
+ service_manager::mojom::Resolver::ResolveServiceNameCallback;
+
+ // Construct a Reader over a static manifest. This Reader never performs
+ // file I/O.
+ Reader(std::unique_ptr<base::Value> static_manifest, EntryCache* cache);
+
+ Reader(base::SequencedWorkerPool* worker_pool,
+ ManifestProvider* manifest_provider);
+ Reader(base::SingleThreadTaskRunner* task_runner,
+ ManifestProvider* manifest_provider);
+ ~Reader();
+
+ // Scans the contents of |package_dir|, reading all application manifests and
+ // populating |cache|. Runs |read_complete_closure| when done.
+ void Read(const base::FilePath& package_dir,
+ EntryCache* cache,
+ const base::Closure& read_complete_closure);
+
+ // Returns an Entry for |name| via |callback|, assuming a manifest file in the
+ // canonical location
+ void CreateEntryForName(
+ const std::string& name,
+ EntryCache* cache,
+ const CreateEntryForNameCallback& entry_created_callback);
+
+ // Overrides the package name used for a specific service name.
+ void OverridePackageName(const std::string& service_name,
+ const std::string& package_name);
+
+ // Overrides the manifest path used for a specific service name.
+ void OverrideManifestPath(const std::string& service_name,
+ const base::FilePath& path);
+
+ private:
+ explicit Reader(ManifestProvider* manifest_provider);
+
+ void OnReadManifest(EntryCache* cache,
+ const CreateEntryForNameCallback& entry_created_callback,
+ std::unique_ptr<Entry> entry);
+
+ const bool using_static_catalog_ = false;
+ base::FilePath system_package_dir_;
+ scoped_refptr<base::TaskRunner> file_task_runner_;
+ ManifestProvider* const manifest_provider_;
+ std::map<std::string, std::string> package_name_overrides_;
+ std::map<std::string, base::FilePath> manifest_path_overrides_;
+ base::WeakPtrFactory<Reader> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(Reader);
+};
+
+} // namespace catalog
+
+#endif // SERVICES_CATALOG_READER_H_
« no previous file with comments | « services/catalog/public/tools/generate_manifest.py ('k') | services/catalog/reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698