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

Side by Side Diff: components/offline_pages/core/prefetch/prefetch_dispatcher_impl.cc

Issue 2914703002: [Offline Prefetch] Backoff support for PrefetchBackgroundTask (Closed)
Patch Set: Address feedback Created 3 years, 6 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/core/prefetch/prefetch_dispatcher_impl.h" 5 #include "components/offline_pages/core/prefetch/prefetch_dispatcher_impl.h"
6 6
7 #include "base/bind.h"
8 #include "base/task_runner.h"
9 #include "base/threading/thread_task_runner_handle.h"
7 #include "url/gurl.h" 10 #include "url/gurl.h"
8 11
9 namespace offline_pages { 12 namespace offline_pages {
10 13
14 namespace {
15 void DeleteBackgroundTaskHelper(
16 std::unique_ptr<PrefetchDispatcher::ScopedBackgroundTask> task) {
17 task.reset();
18 }
19 } // namespace
20
11 PrefetchDispatcherImpl::PrefetchDispatcherImpl() {} 21 PrefetchDispatcherImpl::PrefetchDispatcherImpl() {}
12 22
13 PrefetchDispatcherImpl::~PrefetchDispatcherImpl() = default; 23 PrefetchDispatcherImpl::~PrefetchDispatcherImpl() = default;
14 24
15 void PrefetchDispatcherImpl::AddCandidatePrefetchURLs( 25 void PrefetchDispatcherImpl::AddCandidatePrefetchURLs(
16 const std::vector<PrefetchURL>& url_suggestions) { 26 const std::vector<PrefetchURL>& url_suggestions) {
17 NOTIMPLEMENTED(); 27 NOTIMPLEMENTED();
18 } 28 }
19 void PrefetchDispatcherImpl::RemoveAllUnprocessedPrefetchURLs( 29 void PrefetchDispatcherImpl::RemoveAllUnprocessedPrefetchURLs(
20 const std::string& name_space) { 30 const std::string& name_space) {
21 NOTIMPLEMENTED(); 31 NOTIMPLEMENTED();
22 } 32 }
23 33
24 void PrefetchDispatcherImpl::RemovePrefetchURLsByClientId( 34 void PrefetchDispatcherImpl::RemovePrefetchURLsByClientId(
25 const ClientId& client_id) { 35 const ClientId& client_id) {
26 NOTIMPLEMENTED(); 36 NOTIMPLEMENTED();
27 } 37 }
28 38
29 void PrefetchDispatcherImpl::BeginBackgroundTask( 39 void PrefetchDispatcherImpl::BeginBackgroundTask(
30 std::unique_ptr<ScopedBackgroundTask> task) { 40 std::unique_ptr<ScopedBackgroundTask> task) {
31 NOTIMPLEMENTED(); 41 task_ = std::move(task);
32 } 42 }
33 43
34 void PrefetchDispatcherImpl::StopBackgroundTask(ScopedBackgroundTask* task) { 44 void PrefetchDispatcherImpl::StopBackgroundTask() {
35 NOTIMPLEMENTED(); 45 DisposeTask();
46 }
47
48 void PrefetchDispatcherImpl::RequestFinishBackgroundTaskForTest() {
49 DisposeTask();
50 }
51
52 void PrefetchDispatcherImpl::DisposeTask() {
53 if (!task_)
dewittj 2017/06/01 00:22:27 Should this be DCHECK(task_) ?
jianli 2017/06/02 00:48:37 Done.
54 return;
55 // Delay the deletion till the caller finishes.
56 base::ThreadTaskRunnerHandle::Get()->PostTask(
57 FROM_HERE,
58 base::Bind(&DeleteBackgroundTaskHelper, base::Passed(std::move(task_))));
36 } 59 }
37 60
38 } // namespace offline_pages 61 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698