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

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

Issue 1971923004: Add calls to the offliner and unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR feedback per DougArnett Created 4 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_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 "components/keyed_service/core/keyed_service.h" 13 #include "components/keyed_service/core/keyed_service.h"
14 #include "components/offline_pages/background/offliner.h"
14 #include "components/offline_pages/background/request_queue.h" 15 #include "components/offline_pages/background/request_queue.h"
15 #include "url/gurl.h" 16 #include "url/gurl.h"
16 17
17 namespace offline_pages { 18 namespace offline_pages {
18 19
19 struct ClientId; 20 struct ClientId;
20 class OfflinerPolicy; 21 class OfflinerPolicy;
21 class OfflinerFactory; 22 class OfflinerFactory;
22 class Offliner; 23 class Offliner;
23 class SavePageRequest; 24 class SavePageRequest;
(...skipping 27 matching lines...) Expand all
51 // caller to abort processing; otherwise, processing will complete on 52 // caller to abort processing; otherwise, processing will complete on
52 // its own. In either case, the callback will be called when processing 53 // its own. In either case, the callback will be called when processing
53 // is stopped or complete. 54 // is stopped or complete.
54 void StopProcessing(); 55 void StopProcessing();
55 56
56 // Returns the request queue used for requests. Coordinator keeps ownership. 57 // Returns the request queue used for requests. Coordinator keeps ownership.
57 RequestQueue* GetQueue() { return queue_.get(); } 58 RequestQueue* GetQueue() { return queue_.get(); }
58 59
59 Scheduler* GetSchedulerForTesting() { return scheduler_.get(); } 60 Scheduler* GetSchedulerForTesting() { return scheduler_.get(); }
60 61
62 // Returns the status of the most recent offlining.
63 Offliner::CompletionStatus last_offlining_status() {
64 return last_offlining_status_;
65 }
66
61 private: 67 private:
62 void AddRequestResultCallback(RequestQueue::AddRequestResult result, 68 void AddRequestResultCallback(RequestQueue::AddRequestResult result,
63 const SavePageRequest& request); 69 const SavePageRequest& request);
64 // OfflinerPolicy. Used to store policies. Owned. 70
71 void SendRequestToOffliner(SavePageRequest& request);
72
73 void OfflinerDoneCallback(const SavePageRequest& request,
74 Offliner::CompletionStatus status);
75
76 // RequestCoordinator takes over ownership of the policy
65 std::unique_ptr<OfflinerPolicy> policy_; 77 std::unique_ptr<OfflinerPolicy> policy_;
66 // OfflinerFactory. Used to create offline pages. Owned. 78 // OfflinerFactory. Used to create offline pages. Owned.
67 std::unique_ptr<OfflinerFactory> factory_; 79 std::unique_ptr<OfflinerFactory> factory_;
68 // RequestQueue. Used to store incoming requests. Owned. 80 // RequestQueue. Used to store incoming requests. Owned.
69 std::unique_ptr<RequestQueue> queue_; 81 std::unique_ptr<RequestQueue> queue_;
70 // Scheduler. Used to request a callback when network is available. Owned. 82 // Scheduler. Used to request a callback when network is available. Owned.
71 std::unique_ptr<Scheduler> scheduler_; 83 std::unique_ptr<Scheduler> scheduler_;
84 // Status of the most recent offlining.
85 Offliner::CompletionStatus last_offlining_status_;
72 86
73 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator); 87 DISALLOW_COPY_AND_ASSIGN(RequestCoordinator);
74 }; 88 };
75 89
76 } // namespace offline_pages 90 } // namespace offline_pages
77 91
78 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_ 92 #endif // COMPONENTS_OFFLINE_PAGES_BACKGROUND_REQUEST_COORDINATOR_H_
OLDNEW
« no previous file with comments | « components/offline_pages/background/offliner.h ('k') | components/offline_pages/background/request_coordinator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698