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

Side by Side Diff: components/offline_pages/background/request_coordinator.h

Issue 2260963003: [Offline pages] Enabling notifications for pages saved later (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing missed TODO 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_REQUEST_COORDINATOR_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 6 #define COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "base/supports_user_data.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
16 #include "components/keyed_service/core/keyed_service.h" 17 #include "components/keyed_service/core/keyed_service.h"
17 #include "components/offline_pages/background/device_conditions.h" 18 #include "components/offline_pages/background/device_conditions.h"
18 #include "components/offline_pages/background/offliner.h" 19 #include "components/offline_pages/background/offliner.h"
19 #include "components/offline_pages/background/request_coordinator_event_logger.h " 20 #include "components/offline_pages/background/request_coordinator_event_logger.h "
20 #include "components/offline_pages/background/request_notifier.h" 21 #include "components/offline_pages/background/request_notifier.h"
21 #include "components/offline_pages/background/request_queue.h" 22 #include "components/offline_pages/background/request_queue.h"
22 #include "components/offline_pages/background/scheduler.h" 23 #include "components/offline_pages/background/scheduler.h"
23 #include "url/gurl.h" 24 #include "url/gurl.h"
24 25
25 namespace offline_pages { 26 namespace offline_pages {
26 27
27 struct ClientId; 28 struct ClientId;
28 class OfflinerPolicy; 29 class OfflinerPolicy;
29 class OfflinerFactory; 30 class OfflinerFactory;
30 class Offliner; 31 class Offliner;
31 class RequestPicker; 32 class RequestPicker;
32 class SavePageRequest; 33 class SavePageRequest;
33 class Scheduler; 34 class Scheduler;
34 35
35 // Coordinates queueing and processing save page later requests. 36 // Coordinates queueing and processing save page later requests.
36 class RequestCoordinator : public KeyedService, public RequestNotifier { 37 class RequestCoordinator : public KeyedService,
38 public RequestNotifier,
39 public base::SupportsUserData {
37 public: 40 public:
38 41
39 // Nested observer class. To make sure that no events are missed, the client 42 // Nested observer class. To make sure that no events are missed, the client
40 // code should first register for notifications, then |GetAllRequests|, and 43 // code should first register for notifications, then |GetAllRequests|, and
41 // ignore all events before the return from |GetAllRequests|, and consume 44 // ignore all events before the return from |GetAllRequests|, and consume
42 // events after the return callback from |GetAllRequests|. 45 // events after the return callback from |GetAllRequests|.
43 class Observer { 46 class Observer {
44 public: 47 public:
48 virtual ~Observer() = default;
49
45 virtual void OnAdded(const SavePageRequest& request) = 0; 50 virtual void OnAdded(const SavePageRequest& request) = 0;
46 virtual void OnCompleted(const SavePageRequest& request, 51 virtual void OnCompleted(const SavePageRequest& request,
47 RequestNotifier::SavePageStatus status) = 0; 52 RequestNotifier::SavePageStatus status) = 0;
48 virtual void OnChanged(const SavePageRequest& request) = 0; 53 virtual void OnChanged(const SavePageRequest& request) = 0;
49 }; 54 };
50 55
51 // Callback to report when the processing of a triggered task is complete. 56 // Callback to report when the processing of a triggered task is complete.
52 typedef base::Callback<void(const SavePageRequest& request)> 57 typedef base::Callback<void(const SavePageRequest& request)>
53 RequestPickedCallback; 58 RequestPickedCallback;
54 typedef base::Callback<void()> RequestQueueEmptyCallback; 59 typedef base::Callback<void()> RequestQueueEmptyCallback;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 base::TimeDelta offliner_timeout_; 239 base::TimeDelta offliner_timeout_;
235 // Allows us to pass a weak pointer to callbacks. 240 // Allows us to pass a weak pointer to callbacks.
236 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_; 241 base::WeakPtrFactory<RequestCoordinator> weak_ptr_factory_;
237 242
238 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); 243 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
239 }; 244 };
240 245
241 } // namespace offline_pages 246 } // namespace offline_pages
242 247
243 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 248 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698