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

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: Created 3 years, 10 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // updating the status in the request queue failed. 54 // updating the status in the request queue failed.
55 QUEUE_UPDATE_FAILED = 13, 55 QUEUE_UPDATE_FAILED = 13,
56 // NOTE: insert new values above this line and update histogram enum too. 56 // NOTE: insert new values above this line and update histogram enum too.
57 STATUS_COUNT 57 STATUS_COUNT
58 }; 58 };
59 59
60 // Reports the completion status of a request. 60 // Reports the completion status of a request.
61 // TODO(dougarnett): consider passing back a request id instead of request. 61 // TODO(dougarnett): consider passing back a request id instead of request.
62 typedef base::Callback<void(const SavePageRequest&, RequestStatus)> 62 typedef base::Callback<void(const SavePageRequest&, RequestStatus)>
63 CompletionCallback; 63 CompletionCallback;
64 // Reports that the cancel operation has completed.
65 // TODO(chili): make save operation cancellable.
66 typedef base::Callback<void(int64_t request_id)> CancelCallback;
64 67
65 Offliner() {} 68 Offliner() {}
66 virtual ~Offliner() {} 69 virtual ~Offliner() {}
67 70
68 // Processes |request| to load and save an offline page. 71 // Processes |request| to load and save an offline page.
69 // Returns whether the request was accepted or not. |callback| is guaranteed 72 // Returns whether the request was accepted or not. |callback| is guaranteed
70 // to be called if the request was accepted and |Cancel()| is not called. 73 // to be called if the request was accepted and |Cancel()| is not called.
71 virtual bool LoadAndSave(const SavePageRequest& request, 74 virtual bool LoadAndSave(const SavePageRequest& request,
72 const CompletionCallback& callback) = 0; 75 const CompletionCallback& callback) = 0;
73 76
74 // Clears the currently processing request, if any, and skips running its 77 // Clears the currently processing request, if any, and skips running its
75 // CompletionCallback. 78 // CompletionCallback.
76 virtual void Cancel() = 0; 79 virtual void Cancel(const CancelCallback& callback) = 0;
77 80
78 // TODO(dougarnett): add policy support methods. 81 // TODO(dougarnett): add policy support methods.
79 }; 82 };
80 83
81 } // namespace offline_pages 84 } // namespace offline_pages
82 85
83 #endif // COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_H_ 86 #endif // COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698