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

Unified Diff: content/child/notifications/pending_notifications_tracker.cc

Issue 1847863002: Move notification resource loading from content/child to blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address peter's comments. Created 4 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
Index: content/child/notifications/pending_notifications_tracker.cc
diff --git a/content/child/notifications/pending_notifications_tracker.cc b/content/child/notifications/pending_notifications_tracker.cc
deleted file mode 100644
index bfe7dd3a362cedff11eec07851d10d783b21372b..0000000000000000000000000000000000000000
--- a/content/child/notifications/pending_notifications_tracker.cc
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2015 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.
-
-#include "content/child/notifications/pending_notifications_tracker.h"
-
-#include <memory>
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/callback.h"
-#include "content/child/notifications/pending_notification.h"
-#include "content/public/common/notification_resources.h"
-
-namespace content {
-
-PendingNotificationsTracker::PendingNotificationsTracker(
- const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner)
- : next_notification_id_(0), main_task_runner_(main_task_runner) {}
-
-PendingNotificationsTracker::~PendingNotificationsTracker() {}
-
-void PendingNotificationsTracker::FetchResources(
- const blink::WebNotificationData& notification_data,
- blink::WebNotificationDelegate* delegate,
- const ResourcesCallback& resources_callback) {
- int32_t notification_id = next_notification_id_++;
-
- if (delegate)
- delegate_to_pending_id_map_[delegate] = notification_id;
-
- base::Closure fetches_finished_callback = base::Bind(
- &PendingNotificationsTracker::FetchesFinished,
- base::Unretained(this) /* The pending notifications are owned by this. */,
- delegate, notification_id, resources_callback);
-
- std::unique_ptr<PendingNotification> pending_notification(
- new PendingNotification(main_task_runner_));
- pending_notification->FetchResources(notification_data,
- fetches_finished_callback);
-
- pending_notifications_.AddWithID(pending_notification.release(),
- notification_id);
-}
-
-bool PendingNotificationsTracker::CancelResourceFetches(
- blink::WebNotificationDelegate* delegate) {
- DCHECK(delegate);
-
- auto iter = delegate_to_pending_id_map_.find(delegate);
- if (iter == delegate_to_pending_id_map_.end())
- return false;
-
- pending_notifications_.Remove(iter->second);
- delegate_to_pending_id_map_.erase(iter);
-
- return true;
-}
-
-void PendingNotificationsTracker::FetchesFinished(
- blink::WebNotificationDelegate* delegate,
- int32_t notification_id,
- const ResourcesCallback& resources_callback) {
- PendingNotification* pending_notification =
- pending_notifications_.Lookup(notification_id);
- DCHECK(pending_notification);
-
- resources_callback.Run(pending_notification->GetResources());
-
- if (delegate)
- delegate_to_pending_id_map_.erase(delegate);
- pending_notifications_.Remove(notification_id);
-}
-
-} // namespace content

Powered by Google App Engine
This is Rietveld 408576698