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

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

Issue 2742833004: Fix the Download Notifications for Offline Pages to indicate bytes loaded. (Closed)
Patch Set: 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 LOADING_NOT_ACCEPTED = 12, 52 LOADING_NOT_ACCEPTED = 12,
53 // The RequestCoordinator did not start loading the request because 53 // The RequestCoordinator did not start loading the request because
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 // 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 load progress of a request.
63 typedef base::Callback<void(const SavePageRequest&, int64_t received_bytes)>
64 ProgressCallback;
62 // Reports the completion status of a request. 65 // Reports the completion status of a request.
63 // TODO(dougarnett): consider passing back a request id instead of request. 66 // TODO(dougarnett): consider passing back a request id instead of request.
64 typedef base::Callback<void(const SavePageRequest&, RequestStatus)> 67 typedef base::Callback<void(const SavePageRequest&, RequestStatus)>
65 CompletionCallback; 68 CompletionCallback;
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. |completion_callback| is
72 // to be called if the request was accepted and |Cancel()| is not called. 75 // guaranteed to be called if the request was accepted and |Cancel()| is not
76 // called on it. |progress_callback| is invoked periodically to report the
77 // number of bytes received from the network (for UI purposes).
73 virtual bool LoadAndSave(const SavePageRequest& request, 78 virtual bool LoadAndSave(const SavePageRequest& request,
74 const CompletionCallback& callback) = 0; 79 const CompletionCallback& completion_callback,
80 const ProgressCallback& progress_callback) = 0;
75 81
76 // Clears the currently processing request, if any, and skips running its 82 // Clears the currently processing request, if any, and skips running its
77 // CompletionCallback. 83 // CompletionCallback.
78 virtual void Cancel() = 0; 84 virtual void Cancel() = 0;
79 85
80 // Handles timeout scenario. Returns true if lowbar is met and try to do a 86 // Handles timeout scenario. Returns true if lowbar is met and try to do a
81 // snapshot of the current webcontents. 87 // snapshot of the current webcontents.
82 virtual bool HandleTimeout(const SavePageRequest& request) = 0; 88 virtual bool HandleTimeout(const SavePageRequest& request) = 0;
83 89
84 // TODO(dougarnett): add policy support methods. 90 // TODO(dougarnett): add policy support methods.
85 }; 91 };
86 92
87 } // namespace offline_pages 93 } // namespace offline_pages
88 94
89 #endif // COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_H_ 95 #endif // COMPONENTS_OFFLINE_PAGES_CORE_BACKGROUND_OFFLINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698