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

Side by Side Diff: components/offline_pages/core/downloads/download_notifying_observer.cc

Issue 2867103006: [Offline pages] Rename REMOVED to USER_CANCELED and add better foot note descriptions for histogram… (Closed)
Patch Set: rebase Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/offline_pages/core/downloads/download_notifying_observer.h" 5 #include "components/offline_pages/core/downloads/download_notifying_observer.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "components/offline_pages/core/background/request_coordinator.h" 8 #include "components/offline_pages/core/background/request_coordinator.h"
9 #include "components/offline_pages/core/background/save_page_request.h" 9 #include "components/offline_pages/core/background/save_page_request.h"
10 #include "components/offline_pages/core/client_policy_controller.h" 10 #include "components/offline_pages/core/client_policy_controller.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 74
75 void DownloadNotifyingObserver::OnCompleted( 75 void DownloadNotifyingObserver::OnCompleted(
76 const SavePageRequest& request, 76 const SavePageRequest& request,
77 RequestCoordinator::BackgroundSavePageResult status) { 77 RequestCoordinator::BackgroundSavePageResult status) {
78 DCHECK(notifier_.get()); 78 DCHECK(notifier_.get());
79 if (!IsVisibleInUI(request.client_id())) 79 if (!IsVisibleInUI(request.client_id()))
80 return; 80 return;
81 if (status == RequestCoordinator::BackgroundSavePageResult::SUCCESS) 81 if (status == RequestCoordinator::BackgroundSavePageResult::SUCCESS)
82 notifier_->NotifyDownloadSuccessful(DownloadUIItem(request)); 82 notifier_->NotifyDownloadSuccessful(DownloadUIItem(request));
83 else if (status == RequestCoordinator::BackgroundSavePageResult::REMOVED) 83 else if (status ==
84 RequestCoordinator::BackgroundSavePageResult::USER_CANCELED)
84 notifier_->NotifyDownloadCanceled(DownloadUIItem(request)); 85 notifier_->NotifyDownloadCanceled(DownloadUIItem(request));
85 else 86 else
86 notifier_->NotifyDownloadFailed(DownloadUIItem(request)); 87 notifier_->NotifyDownloadFailed(DownloadUIItem(request));
87 } 88 }
88 89
89 bool DownloadNotifyingObserver::IsVisibleInUI(const ClientId& page) { 90 bool DownloadNotifyingObserver::IsVisibleInUI(const ClientId& page) {
90 return policy_controller_->IsSupportedByDownload(page.name_space) && 91 return policy_controller_->IsSupportedByDownload(page.name_space) &&
91 base::IsValidGUID(page.id); 92 base::IsValidGUID(page.id);
92 } 93 }
93 94
94 // Calls the appropriate notifier method depending upon the state of the 95 // Calls the appropriate notifier method depending upon the state of the
95 // request. For example, an AVAILABLE request is not active (aka, pending) 96 // request. For example, an AVAILABLE request is not active (aka, pending)
96 // which the notifier understands as an Interrupted operation vs. one that 97 // which the notifier understands as an Interrupted operation vs. one that
97 // has Progress or is Paused. 98 // has Progress or is Paused.
98 void DownloadNotifyingObserver::NotifyRequestStateChange( 99 void DownloadNotifyingObserver::NotifyRequestStateChange(
99 const SavePageRequest& request) { 100 const SavePageRequest& request) {
100 if (request.request_state() == SavePageRequest::RequestState::PAUSED) 101 if (request.request_state() == SavePageRequest::RequestState::PAUSED)
101 notifier_->NotifyDownloadPaused(DownloadUIItem(request)); 102 notifier_->NotifyDownloadPaused(DownloadUIItem(request));
102 else if (request.request_state() == SavePageRequest::RequestState::AVAILABLE) 103 else if (request.request_state() == SavePageRequest::RequestState::AVAILABLE)
103 notifier_->NotifyDownloadInterrupted(DownloadUIItem(request)); 104 notifier_->NotifyDownloadInterrupted(DownloadUIItem(request));
104 else 105 else
105 notifier_->NotifyDownloadProgress(DownloadUIItem(request)); 106 notifier_->NotifyDownloadProgress(DownloadUIItem(request));
106 } 107 }
107 108
108 } // namespace offline_pages 109 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698