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

Side by Side Diff: components/offline_pages/background/offliner.h

Issue 2104393002: Adds UMA for PrerenderingOffliner request processing result status. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adds note about interim offliner status codes and performs DCHECK that offliner does not return the… Created 4 years, 5 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 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_ 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 9
10 namespace offline_pages { 10 namespace offline_pages {
11 11
12 class SavePageRequest; 12 class SavePageRequest;
13 13
14 // Interface of a class responsible for constructing an offline page given 14 // Interface of a class responsible for constructing an offline page given
15 // a request with a URL. 15 // a request with a URL.
16 class Offliner { 16 class Offliner {
17 public: 17 public:
18 // Status of processing an offline page request. 18 // Status of processing an offline page request.
19 enum class RequestStatus { 19 // WARNING: You must update histograms.xml to match any changes made to
20 UNKNOWN, // No status determined/reported yet. 20 // this enum (ie, OfflinePagesBackgroundOfflinerRequestStatus histogram enum).
21 LOADED, // Page loaded but not (yet) saved. 21 enum RequestStatus {
22 SAVED, // Offline page snapshot saved. 22 UNKNOWN = 0, // No status determined/reported yet. Interim status, not sent
23 CANCELED, // Request was canceled. 23 // in callback.
24 FAILED, // Failed to load page. 24 LOADED = 1, // Page loaded but not (yet) saved. Interim status, not sent in
25 FAILED_SAVE, // Failed to save loaded page. 25 // callback.
26 // TODO(dougarnett): Define a retry-able failure status. 26 SAVED = 2, // Offline page snapshot saved.
27 REQUEST_COORDINATOR_CANCELED = 3, // RequestCoordinator canceled request.
28 PRERENDERING_CANCELED = 4, // Prerendering was canceled.
29 PRERENDERING_FAILED = 5, // Prerendering failed to load page.
30 SAVE_FAILED = 6, // Failed to save loaded page.
31 // NOTE: insert new values above this line and update histogram enum too.
32 STATUS_COUNT
27 }; 33 };
28 34
29 // Reports the completion status of a request. 35 // Reports the completion status of a request.
30 // TODO(dougarnett): consider passing back a request id instead of request. 36 // TODO(dougarnett): consider passing back a request id instead of request.
31 typedef base::Callback<void(const SavePageRequest&, RequestStatus)> 37 typedef base::Callback<void(const SavePageRequest&, RequestStatus)>
32 CompletionCallback; 38 CompletionCallback;
33 39
34 Offliner() {} 40 Offliner() {}
35 virtual ~Offliner() {} 41 virtual ~Offliner() {}
36 42
37 // Processes |request| to load and save an offline page. 43 // Processes |request| to load and save an offline page.
38 // Returns whether the request was accepted or not. |callback| is guaranteed 44 // Returns whether the request was accepted or not. |callback| is guaranteed
39 // to be called if the request was accepted and |Cancel()| is not called. 45 // to be called if the request was accepted and |Cancel()| is not called.
40 virtual bool LoadAndSave( 46 virtual bool LoadAndSave(
41 const SavePageRequest& request, 47 const SavePageRequest& request,
42 const CompletionCallback& callback) = 0; 48 const CompletionCallback& callback) = 0;
43 49
44 // Clears the currently processing request, if any. 50 // Clears the currently processing request, if any, and skips running its
51 // CompletionCallback.
45 virtual void Cancel() = 0; 52 virtual void Cancel() = 0;
46 53
47 // TODO(dougarnett): add policy support methods. 54 // TODO(dougarnett): add policy support methods.
48 }; 55 };
49 56
50 } // namespace offline_pages 57 } // namespace offline_pages
51 58
52 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_ 59 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698