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

Side by Side Diff: components/offline_pages/background/request_coordinator.cc

Issue 2324493005: [Offline Pages] Adds event logs for requests dropped due to number of start or complete attempts. (Closed)
Patch Set: Merge Created 4 years, 3 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/background/request_coordinator.h" 5 #include "components/offline_pages/background/request_coordinator.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 189 }
190 190
191 return false; 191 return false;
192 } 192 }
193 193
194 void RequestCoordinator::AbortRequestAttempt(SavePageRequest* request) { 194 void RequestCoordinator::AbortRequestAttempt(SavePageRequest* request) {
195 request->MarkAttemptAborted(); 195 request->MarkAttemptAborted();
196 if (request->started_attempt_count() >= policy_->GetMaxStartedTries()) { 196 if (request->started_attempt_count() >= policy_->GetMaxStartedTries()) {
197 RemoveAttemptedRequest(*request, 197 RemoveAttemptedRequest(*request,
198 BackgroundSavePageResult::START_COUNT_EXCEEDED); 198 BackgroundSavePageResult::START_COUNT_EXCEEDED);
199 event_logger_.RecordDroppedSavePageRequest(
Pete Williamson 2016/09/09 17:16:19 This is logging to the offline-internals page, not
Pete Williamson 2016/09/09 22:08:31 Per our conversation, this is OK as logging, not U
dougarnett 2016/09/09 23:58:21 Opened 645679 for UMA. The point of this event log
200 request->client_id().name_space,
201 BackgroundSavePageResult::START_COUNT_EXCEEDED, request->request_id());
199 } else { 202 } else {
200 queue_->UpdateRequest( 203 queue_->UpdateRequest(
201 *request, 204 *request,
202 base::Bind(&RequestCoordinator::UpdateRequestCallback, 205 base::Bind(&RequestCoordinator::UpdateRequestCallback,
203 weak_ptr_factory_.GetWeakPtr(), request->client_id())); 206 weak_ptr_factory_.GetWeakPtr(), request->client_id()));
204 } 207 }
205 } 208 }
206 209
207 void RequestCoordinator::RemoveAttemptedRequest( 210 void RequestCoordinator::RemoveAttemptedRequest(
208 const SavePageRequest& request, BackgroundSavePageResult status) { 211 const SavePageRequest& request,
212 BackgroundSavePageResult result) {
209 std::vector<int64_t> remove_requests; 213 std::vector<int64_t> remove_requests;
210 remove_requests.push_back(request.request_id()); 214 remove_requests.push_back(request.request_id());
211 queue_->RemoveRequests(remove_requests, 215 queue_->RemoveRequests(remove_requests,
212 base::Bind(&RequestCoordinator::HandleRemovedRequests, 216 base::Bind(&RequestCoordinator::HandleRemovedRequests,
213 weak_ptr_factory_.GetWeakPtr(), status)); 217 weak_ptr_factory_.GetWeakPtr(), result));
214 RecordAttemptCount(request, status); 218 RecordAttemptCount(request, result);
215 } 219 }
216 220
217 void RequestCoordinator::RemoveRequests( 221 void RequestCoordinator::RemoveRequests(
218 const std::vector<int64_t>& request_ids, 222 const std::vector<int64_t>& request_ids,
219 const RemoveRequestsCallback& callback) { 223 const RemoveRequestsCallback& callback) {
220 bool canceled = CancelActiveRequestIfItMatches(request_ids); 224 bool canceled = CancelActiveRequestIfItMatches(request_ids);
221 queue_->RemoveRequests( 225 queue_->RemoveRequests(
222 request_ids, 226 request_ids,
223 base::Bind(&RequestCoordinator::HandleRemovedRequestsAndCallback, 227 base::Bind(&RequestCoordinator::HandleRemovedRequestsAndCallback,
224 weak_ptr_factory_.GetWeakPtr(), callback, 228 weak_ptr_factory_.GetWeakPtr(), callback,
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 } 473 }
470 } 474 }
471 475
472 void RequestCoordinator::OfflinerDoneCallback(const SavePageRequest& request, 476 void RequestCoordinator::OfflinerDoneCallback(const SavePageRequest& request,
473 Offliner::RequestStatus status) { 477 Offliner::RequestStatus status) {
474 DVLOG(2) << "offliner finished, saved: " 478 DVLOG(2) << "offliner finished, saved: "
475 << (status == Offliner::RequestStatus::SAVED) 479 << (status == Offliner::RequestStatus::SAVED)
476 << ", status: " << static_cast<int>(status) << ", " << __func__; 480 << ", status: " << static_cast<int>(status) << ", " << __func__;
477 DCHECK_NE(status, Offliner::RequestStatus::UNKNOWN); 481 DCHECK_NE(status, Offliner::RequestStatus::UNKNOWN);
478 DCHECK_NE(status, Offliner::RequestStatus::LOADED); 482 DCHECK_NE(status, Offliner::RequestStatus::LOADED);
479 event_logger_.RecordSavePageRequestUpdated(request.client_id().name_space, 483 event_logger_.RecordOfflinerResult(request.client_id().name_space, status,
480 status, request.request_id()); 484 request.request_id());
481 last_offlining_status_ = status; 485 last_offlining_status_ = status;
482 RecordOfflinerResultUMA(request.client_id(), last_offlining_status_); 486 RecordOfflinerResultUMA(request.client_id(), last_offlining_status_);
483 watchdog_timer_.Stop(); 487 watchdog_timer_.Stop();
484 488
485 is_busy_ = false; 489 is_busy_ = false;
486 active_request_.reset(nullptr); 490 active_request_.reset(nullptr);
487 491
488 if (status == Offliner::RequestStatus::FOREGROUND_CANCELED || 492 if (status == Offliner::RequestStatus::FOREGROUND_CANCELED ||
489 status == Offliner::RequestStatus::PRERENDERING_CANCELED) { 493 status == Offliner::RequestStatus::PRERENDERING_CANCELED) {
490 // Update the request for the canceled attempt. 494 // Update the request for the canceled attempt.
491 // TODO(dougarnett): See if we can conclusively identify other attempt 495 // TODO(dougarnett): See if we can conclusively identify other attempt
492 // aborted cases to treat this way (eg, for Render Process Killed). 496 // aborted cases to treat this way (eg, for Render Process Killed).
493 SavePageRequest updated_request(request); 497 SavePageRequest updated_request(request);
494 AbortRequestAttempt(&updated_request); 498 AbortRequestAttempt(&updated_request);
495 NotifyChanged(updated_request); 499 NotifyChanged(updated_request);
496 } else if (status == Offliner::RequestStatus::SAVED) { 500 } else if (status == Offliner::RequestStatus::SAVED) {
497 // Remove the request from the queue if it succeeded. 501 // Remove the request from the queue if it succeeded.
498 RemoveAttemptedRequest(request, BackgroundSavePageResult::SUCCESS); 502 RemoveAttemptedRequest(request, BackgroundSavePageResult::SUCCESS);
499 } else if (request.completed_attempt_count() + 1 >= 503 } else if (request.completed_attempt_count() + 1 >=
500 policy_->GetMaxCompletedTries()) { 504 policy_->GetMaxCompletedTries()) {
501 // Remove from the request queue if we exceeded max retries. The +1 505 // Remove from the request queue if we exceeded max retries. The +1
502 // represents the request that just completed. Since we call 506 // represents the request that just completed. Since we call
503 // MarkAttemptCompleted within the if branches, the completed_attempt_count 507 // MarkAttemptCompleted within the if branches, the completed_attempt_count
504 // has not yet been updated when we are checking the if condition. 508 // has not yet been updated when we are checking the if condition.
505 RemoveAttemptedRequest(request, 509 RemoveAttemptedRequest(request,
506 BackgroundSavePageResult::RETRY_COUNT_EXCEEDED); 510 BackgroundSavePageResult::RETRY_COUNT_EXCEEDED);
511 event_logger_.RecordDroppedSavePageRequest(
512 request.client_id().name_space,
513 BackgroundSavePageResult::RETRY_COUNT_EXCEEDED, request.request_id());
507 } else { 514 } else {
508 // If we failed, but are not over the limit, update the request in the 515 // If we failed, but are not over the limit, update the request in the
509 // queue. 516 // queue.
510 SavePageRequest updated_request(request); 517 SavePageRequest updated_request(request);
511 updated_request.MarkAttemptCompleted(); 518 updated_request.MarkAttemptCompleted();
512 queue_->UpdateRequest(updated_request, 519 queue_->UpdateRequest(updated_request,
513 base::Bind(&RequestCoordinator::UpdateRequestCallback, 520 base::Bind(&RequestCoordinator::UpdateRequestCallback,
514 weak_ptr_factory_.GetWeakPtr(), 521 weak_ptr_factory_.GetWeakPtr(),
515 updated_request.client_id())); 522 updated_request.client_id()));
516 NotifyChanged(updated_request); 523 NotifyChanged(updated_request);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 FOR_EACH_OBSERVER(Observer, observers_, OnChanged(request)); 577 FOR_EACH_OBSERVER(Observer, observers_, OnChanged(request));
571 } 578 }
572 579
573 void RequestCoordinator::GetOffliner() { 580 void RequestCoordinator::GetOffliner() {
574 if (!offliner_) { 581 if (!offliner_) {
575 offliner_ = factory_->GetOffliner(policy_.get()); 582 offliner_ = factory_->GetOffliner(policy_.get());
576 } 583 }
577 } 584 }
578 585
579 } // namespace offline_pages 586 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698