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

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

Issue 2836863002: [Offline pages] Removing active_request_ from request coordinator (Closed)
Patch Set: Addressing code review feedback and fixing app status change bug Created 3 years, 7 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_CORE_BACKGROUND_OFFLINER_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_H_
6 #define COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_H_ 6 #define COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 // We saved a snapshot on the last retry, after timeout. 58 // We saved a snapshot on the last retry, after timeout.
59 SAVED_ON_LAST_RETRY = 15, 59 SAVED_ON_LAST_RETRY = 15,
60 // NOTE: insert new values above this line and update histogram enum too. 60 // NOTE: insert new values above this line and update histogram enum too.
61 STATUS_COUNT 61 STATUS_COUNT
62 }; 62 };
63 63
64 // Reports the load progress of a request. 64 // Reports the load progress of a request.
65 typedef base::Callback<void(const SavePageRequest&, int64_t received_bytes)> 65 typedef base::Callback<void(const SavePageRequest&, int64_t received_bytes)>
66 ProgressCallback; 66 ProgressCallback;
67 // Reports the completion status of a request. 67 // Reports the completion status of a request.
68 // TODO(dougarnett): consider passing back a request id instead of request.
69 typedef base::Callback<void(const SavePageRequest&, RequestStatus)> 68 typedef base::Callback<void(const SavePageRequest&, RequestStatus)>
70 CompletionCallback; 69 CompletionCallback;
71 // Reports that the cancel operation has completed. 70 // Reports that the cancel operation has completed.
72 // TODO(chili): make save operation cancellable. 71 // TODO(chili): make save operation cancellable.
73 typedef base::Callback<void(int64_t request_id)> CancelCallback; 72 typedef base::Callback<void(const SavePageRequest&)> CancelCallback;
74 73
75 Offliner() {} 74 Offliner() {}
76 virtual ~Offliner() {} 75 virtual ~Offliner() {}
77 76
78 // Processes |request| to load and save an offline page. 77 // Processes |request| to load and save an offline page.
79 // Returns whether the request was accepted or not. |completion_callback| is 78 // Returns whether the request was accepted or not. |completion_callback| is
80 // guaranteed to be called if the request was accepted and |Cancel()| is not 79 // guaranteed to be called if the request was accepted and |Cancel()| is not
81 // called on it. |progress_callback| is invoked periodically to report the 80 // called on it. |progress_callback| is invoked periodically to report the
82 // number of bytes received from the network (for UI purposes). 81 // number of bytes received from the network (for UI purposes).
83 virtual bool LoadAndSave(const SavePageRequest& request, 82 virtual bool LoadAndSave(const SavePageRequest& request,
84 const CompletionCallback& completion_callback, 83 const CompletionCallback& completion_callback,
85 const ProgressCallback& progress_callback) = 0; 84 const ProgressCallback& progress_callback) = 0;
86 85
87 // Clears the currently processing request, if any, and skips running its 86 // Clears the currently processing request, if any, and skips running its
88 // CompletionCallback. 87 // CompletionCallback. Returns false if there is nothing to cancel, otherwise
89 virtual void Cancel(const CancelCallback& callback) = 0; 88 // returns true and canceled request will be delivered using callback.
89 virtual bool Cancel(const CancelCallback& callback) = 0;
90 90
91 // Handles timeout scenario. Returns true if lowbar is met and try to do a 91 // Handles timeout scenario. Returns true if lowbar is met and try to do a
92 // snapshot of the current webcontents. 92 // snapshot of the current webcontents. If that is the case, the result of
93 virtual bool HandleTimeout(const SavePageRequest& request) = 0; 93 // offlining will be provided by |completion_callback|.
94 virtual bool HandleTimeout(int64_t request_id) = 0;
94 95
95 // TODO(dougarnett): add policy support methods. 96 // TODO(dougarnett): add policy support methods.
96 }; 97 };
97 98
98 } // namespace offline_pages 99 } // namespace offline_pages
99 100
100 #endif // COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_H_ 101 #endif // COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698