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

Unified Diff: content/browser/service_worker/service_worker_internals_ui.cc

Issue 2605923002: Remove base::ScopedPtrHashMap from content/browser/service_worker/. (Closed)
Patch Set: Created 4 years 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 | « content/browser/service_worker/service_worker_internals_ui.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/service_worker_internals_ui.cc
diff --git a/content/browser/service_worker/service_worker_internals_ui.cc b/content/browser/service_worker/service_worker_internals_ui.cc
index f4b224985edcab3ec512477600e93983aef7d1b6..5ec763d2a6f4f5b468ca79df6ce0f3ab0053e162 100644
--- a/content/browser/service_worker/service_worker_internals_ui.cc
+++ b/content/browser/service_worker/service_worker_internals_ui.cc
@@ -433,16 +433,16 @@ void ServiceWorkerInternalsUI::AddContextFromStoragePartition(
scoped_refptr<ServiceWorkerContextWrapper> context =
static_cast<ServiceWorkerContextWrapper*>(
partition->GetServiceWorkerContext());
- if (PartitionObserver* observer =
- observers_.get(reinterpret_cast<uintptr_t>(partition))) {
- partition_id = observer->partition_id();
+ auto it = observers_.find(reinterpret_cast<uintptr_t>(partition));
+ if (it != observers_.end()) {
+ partition_id = it->second->partition_id();
} else {
partition_id = next_partition_id_++;
std::unique_ptr<PartitionObserver> new_observer(
new PartitionObserver(partition_id, web_ui()));
context->AddObserver(new_observer.get());
- observers_.set(reinterpret_cast<uintptr_t>(partition),
- std::move(new_observer));
+ observers_[reinterpret_cast<uintptr_t>(partition)] =
+ std::move(new_observer);
}
BrowserThread::PostTask(
@@ -455,10 +455,11 @@ void ServiceWorkerInternalsUI::AddContextFromStoragePartition(
void ServiceWorkerInternalsUI::RemoveObserverFromStoragePartition(
StoragePartition* partition) {
- std::unique_ptr<PartitionObserver> observer(
- observers_.take_and_erase(reinterpret_cast<uintptr_t>(partition)));
- if (!observer.get())
+ auto it = observers_.find(reinterpret_cast<uintptr_t>(partition));
+ if (it == observers_.end())
return;
+ std::unique_ptr<PartitionObserver> observer = std::move(it->second);
+ observers_.erase(it);
scoped_refptr<ServiceWorkerContextWrapper> context =
static_cast<ServiceWorkerContextWrapper*>(
partition->GetServiceWorkerContext());
@@ -469,9 +470,8 @@ void ServiceWorkerInternalsUI::FindContext(
int partition_id,
StoragePartition** result_partition,
StoragePartition* storage_partition) const {
- PartitionObserver* observer =
- observers_.get(reinterpret_cast<uintptr_t>(storage_partition));
- if (observer && partition_id == observer->partition_id()) {
+ auto it = observers_.find(reinterpret_cast<uintptr_t>(storage_partition));
+ if (it != observers_.end() && partition_id == it->second->partition_id()) {
*result_partition = storage_partition;
}
}
« no previous file with comments | « content/browser/service_worker/service_worker_internals_ui.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698