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

Unified Diff: components/precache/core/precache_fetcher.cc

Issue 2802053002: precache: Extract common methods for PrecacheManifest into util. (Closed)
Patch Set: Copyright. Created 3 years, 8 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 | « components/precache/core/BUILD.gn ('k') | components/precache/core/precache_manifest_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/precache/core/precache_fetcher.cc
diff --git a/components/precache/core/precache_fetcher.cc b/components/precache/core/precache_fetcher.cc
index c9afc31348b7df58d19b7fdf29438cc42ce2a891..a17c6ea199cd4cd034b99a079d7d0b2e099f2cfc 100644
--- a/components/precache/core/precache_fetcher.cc
+++ b/components/precache/core/precache_fetcher.cc
@@ -28,6 +28,7 @@
#include "base/task_runner_util.h"
#include "components/data_use_measurement/core/data_use_user_data.h"
#include "components/precache/core/precache_database.h"
+#include "components/precache/core/precache_manifest_util.h"
#include "components/precache/core/precache_switches.h"
#include "components/precache/core/proto/quota.pb.h"
#include "components/precache/core/proto/unfinished_work.pb.h"
@@ -125,41 +126,6 @@ bool ParseProtoFromFetchResponse(const net::URLFetcher& source,
return true;
}
-// Returns the resource selection bitset from the |manifest| for the given
-// |experiment_id|. If the experiment group is not found, then this returns
-// nullopt, in which case all resources should be selected.
-base::Optional<std::vector<bool>> GetResourceBitset(
- const PrecacheManifest& manifest,
- uint32_t experiment_id) {
- base::Optional<std::vector<bool>> ret;
- if (manifest.has_experiments()) {
- const auto& resource_bitset_map =
- manifest.experiments().resources_by_experiment_group();
- const auto& it = resource_bitset_map.find(experiment_id);
- if (it != resource_bitset_map.end()) {
- if (it->second.has_bitset()) {
- const std::string& bitset = it->second.bitset();
- ret.emplace(bitset.size() * 8);
- for (size_t i = 0; i < bitset.size(); ++i) {
- for (size_t j = 0; j < 8; ++j) {
- if ((1 << j) & bitset[i])
- ret.value()[i * 8 + j] = true;
- }
- }
- } else if (it->second.has_deprecated_bitset()) {
- uint64_t bitset = it->second.deprecated_bitset();
- ret.emplace(64);
- for (int i = 0; i < 64; ++i) {
- if ((0x1ULL << i) & bitset)
- ret.value()[i] = true;
- }
- }
- }
- }
- // Only return one variable to ensure RVO triggers.
- return ret;
-}
-
// URLFetcherResponseWriter that ignores the response body, in order to avoid
// the unnecessary memory usage. Use it rather than the default if you don't
// care about parsing the response body. We use it below as a means to populate
« no previous file with comments | « components/precache/core/BUILD.gn ('k') | components/precache/core/precache_manifest_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698