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

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

Issue 2715433006: [Offline Pages] Turn Offliner::Cancel into an async operation to resolve conflicting assumptions (Closed)
Patch Set: forgot to init 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 16 matching lines...) Expand all
27 27
28 // Post the callback on the run loop. 28 // Post the callback on the run loop.
29 if (enable_callback_) { 29 if (enable_callback_) {
30 base::ThreadTaskRunnerHandle::Get()->PostTask( 30 base::ThreadTaskRunnerHandle::Get()->PostTask(
31 FROM_HERE, 31 FROM_HERE,
32 base::Bind(callback, request, Offliner::RequestStatus::SAVED)); 32 base::Bind(callback, request, Offliner::RequestStatus::SAVED));
33 } 33 }
34 return true; 34 return true;
35 } 35 }
36 36
37 void OfflinerStub::Cancel() { 37 void OfflinerStub::Cancel(const CancelCallback& callback) {
38 cancel_called_ = true; 38 cancel_called_ = true;
39 callback.Run(0LL);
39 } 40 }
40 41
41 bool OfflinerStub::HandleTimeout(const SavePageRequest& request) { 42 bool OfflinerStub::HandleTimeout(const SavePageRequest& request) {
42 if (snapshot_on_last_retry_) { 43 if (snapshot_on_last_retry_) {
43 base::ThreadTaskRunnerHandle::Get()->PostTask( 44 base::ThreadTaskRunnerHandle::Get()->PostTask(
44 FROM_HERE, 45 FROM_HERE,
45 base::Bind(callback_, request, Offliner::RequestStatus::SAVED)); 46 base::Bind(callback_, request, Offliner::RequestStatus::SAVED));
46 return true; 47 return true;
47 } 48 }
48 return false; 49 return false;
49 } 50 }
50 51
51 } // namespace offline_pages 52 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698