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

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

Issue 2209813002: [Offline Pages] Moves Coordinator to using MarkAttemptStarted/MarkAttemptCompleted API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix trybot complaint for no return value on string mapping methods Created 4 years, 4 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 <string>
9
8 #include "base/callback.h" 10 #include "base/callback.h"
9 11
10 namespace offline_pages { 12 namespace offline_pages {
11 13
12 class SavePageRequest; 14 class SavePageRequest;
13 15
14 // Interface of a class responsible for constructing an offline page given 16 // Interface of a class responsible for constructing an offline page given
15 // a request with a URL. 17 // a request with a URL.
16 class Offliner { 18 class Offliner {
17 public: 19 public:
(...skipping 14 matching lines...) Expand all
32 // Prerendering failed to load page. 34 // Prerendering failed to load page.
33 PRERENDERING_FAILED = 5, 35 PRERENDERING_FAILED = 5,
34 // Failed to save loaded page. 36 // Failed to save loaded page.
35 SAVE_FAILED = 6, 37 SAVE_FAILED = 6,
36 // Foreground transition canceled request. 38 // Foreground transition canceled request.
37 FOREGROUND_CANCELED = 7, 39 FOREGROUND_CANCELED = 7,
38 // NOTE: insert new values above this line and update histogram enum too. 40 // NOTE: insert new values above this line and update histogram enum too.
39 STATUS_COUNT 41 STATUS_COUNT
40 }; 42 };
41 43
44 static std::string RequestStatusToString(RequestStatus request_status) {
45 switch (request_status) {
46 case UNKNOWN: return "UNKNOWN";
47 case LOADED: return "LOADED";
48 case SAVED: return "SAVED";
49 case REQUEST_COORDINATOR_CANCELED: return "REQUEST_COORDINATOR_CANCELED";
50 case PRERENDERING_CANCELED: return "PRERENDERING_CANCELED";
51 case PRERENDERING_FAILED: return "PRERENDERING_FAILED";
52 case SAVE_FAILED: return "SAVE_FAILED";
53 case FOREGROUND_CANCELED: return "FOREGROUND_CANCELED";
54 default:
55 DCHECK(false);
56 return "";
57 }
58 }
59
42 // Reports the completion status of a request. 60 // Reports the completion status of a request.
43 // TODO(dougarnett): consider passing back a request id instead of request. 61 // TODO(dougarnett): consider passing back a request id instead of request.
44 typedef base::Callback<void(const SavePageRequest&, RequestStatus)> 62 typedef base::Callback<void(const SavePageRequest&, RequestStatus)>
45 CompletionCallback; 63 CompletionCallback;
46 64
47 Offliner() {} 65 Offliner() {}
48 virtual ~Offliner() {} 66 virtual ~Offliner() {}
49 67
50 // Processes |request| to load and save an offline page. 68 // Processes |request| to load and save an offline page.
51 // Returns whether the request was accepted or not. |callback| is guaranteed 69 // Returns whether the request was accepted or not. |callback| is guaranteed
52 // to be called if the request was accepted and |Cancel()| is not called. 70 // to be called if the request was accepted and |Cancel()| is not called.
53 virtual bool LoadAndSave( 71 virtual bool LoadAndSave(
54 const SavePageRequest& request, 72 const SavePageRequest& request,
55 const CompletionCallback& callback) = 0; 73 const CompletionCallback& callback) = 0;
56 74
57 // Clears the currently processing request, if any, and skips running its 75 // Clears the currently processing request, if any, and skips running its
58 // CompletionCallback. 76 // CompletionCallback.
59 virtual void Cancel() = 0; 77 virtual void Cancel() = 0;
60 78
61 // TODO(dougarnett): add policy support methods. 79 // TODO(dougarnett): add policy support methods.
62 }; 80 };
63 81
64 } // namespace offline_pages 82 } // namespace offline_pages
65 83
66 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_ 84 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698