Skip to content

Commit

Permalink
[Deduplication] Moved entry status from dedup service to entry class
Browse files Browse the repository at this point in the history
Bug: b/283900876
Change-Id: I55c8280f7d667e818b679865726bc2b4f073db54
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4572068
Reviewed-by: Melissa Zhang <melzhang@chromium.org>
Commit-Queue: Sharmin Zaman <sharminzaman@google.com>
Cr-Commit-Position: refs/heads/main@{#1150398}
  • Loading branch information
Sharmin Zaman authored and Chromium LUCI CQ committed May 30, 2023
1 parent e7249fd commit bdbcebd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,8 @@ std::vector<Entry> AppDeduplicationService::GetDuplicates(
}

for (const auto& entry : group->second.entries) {
auto status_it = entry_status_.find(entry);
if (status_it == entry_status_.end()) {
continue;
}
if (status_it->second == EntryStatus::kNonApp ||
status_it->second == EntryStatus::kInstalledApp) {
if (entry.entry_status == EntryStatus::kNonApp ||
entry.entry_status == EntryStatus::kInstalledApp) {
entries.push_back(entry);
}
}
Expand Down Expand Up @@ -163,15 +159,9 @@ void AppDeduplicationService::OnAppRegistryCacheWillBeDestroyed(
void AppDeduplicationService::UpdateInstallationStatus(
const apps::AppUpdate& update) {
Entry entry(update.PublisherId(), update.AppType());
auto it = entry_status_.find(entry);

if (it == entry_status_.end()) {
return;
}

it->second = apps_util::IsInstalled(update.Readiness())
? EntryStatus::kInstalledApp
: EntryStatus::kNotInstalledApp;
entry.entry_status = apps_util::IsInstalled(update.Readiness())
? EntryStatus::kInstalledApp
: EntryStatus::kNotInstalledApp;
}

absl::optional<uint32_t> AppDeduplicationService::FindDuplicationIndex(
Expand Down Expand Up @@ -312,11 +302,11 @@ void AppDeduplicationService::DeduplicateDataToEntries(
entry = Entry(app_id, source);
}

entry_to_group_map_[entry] = index;
// Initialize entry status.
entry_status_[entry] = entry.entry_type == EntryType::kApp
? EntryStatus::kNotInstalledApp
: EntryStatus::kNonApp;
entry.entry_status = entry.entry_type == EntryType::kApp
? EntryStatus::kNotInstalledApp
: EntryStatus::kNonApp;
entry_to_group_map_[entry] = index;
duplicate_group.entries.push_back(std::move(entry));
}
if (!duplicate_group.entries.empty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,6 @@ class AppDeduplicationService : public KeyedService,
FRIEND_TEST_ALL_PREFIXES(AppDeduplicationServiceAlmanacTest,
ValidServiceWithDuplicates);

enum class EntryStatus {
// This entry is not an app entry (could be website, phonehub, etc.).
kNonApp = 0,
kInstalledApp = 1,
kNotInstalledApp = 2
};

// Starts the process of calling the server to retrieve duplicate app data.
// A call is only made to the server if there is a difference of over 24 hours
// between now and the time stored in the server pref.
Expand Down Expand Up @@ -123,7 +116,6 @@ class AppDeduplicationService : public KeyedService,

std::map<uint32_t, DuplicateGroup> duplication_map_;
std::map<Entry, uint32_t> entry_to_group_map_;
std::map<Entry, EntryStatus> entry_status_;
raw_ptr<Profile, ExperimentalAsh> profile_;

base::ScopedObservation<AppProvisioningDataManager,
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/apps/app_deduplication_service/entry_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ bool Entry::operator<(const Entry& other) const {
}

std::ostream& operator<<(std::ostream& out, const Entry& entry) {
out << "EntryStatus: "
<< static_cast<std::underlying_type<EntryStatus>::type>(
entry.entry_status)
<< std::endl;
out << "EntryType: "
<< static_cast<std::underlying_type<EntryType>::type>(entry.entry_type)
<< std::endl;
Expand Down
9 changes: 9 additions & 0 deletions chrome/browser/apps/app_deduplication_service/entry_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ class GURL;

namespace apps::deduplication {

enum class EntryStatus {
// This entry is not an app entry (could be website, etc.).
kNonApp = 0,
kInstalledApp = 1,
kNotInstalledApp = 2
};

enum class EntryType { kApp, kWebPage };

// Deduplication entry, each entry represents an app or a web page that could be
Expand All @@ -35,6 +42,8 @@ struct Entry {
bool operator==(const Entry& other) const;
bool operator<(const Entry& other) const;

EntryStatus entry_status;

EntryType entry_type;

// The identifier id. If it is website, the id is the url.spec().
Expand Down

0 comments on commit bdbcebd

Please sign in to comment.