OLD | NEW |
| (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 default: | |
37 NOTREACHED(); | |
38 return std::to_string(static_cast<int>(request_status)); | |
39 } | |
40 } | |
41 | |
42 static std::string BackgroundSavePageResultToString( | |
43 RequestNotifier::BackgroundSavePageResult result) { | |
44 switch (result) { | |
45 case RequestNotifier::BackgroundSavePageResult::SUCCESS: | |
46 return "SUCCESS"; | |
47 case RequestNotifier::BackgroundSavePageResult::PRERENDER_FAILURE: | |
48 return "PRERENDER_FAILURE"; | |
49 case RequestNotifier::BackgroundSavePageResult::PRERENDER_CANCELED: | |
50 return "PRERENDER_CANCELED"; | |
51 case RequestNotifier::BackgroundSavePageResult::FOREGROUND_CANCELED: | |
52 return "FOREGROUND_CANCELED"; | |
53 case RequestNotifier::BackgroundSavePageResult::SAVE_FAILED: | |
54 return "SAVE_FAILED"; | |
55 case RequestNotifier::BackgroundSavePageResult::EXPIRED: | |
56 return "EXPIRED"; | |
57 case RequestNotifier::BackgroundSavePageResult::RETRY_COUNT_EXCEEDED: | |
58 return "RETRY_COUNT_EXCEEDED"; | |
59 case RequestNotifier::BackgroundSavePageResult::START_COUNT_EXCEEDED: | |
60 return "START_COUNT_EXCEEDED"; | |
61 case RequestNotifier::BackgroundSavePageResult::REMOVED: | |
62 return "REMOVED"; | |
63 default: | |
64 NOTREACHED(); | |
65 return std::to_string(static_cast<int>(result)); | |
66 } | |
67 } | |
68 | |
69 static std::string UpdateRequestResultToString(UpdateRequestResult result) { | |
70 switch (result) { | |
71 case UpdateRequestResult::SUCCESS: | |
72 return "SUCCESS"; | |
73 case UpdateRequestResult::STORE_FAILURE: | |
74 return "STORE_FAILURE"; | |
75 case UpdateRequestResult::REQUEST_DOES_NOT_EXIST: | |
76 return "REQUEST_DOES_NOT_EXIST"; | |
77 default: | |
78 NOTREACHED(); | |
79 return std::to_string(static_cast<int>(result)); | |
80 } | |
81 } | |
82 | |
83 } // namespace | |
84 | |
85 void RequestCoordinatorEventLogger::RecordOfflinerResult( | |
86 const std::string& name_space, | |
87 Offliner::RequestStatus new_status, | |
88 int64_t request_id) { | |
89 RecordActivity("Background save attempt for " + name_space + ":" + | |
90 std::to_string(request_id) + " - " + | |
91 OfflinerRequestStatusToString(new_status)); | |
92 } | |
93 | |
94 void RequestCoordinatorEventLogger::RecordDroppedSavePageRequest( | |
95 const std::string& name_space, | |
96 RequestNotifier::BackgroundSavePageResult result, | |
97 int64_t request_id) { | |
98 RecordActivity("Background save request removed " + name_space + ":" + | |
99 std::to_string(request_id) + " - " + | |
100 BackgroundSavePageResultToString(result)); | |
101 } | |
102 | |
103 void RequestCoordinatorEventLogger::RecordUpdateRequestFailed( | |
104 const std::string& name_space, | |
105 UpdateRequestResult result) { | |
106 RecordActivity("Updating queued request for " + name_space + " failed - " + | |
107 UpdateRequestResultToString(result)); | |
108 } | |
109 | |
110 } // namespace offline_pages | |
OLD | NEW |