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

Unified Diff: components/offline_pages/downloads/download_notifying_observer.cc

Issue 2489443002: Move all components/offline_pages/ files into component/offline_pages/core (Closed)
Patch Set: more rebase Created 4 years, 1 month 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: components/offline_pages/downloads/download_notifying_observer.cc
diff --git a/components/offline_pages/downloads/download_notifying_observer.cc b/components/offline_pages/downloads/download_notifying_observer.cc
deleted file mode 100644
index 397bcc975a867fbd9fff675cb620921857ca9662..0000000000000000000000000000000000000000
--- a/components/offline_pages/downloads/download_notifying_observer.cc
+++ /dev/null
@@ -1,82 +0,0 @@
-// 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.
-
-#include "components/offline_pages/downloads/download_notifying_observer.h"
-
-#include "components/offline_pages/background/request_coordinator.h"
-#include "components/offline_pages/background/save_page_request.h"
-#include "components/offline_pages/client_policy_controller.h"
-#include "components/offline_pages/downloads/download_ui_adapter.h"
-#include "components/offline_pages/downloads/offline_page_download_notifier.h"
-
-namespace offline_pages {
-namespace {
-int kUserDataKey; // Only address is used.
-} // namespace
-
-DownloadNotifyingObserver::DownloadNotifyingObserver(
- std::unique_ptr<OfflinePageDownloadNotifier> notifier,
- ClientPolicyController* policy_controller)
- : notifier_(std::move(notifier)), policy_controller_(policy_controller) {}
-
-DownloadNotifyingObserver::~DownloadNotifyingObserver() {}
-
-// static
-DownloadNotifyingObserver* DownloadNotifyingObserver::GetFromRequestCoordinator(
- RequestCoordinator* request_coordinator) {
- DCHECK(request_coordinator);
- return static_cast<DownloadNotifyingObserver*>(
- request_coordinator->GetUserData(&kUserDataKey));
-}
-
-// static
-void DownloadNotifyingObserver::CreateAndStartObserving(
- RequestCoordinator* request_coordinator,
- std::unique_ptr<OfflinePageDownloadNotifier> notifier) {
- DCHECK(request_coordinator);
- DCHECK(notifier.get());
- DownloadNotifyingObserver* observer = new DownloadNotifyingObserver(
- std::move(notifier), request_coordinator->GetPolicyController());
- request_coordinator->AddObserver(observer);
- // |request_coordinator| takes ownership of observer here.
- request_coordinator->SetUserData(&kUserDataKey, observer);
-}
-
-void DownloadNotifyingObserver::OnAdded(const SavePageRequest& request) {
- DCHECK(notifier_.get());
- if (!IsVisibleInUI(request.client_id()))
- return;
- notifier_->NotifyDownloadProgress(DownloadUIItem(request));
-}
-
-void DownloadNotifyingObserver::OnChanged(const SavePageRequest& request) {
- DCHECK(notifier_.get());
- if (!IsVisibleInUI(request.client_id()))
- return;
- if (request.request_state() == SavePageRequest::RequestState::PAUSED)
- notifier_->NotifyDownloadPaused(DownloadUIItem(request));
- else
- notifier_->NotifyDownloadProgress(DownloadUIItem(request));
-}
-
-void DownloadNotifyingObserver::OnCompleted(
- const SavePageRequest& request,
- RequestCoordinator::BackgroundSavePageResult status) {
- DCHECK(notifier_.get());
- if (!IsVisibleInUI(request.client_id()))
- return;
- if (status == RequestCoordinator::BackgroundSavePageResult::SUCCESS)
- notifier_->NotifyDownloadSuccessful(DownloadUIItem(request));
- else if (status == RequestCoordinator::BackgroundSavePageResult::REMOVED)
- notifier_->NotifyDownloadCanceled(DownloadUIItem(request));
- else
- notifier_->NotifyDownloadFailed(DownloadUIItem(request));
-}
-
-bool DownloadNotifyingObserver::IsVisibleInUI(const ClientId& page) {
- return policy_controller_->IsSupportedByDownload(page.name_space) &&
- base::IsValidGUID(page.id);
-}
-
-} // namespace offline_pages

Powered by Google App Engine
This is Rietveld 408576698