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

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

Issue 2715433006: [Offline Pages] Turn Offliner::Cancel into an async operation to resolve conflicting assumptions (Closed)
Patch Set: forgot to init Created 3 years, 9 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // Scheduler canceled processing of requests. 56 // Scheduler canceled processing of requests.
57 BACKGROUND_SCHEDULER_CANCELED = 14, 57 BACKGROUND_SCHEDULER_CANCELED = 14,
58 // NOTE: insert new values above this line and update histogram enum too. 58 // NOTE: insert new values above this line and update histogram enum too.
59 STATUS_COUNT 59 STATUS_COUNT
60 }; 60 };
61 61
62 // Reports the completion status of a request. 62 // Reports the completion status of a request.
63 // TODO(dougarnett): consider passing back a request id instead of request. 63 // TODO(dougarnett): consider passing back a request id instead of request.
64 typedef base::Callback<void(const SavePageRequest&, RequestStatus)> 64 typedef base::Callback<void(const SavePageRequest&, RequestStatus)>
65 CompletionCallback; 65 CompletionCallback;
66 // Reports that the cancel operation has completed.
67 // TODO(chili): make save operation cancellable.
68 typedef base::Callback<void(int64_t request_id)> CancelCallback;
66 69
67 Offliner() {} 70 Offliner() {}
68 virtual ~Offliner() {} 71 virtual ~Offliner() {}
69 72
70 // Processes |request| to load and save an offline page. 73 // Processes |request| to load and save an offline page.
71 // Returns whether the request was accepted or not. |callback| is guaranteed 74 // Returns whether the request was accepted or not. |callback| is guaranteed
72 // to be called if the request was accepted and |Cancel()| is not called. 75 // to be called if the request was accepted and |Cancel()| is not called.
73 virtual bool LoadAndSave(const SavePageRequest& request, 76 virtual bool LoadAndSave(const SavePageRequest& request,
74 const CompletionCallback& callback) = 0; 77 const CompletionCallback& callback) = 0;
75 78
76 // Clears the currently processing request, if any, and skips running its 79 // Clears the currently processing request, if any, and skips running its
77 // CompletionCallback. 80 // CompletionCallback.
78 virtual void Cancel() = 0; 81 virtual void Cancel(const CancelCallback& callback) = 0;
79 82
80 // Handles timeout scenario. Returns true if lowbar is met and try to do a 83 // Handles timeout scenario. Returns true if lowbar is met and try to do a
81 // snapshot of the current webcontents. 84 // snapshot of the current webcontents.
82 virtual bool HandleTimeout(const SavePageRequest& request) = 0; 85 virtual bool HandleTimeout(const SavePageRequest& request) = 0;
83 86
84 // TODO(dougarnett): add policy support methods. 87 // TODO(dougarnett): add policy support methods.
85 }; 88 };
86 89
87 } // namespace offline_pages 90 } // namespace offline_pages
88 91
89 #endif // COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_H_ 92 #endif // COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698