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

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

Issue 2324493005: [Offline Pages] Adds event logs for requests dropped due to number of start or complete attempts. (Closed)
Patch Set: Fixed a new comment and also made the new comments a bit less fragile to specific logger method nam… 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_picker.h" 5 #include "components/offline_pages/background/request_picker.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "components/offline_pages/background/save_page_request.h" 9 #include "components/offline_pages/background/save_page_request.h"
10 10
11 namespace { 11 namespace {
12 template <typename T> 12 template <typename T>
13 int signum(T t) { 13 int signum(T t) {
14 return (T(0) < t) - (t < T(0)); 14 return (T(0) < t) - (t < T(0));
15 } 15 }
16 16
17 #define CALL_MEMBER_FUNCTION(object,ptrToMember) ((object)->*(ptrToMember)) 17 #define CALL_MEMBER_FUNCTION(object, ptrToMember) ((object)->*(ptrToMember))
18 } // namespace 18 } // namespace
19 19
20 namespace offline_pages { 20 namespace offline_pages {
21 21
22 RequestPicker::RequestPicker(RequestQueue* requestQueue, 22 RequestPicker::RequestPicker(RequestQueue* requestQueue,
23 OfflinerPolicy* policy, 23 OfflinerPolicy* policy,
24 RequestNotifier* notifier) 24 RequestNotifier* notifier,
25 RequestCoordinatorEventLogger* event_logger)
25 : queue_(requestQueue), 26 : queue_(requestQueue),
26 policy_(policy), 27 policy_(policy),
27 notifier_(notifier), 28 notifier_(notifier),
29 event_logger_(event_logger),
28 fewer_retries_better_(false), 30 fewer_retries_better_(false),
29 earlier_requests_better_(false), 31 earlier_requests_better_(false),
30 weak_ptr_factory_(this) {} 32 weak_ptr_factory_(this) {}
31 33
32 RequestPicker::~RequestPicker() {} 34 RequestPicker::~RequestPicker() {}
33 35
34 // Entry point for the async operation to choose the next request. 36 // Entry point for the async operation to choose the next request.
35 void RequestPicker::ChooseNextRequest( 37 void RequestPicker::ChooseNextRequest(
36 RequestCoordinator::RequestPickedCallback picked_callback, 38 RequestCoordinator::RequestPickedCallback picked_callback,
37 RequestCoordinator::RequestNotPickedCallback not_picked_callback, 39 RequestCoordinator::RequestNotPickedCallback not_picked_callback,
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 } 252 }
251 } 253 }
252 } 254 }
253 255
254 // Callback used after expired requests are deleted from the queue and notifies 256 // Callback used after expired requests are deleted from the queue and notifies
255 // the coordinator. 257 // the coordinator.
256 void RequestPicker::OnRequestExpired( 258 void RequestPicker::OnRequestExpired(
257 const RequestQueue::UpdateMultipleRequestResults& results, 259 const RequestQueue::UpdateMultipleRequestResults& results,
258 const std::vector<std::unique_ptr<SavePageRequest>> requests) { 260 const std::vector<std::unique_ptr<SavePageRequest>> requests) {
259 std::vector<std::unique_ptr<SavePageRequest>>::const_iterator request; 261 std::vector<std::unique_ptr<SavePageRequest>>::const_iterator request;
260 for (request = requests.begin(); request != requests.end(); ++request) 262 for (request = requests.begin(); request != requests.end(); ++request) {
261 notifier_->NotifyCompleted( 263 notifier_->NotifyCompleted(
262 *(request->get()), 264 *(request->get()),
263 RequestCoordinator::BackgroundSavePageResult::EXPIRED); 265 RequestCoordinator::BackgroundSavePageResult::EXPIRED);
266 event_logger_->RecordDroppedSavePageRequest(
Dmitry Titov 2016/09/12 19:43:13 I'd record the log before calling NotifyCompleted,
dougarnett 2016/09/12 20:51:49 Done.
267 request->get()->client_id().name_space,
268 RequestCoordinator::BackgroundSavePageResult::EXPIRED,
269 request->get()->request_id());
270 }
264 } 271 }
265 272
266 } // namespace offline_pages 273 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698