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

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

Issue 2149773002: PrerenderingOffliner will abort background load if it sees chrome transitioning to foreground on lo… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revise some comments wrt app listener setting/clearing 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 // WARNING: You must update histograms.xml to match any changes made to 19 // WARNING: You must update histograms.xml to match any changes made to
20 // this enum (ie, OfflinePagesBackgroundOfflinerRequestStatus histogram enum). 20 // this enum (ie, OfflinePagesBackgroundOfflinerRequestStatus histogram enum).
21 enum RequestStatus { 21 enum RequestStatus {
22 UNKNOWN = 0, // No status determined/reported yet. Interim status, not sent 22 // No status determined/reported yet. Interim status, not sent in callback.
23 // in callback. 23 UNKNOWN = 0,
24 LOADED = 1, // Page loaded but not (yet) saved. Interim status, not sent in 24 // Page loaded but not (yet) saved. Interim status, not sent in callback.
25 // callback. 25 LOADED = 1,
26 SAVED = 2, // Offline page snapshot saved. 26 // Offline page snapshot saved.
27 REQUEST_COORDINATOR_CANCELED = 3, // RequestCoordinator canceled request. 27 SAVED = 2,
28 PRERENDERING_CANCELED = 4, // Prerendering was canceled. 28 // RequestCoordinator canceled request.
29 PRERENDERING_FAILED = 5, // Prerendering failed to load page. 29 REQUEST_COORDINATOR_CANCELED = 3,
30 SAVE_FAILED = 6, // Failed to save loaded page. 30 // Prerendering was canceled.
31 PRERENDERING_CANCELED = 4,
32 // Prerendering failed to load page.
33 PRERENDERING_FAILED = 5,
34 // Failed to save loaded page.
35 SAVE_FAILED = 6,
36 // Foreground transition canceled request.
37 FOREGROUND_CANCELED = 7,
31 // NOTE: insert new values above this line and update histogram enum too. 38 // NOTE: insert new values above this line and update histogram enum too.
32 STATUS_COUNT 39 STATUS_COUNT
33 }; 40 };
34 41
35 // Reports the completion status of a request. 42 // Reports the completion status of a request.
36 // TODO(dougarnett): consider passing back a request id instead of request. 43 // TODO(dougarnett): consider passing back a request id instead of request.
37 typedef base::Callback<void(const SavePageRequest&, RequestStatus)> 44 typedef base::Callback<void(const SavePageRequest&, RequestStatus)>
38 CompletionCallback; 45 CompletionCallback;
39 46
40 Offliner() {} 47 Offliner() {}
41 virtual ~Offliner() {} 48 virtual ~Offliner() {}
42 49
43 // Processes |request| to load and save an offline page. 50 // Processes |request| to load and save an offline page.
44 // Returns whether the request was accepted or not. |callback| is guaranteed 51 // Returns whether the request was accepted or not. |callback| is guaranteed
45 // to be called if the request was accepted and |Cancel()| is not called. 52 // to be called if the request was accepted and |Cancel()| is not called.
46 virtual bool LoadAndSave( 53 virtual bool LoadAndSave(
47 const SavePageRequest& request, 54 const SavePageRequest& request,
48 const CompletionCallback& callback) = 0; 55 const CompletionCallback& callback) = 0;
49 56
50 // Clears the currently processing request, if any, and skips running its 57 // Clears the currently processing request, if any, and skips running its
51 // CompletionCallback. 58 // CompletionCallback.
52 virtual void Cancel() = 0; 59 virtual void Cancel() = 0;
53 60
54 // TODO(dougarnett): add policy support methods. 61 // TODO(dougarnett): add policy support methods.
55 }; 62 };
56 63
57 } // namespace offline_pages 64 } // namespace offline_pages
58 65
59 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_ 66 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/offline_pages/prerendering_offliner_unittest.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698