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

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

Issue 2489443002: Move all components/offline_pages/ files into component/offline_pages/core (Closed)
Patch Set: rebase Created 4 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/offline_pages/background/request_coordinator_event_logger.h "
6
7 namespace offline_pages {
8
9 namespace {
10
11 static std::string OfflinerRequestStatusToString(
12 Offliner::RequestStatus request_status) {
13 switch (request_status) {
14 case Offliner::UNKNOWN:
15 return "UNKNOWN";
16 case Offliner::LOADED:
17 return "LOADED";
18 case Offliner::SAVED:
19 return "SAVED";
20 case Offliner::REQUEST_COORDINATOR_CANCELED:
21 return "REQUEST_COORDINATOR_CANCELED";
22 case Offliner::PRERENDERING_CANCELED:
23 return "PRERENDERING_CANCELED";
24 case Offliner::PRERENDERING_FAILED:
25 return "PRERENDERING_FAILED";
26 case Offliner::SAVE_FAILED:
27 return "SAVE_FAILED";
28 case Offliner::FOREGROUND_CANCELED:
29 return "FOREGROUND_CANCELED";
30 case Offliner::REQUEST_COORDINATOR_TIMED_OUT:
31 return "REQUEST_COORDINATOR_TIMED_OUT";
32 case Offliner::PRERENDERING_NOT_STARTED:
33 return "PRERENDERING_NOT_STARTED";
34 case Offliner::PRERENDERING_FAILED_NO_RETRY:
35 return "PRERENDERING_FAILED_NO_RETRY";
36 case Offliner::PRERENDERING_FAILED_NO_NEXT:
37 return "PRERENDERING_FAILED_NO_NEXT";
38 default:
39 NOTREACHED();
40 return std::to_string(static_cast<int>(request_status));
41 }
42 }
43
44 static std::string BackgroundSavePageResultToString(
45 RequestNotifier::BackgroundSavePageResult result) {
46 switch (result) {
47 case RequestNotifier::BackgroundSavePageResult::SUCCESS:
48 return "SUCCESS";
49 case RequestNotifier::BackgroundSavePageResult::PRERENDER_FAILURE:
50 return "PRERENDER_FAILURE";
51 case RequestNotifier::BackgroundSavePageResult::PRERENDER_CANCELED:
52 return "PRERENDER_CANCELED";
53 case RequestNotifier::BackgroundSavePageResult::FOREGROUND_CANCELED:
54 return "FOREGROUND_CANCELED";
55 case RequestNotifier::BackgroundSavePageResult::SAVE_FAILED:
56 return "SAVE_FAILED";
57 case RequestNotifier::BackgroundSavePageResult::EXPIRED:
58 return "EXPIRED";
59 case RequestNotifier::BackgroundSavePageResult::RETRY_COUNT_EXCEEDED:
60 return "RETRY_COUNT_EXCEEDED";
61 case RequestNotifier::BackgroundSavePageResult::START_COUNT_EXCEEDED:
62 return "START_COUNT_EXCEEDED";
63 case RequestNotifier::BackgroundSavePageResult::REMOVED:
64 return "REMOVED";
65 default:
66 NOTREACHED();
67 return std::to_string(static_cast<int>(result));
68 }
69 }
70
71 static std::string UpdateRequestResultToString(UpdateRequestResult result) {
72 switch (result) {
73 case UpdateRequestResult::SUCCESS:
74 return "SUCCESS";
75 case UpdateRequestResult::STORE_FAILURE:
76 return "STORE_FAILURE";
77 case UpdateRequestResult::REQUEST_DOES_NOT_EXIST:
78 return "REQUEST_DOES_NOT_EXIST";
79 default:
80 NOTREACHED();
81 return std::to_string(static_cast<int>(result));
82 }
83 }
84
85 } // namespace
86
87 void RequestCoordinatorEventLogger::RecordOfflinerResult(
88 const std::string& name_space,
89 Offliner::RequestStatus new_status,
90 int64_t request_id) {
91 RecordActivity("Background save attempt for " + name_space + ":" +
92 std::to_string(request_id) + " - " +
93 OfflinerRequestStatusToString(new_status));
94 }
95
96 void RequestCoordinatorEventLogger::RecordDroppedSavePageRequest(
97 const std::string& name_space,
98 RequestNotifier::BackgroundSavePageResult result,
99 int64_t request_id) {
100 RecordActivity("Background save request removed " + name_space + ":" +
101 std::to_string(request_id) + " - " +
102 BackgroundSavePageResultToString(result));
103 }
104
105 void RequestCoordinatorEventLogger::RecordUpdateRequestFailed(
106 const std::string& name_space,
107 UpdateRequestResult result) {
108 RecordActivity("Updating queued request for " + name_space + " failed - " +
109 UpdateRequestResultToString(result));
110 }
111
112 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698