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

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

Issue 1969463002: Add a save page request to the request queue (and test it). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove files added in error. 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 #include "components/offline_pages/background/request_coordinator.h" 5 #include "components/offline_pages/background/request_coordinator.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h"
9 #include "components/offline_pages/background/offliner_factory.h" 10 #include "components/offline_pages/background/offliner_factory.h"
10 #include "components/offline_pages/background/offliner_policy.h" 11 #include "components/offline_pages/background/offliner_policy.h"
11 #include "components/offline_pages/background/save_page_request.h" 12 #include "components/offline_pages/background/save_page_request.h"
12 #include "components/offline_pages/offline_page_item.h" 13 #include "components/offline_pages/offline_page_item.h"
13 14
14 namespace offline_pages { 15 namespace offline_pages {
15 16
16 RequestCoordinator::RequestCoordinator( 17 RequestCoordinator::RequestCoordinator(std::unique_ptr<OfflinerPolicy> policy,
17 std::unique_ptr<OfflinerPolicy> policy, 18 std::unique_ptr<OfflinerFactory> factory,
18 std::unique_ptr<OfflinerFactory> factory) { 19 std::unique_ptr<RequestQueue> queue) {
19 // Do setup as needed. 20 // Do setup as needed.
20 // TODO(petewil): Assert policy not null. 21 // TODO(petewil): Assert policy not null.
21 policy_ = std::move(policy); 22 policy_ = std::move(policy);
22 factory_ = std::move(factory); 23 factory_ = std::move(factory);
24 queue_ = std::move(queue);
23 } 25 }
24 26
25 RequestCoordinator::~RequestCoordinator() {} 27 RequestCoordinator::~RequestCoordinator() {}
26 28
27 bool RequestCoordinator::SavePageLater( 29 bool RequestCoordinator::SavePageLater(
28 const GURL& url, const ClientId& client_id) { 30 const GURL& url, const ClientId& client_id) {
31 DVLOG(0) << "URL is " << url << " " << __FUNCTION__;
dougarnett 2016/05/10 20:23:34 maybe not submit? or the @@@@@ one below
Pete Williamson 2016/05/10 21:07:45 Changed both to DVLOG(2). Both of these will help
29 32
30 // TODO(petewil): We need a robust scheme for allocating new IDs. 33 // TODO(petewil): We need a robust scheme for allocating new IDs.
31 // TODO(petewil): Build a SavePageRequest. 34 static int64_t id = 0;
32 // TODO(petewil): Put the request on the request queue, nudge the scheduler. 35
36 // Build a SavePageRequest.
37 offline_pages::SavePageRequest request(
38 id++, url, client_id, base::Time::Now());
fgorski 2016/05/10 21:18:12 nit align Also, please add a TODO to use somethin
Pete Williamson 2016/05/10 22:51:57 Done.
39
40 // Put the request on the request queue.
41 queue_->AddRequest(request,
42 base::Bind(&RequestCoordinator::AddRequestResultCallback,
43 base::Unretained(this)));
fgorski 2016/05/10 21:18:12 base::Unretained should not be used in production.
Pete Williamson 2016/05/10 22:51:57 Done.
44 // TODO: Do I need to persist the request in case the add fails?
fgorski 2016/05/10 21:18:12 Adding a request to the queue is meant to persist
Pete Williamson 2016/05/10 22:51:57 Noted. We'll solve this with a later patch (and I
fgorski 2016/05/11 19:45:15 Acknowledged.
33 45
34 return true; 46 return true;
35 } 47 }
36 48
49 void RequestCoordinator::AddRequestResultCallback(
50 RequestQueue::AddRequestResult result,
51 const SavePageRequest& request) {
52 DVLOG(0) << "@@@@@@ " << __FUNCTION__;
53
54 // Inform the scheduler that we have an outstanding task.
55 // TODO(petewil): implement.
56 }
57
37 bool RequestCoordinator::StartProcessing( 58 bool RequestCoordinator::StartProcessing(
38 const ProcessingDoneCallback& callback) { 59 const ProcessingDoneCallback& callback) {
39 return false; 60 return false;
40 } 61 }
41 62
42 void RequestCoordinator::StopProcessing() { 63 void RequestCoordinator::StopProcessing() {
43 } 64 }
44 65
45 } // namespace offline_pages 66 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698