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

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

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 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_
7
8 #include <string>
9
10 #include "base/callback.h"
11
12 namespace offline_pages {
13
14 class SavePageRequest;
15
16 // Interface of a class responsible for constructing an offline page given
17 // a request with a URL.
18 class Offliner {
19 public:
20 // Status of processing an offline page request.
21 // WARNING: You must update histograms.xml to match any changes made to
22 // this enum (ie, OfflinePagesBackgroundOfflinerRequestStatus histogram enum).
23 // Also update related switch code in RequestCoordinatorEventLogger.
24 enum RequestStatus {
25 // No status determined/reported yet. Interim status, not sent in callback.
26 UNKNOWN = 0,
27 // Page loaded but not (yet) saved. Interim status, not sent in callback.
28 LOADED = 1,
29 // Offline page snapshot saved.
30 SAVED = 2,
31 // RequestCoordinator canceled request.
32 REQUEST_COORDINATOR_CANCELED = 3,
33 // Prerendering was canceled.
34 PRERENDERING_CANCELED = 4,
35 // Prerendering failed to load page.
36 PRERENDERING_FAILED = 5,
37 // Failed to save loaded page.
38 SAVE_FAILED = 6,
39 // Foreground transition canceled request.
40 FOREGROUND_CANCELED = 7,
41 // RequestCoordinator canceled request attempt per time limit.
42 REQUEST_COORDINATOR_TIMED_OUT = 8,
43 // The loader did not accept/start the request.
44 PRERENDERING_NOT_STARTED = 9,
45 // Prerendering failed with hard error so should not retry the request.
46 PRERENDERING_FAILED_NO_RETRY = 10,
47 // Prerendering failed with some error that suggests we should not continue
48 // processing another request at this time.
49 PRERENDERING_FAILED_NO_NEXT = 11,
50 // NOTE: insert new values above this line and update histogram enum too.
51 STATUS_COUNT
52 };
53
54 // Reports the completion status of a request.
55 // TODO(dougarnett): consider passing back a request id instead of request.
56 typedef base::Callback<void(const SavePageRequest&, RequestStatus)>
57 CompletionCallback;
58
59 Offliner() {}
60 virtual ~Offliner() {}
61
62 // Processes |request| to load and save an offline page.
63 // Returns whether the request was accepted or not. |callback| is guaranteed
64 // to be called if the request was accepted and |Cancel()| is not called.
65 virtual bool LoadAndSave(
66 const SavePageRequest& request,
67 const CompletionCallback& callback) = 0;
68
69 // Clears the currently processing request, if any, and skips running its
70 // CompletionCallback.
71 virtual void Cancel() = 0;
72
73 // TODO(dougarnett): add policy support methods.
74 };
75
76 } // namespace offline_pages
77
78 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698