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

Side by Side Diff: components/offline_pages/core/background/offliner_stub.cc

Issue 2744553005: [Offline Pages] Turn Offliner::Cancel into an async operation to resolve conflicting assumptions be… (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 #include "components/offline_pages/core/background/offliner_stub.h" 5 #include "components/offline_pages/core/background/offliner_stub.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/threading/thread_task_runner_handle.h" 8 #include "base/threading/thread_task_runner_handle.h"
9 #include "components/offline_pages/core/background/save_page_request.h" 9 #include "components/offline_pages/core/background/save_page_request.h"
10 10
(...skipping 21 matching lines...) Expand all
32 const int64_t arbitrary_size = 153LL; 32 const int64_t arbitrary_size = 153LL;
33 base::ThreadTaskRunnerHandle::Get()->PostTask( 33 base::ThreadTaskRunnerHandle::Get()->PostTask(
34 FROM_HERE, base::Bind(progress_callback_, request, arbitrary_size)); 34 FROM_HERE, base::Bind(progress_callback_, request, arbitrary_size));
35 base::ThreadTaskRunnerHandle::Get()->PostTask( 35 base::ThreadTaskRunnerHandle::Get()->PostTask(
36 FROM_HERE, base::Bind(completion_callback_, request, 36 FROM_HERE, base::Bind(completion_callback_, request,
37 Offliner::RequestStatus::SAVED)); 37 Offliner::RequestStatus::SAVED));
38 } 38 }
39 return true; 39 return true;
40 } 40 }
41 41
42 void OfflinerStub::Cancel() { 42 void OfflinerStub::Cancel(const CancelCallback& callback) {
43 cancel_called_ = true; 43 cancel_called_ = true;
44 callback.Run(0LL);
44 } 45 }
45 46
46 bool OfflinerStub::HandleTimeout(const SavePageRequest& request) { 47 bool OfflinerStub::HandleTimeout(const SavePageRequest& request) {
47 if (snapshot_on_last_retry_) { 48 if (snapshot_on_last_retry_) {
48 base::ThreadTaskRunnerHandle::Get()->PostTask( 49 base::ThreadTaskRunnerHandle::Get()->PostTask(
49 FROM_HERE, base::Bind(completion_callback_, request, 50 FROM_HERE, base::Bind(completion_callback_, request,
50 Offliner::RequestStatus::SAVED)); 51 Offliner::RequestStatus::SAVED));
51 return true; 52 return true;
52 } 53 }
53 return false; 54 return false;
54 } 55 }
55 56
56 } // namespace offline_pages 57 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698