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

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

Issue 2007783002: Adds PrerenderingOffliner implementation for handling Loader callbacks and then performing SavePage… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ploader
Patch Set: Update for petewil comment Created 4 years, 6 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
« no previous file with comments | « chrome/browser/android/offline_pages/prerendering_offliner_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 enum class RequestStatus {
20 UNKNOWN, // No status determined/reported yet. 20 UNKNOWN, // No status determined/reported yet.
21 LOADED, // Page loaded but not (yet) saved. 21 LOADED, // Page loaded but not (yet) saved.
22 SAVED, // Offline page snapshot saved. 22 SAVED, // Offline page snapshot saved.
23 CANCELED, // Request was canceled. 23 CANCELED, // Request was canceled.
24 FAILED, // Request failed. 24 FAILED, // Failed to load page.
25 FAILED_SAVE, // Failed to save loaded page.
25 // TODO(dougarnett): Define a retry-able failure status. 26 // TODO(dougarnett): Define a retry-able failure status.
26 }; 27 };
27 28
28 // Reports the completion status of a request. 29 // Reports the completion status of a request.
29 // TODO(dougarnett): consider passing back a request id instead of request. 30 // TODO(dougarnett): consider passing back a request id instead of request.
30 typedef base::Callback<void(const SavePageRequest&, RequestStatus)> 31 typedef base::Callback<void(const SavePageRequest&, RequestStatus)>
31 CompletionCallback; 32 CompletionCallback;
32 33
33 Offliner() {} 34 Offliner() {}
34 virtual ~Offliner() {} 35 virtual ~Offliner() {}
35 36
36 // Processes |request| to load and save an offline page. 37 // Processes |request| to load and save an offline page.
37 // Returns whether the request was accepted or not. 38 // 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.
38 virtual bool LoadAndSave( 40 virtual bool LoadAndSave(
39 const SavePageRequest& request, 41 const SavePageRequest& request,
40 const CompletionCallback& callback) = 0; 42 const CompletionCallback& callback) = 0;
41 43
42 // Clears the currently processing request, if any. 44 // Clears the currently processing request, if any.
43 virtual void Cancel() = 0; 45 virtual void Cancel() = 0;
44 46
45 // TODO(dougarnett): add policy support methods. 47 // TODO(dougarnett): add policy support methods.
46 }; 48 };
47 49
48 } // namespace offline_pages 50 } // namespace offline_pages
49 51
50 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_ 52 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/offline_pages/prerendering_offliner_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698