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

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: Fixes status string send to event logger (was hardwired to "Saved" without checking actual status) 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 "base/callback.h" 8 #include "base/callback.h"
9 9
10 namespace offline_pages { 10 namespace offline_pages {
(...skipping 21 matching lines...) Expand all
32 // Prerendering failed to load page. 32 // Prerendering failed to load page.
33 PRERENDERING_FAILED = 5, 33 PRERENDERING_FAILED = 5,
34 // Failed to save loaded page. 34 // Failed to save loaded page.
35 SAVE_FAILED = 6, 35 SAVE_FAILED = 6,
36 // Foreground transition canceled request. 36 // Foreground transition canceled request.
37 FOREGROUND_CANCELED = 7, 37 FOREGROUND_CANCELED = 7,
38 // 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.
39 STATUS_COUNT 39 STATUS_COUNT
40 }; 40 };
41 41
42 static std::string RequestStatusToString(RequestStatus request_status) {
43 switch (request_status) {
44 case UNKNOWN: return "Unknown";
45 case LOADED: return "LOADED";
46 case SAVED: return "SAVED";
47 case REQUEST_COORDINATOR_CANCELED: return "REQUEST_COORDINATOR_CANCELED";
48 case PRERENDERING_CANCELED: return "PRERENDERING_CANCELED";
49 case PRERENDERING_FAILED: return "PRERENDERING_FAILED";
50 case SAVE_FAILED: return "SAVE_FAILED";
51 case FOREGROUND_CANCELED: return "FOREGROUND_CANCELED";
52 case STATUS_COUNT: return "STATUS_COUNT";
Pete Williamson 2016/08/03 20:44:55 SHould we really be returning a string for the cou
dougarnett 2016/08/03 21:40:01 update to DCHECK and empty string for non-Debug?
Pete Williamson 2016/08/03 22:29:12 sounds good
dougarnett 2016/08/03 23:33:51 Done.
53 }
54 }
55
42 // Reports the completion status of a request. 56 // Reports the completion status of a request.
43 // TODO(dougarnett): consider passing back a request id instead of request. 57 // TODO(dougarnett): consider passing back a request id instead of request.
44 typedef base::Callback<void(const SavePageRequest&, RequestStatus)> 58 typedef base::Callback<void(const SavePageRequest&, RequestStatus)>
45 CompletionCallback; 59 CompletionCallback;
46 60
47 Offliner() {} 61 Offliner() {}
48 virtual ~Offliner() {} 62 virtual ~Offliner() {}
49 63
50 // Processes |request| to load and save an offline page. 64 // Processes |request| to load and save an offline page.
51 // Returns whether the request was accepted or not. |callback| is guaranteed 65 // 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. 66 // to be called if the request was accepted and |Cancel()| is not called.
53 virtual bool LoadAndSave( 67 virtual bool LoadAndSave(
54 const SavePageRequest& request, 68 const SavePageRequest& request,
55 const CompletionCallback& callback) = 0; 69 const CompletionCallback& callback) = 0;
56 70
57 // Clears the currently processing request, if any, and skips running its 71 // Clears the currently processing request, if any, and skips running its
58 // CompletionCallback. 72 // CompletionCallback.
59 virtual void Cancel() = 0; 73 virtual void Cancel() = 0;
60 74
61 // TODO(dougarnett): add policy support methods. 75 // TODO(dougarnett): add policy support methods.
62 }; 76 };
63 77
64 } // namespace offline_pages 78 } // namespace offline_pages
65 79
66 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_ 80 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_OFFLINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698