Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/browser/background_fetch/background_fetch_client_proxy.h" | |
| 6 | |
| 7 #include "content/browser/background_fetch/background_fetch_context.h" | |
| 8 #include "content/browser/background_fetch/background_fetch_registration_id.h" | |
| 9 #include "content/public/browser/browser_thread.h" | |
| 10 | |
| 11 namespace content { | |
| 12 | |
| 13 BackgroundFetchClientProxy::BackgroundFetchClientProxy( | |
| 14 BackgroundFetchContext* background_fetch_context) | |
| 15 : background_fetch_context_(background_fetch_context) { | |
| 16 DCHECK(background_fetch_context); | |
| 17 } | |
| 18 | |
| 19 BackgroundFetchClientProxy::~BackgroundFetchClientProxy() = default; | |
| 20 | |
| 21 void BackgroundFetchClientProxy::CancelDownload( | |
| 22 const std::string& registration_id) { | |
| 23 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 24 BackgroundFetchRegistrationId deserialized_id; | |
| 25 if (!BackgroundFetchRegistrationId::Deserialize(registration_id, | |
| 26 deserialized_id)) | |
| 27 return; | |
|
Peter Beverloo
2017/03/31 01:32:23
nit: {} (condition is multiple lines, elsewhere to
Peter Beverloo
2017/03/31 01:32:23
LOG(ERROR)? This shouldn't crash, but it also shou
harkness
2017/03/31 10:11:43
I added a log without printing the string. I wasn'
harkness
2017/03/31 10:11:44
Ah git cl format, you fail me!
| |
| 28 | |
| 29 BrowserThread::PostTask( | |
| 30 BrowserThread::IO, FROM_HERE, | |
| 31 base::Bind(&BackgroundFetchContext::CancelFetch, | |
| 32 background_fetch_context_, deserialized_id)); | |
|
Peter Beverloo
2017/03/31 01:32:23
I guess we're getting scoped_refptr lifetime seman
harkness
2017/03/31 10:11:43
That's what I was counting on. Do you want me to m
| |
| 33 } | |
| 34 | |
| 35 void BackgroundFetchClientProxy::PauseDownload( | |
| 36 const std::string& registration_id) { | |
| 37 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 38 BackgroundFetchRegistrationId deserialized_id; | |
| 39 if (!BackgroundFetchRegistrationId::Deserialize(registration_id, | |
| 40 deserialized_id)) | |
| 41 return; | |
| 42 | |
| 43 BrowserThread::PostTask( | |
| 44 BrowserThread::IO, FROM_HERE, | |
| 45 base::Bind(&BackgroundFetchContext::PauseFetch, background_fetch_context_, | |
| 46 deserialized_id)); | |
| 47 } | |
| 48 | |
| 49 void BackgroundFetchClientProxy::ResumeDownload( | |
| 50 const std::string& registration_id) { | |
| 51 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 52 BackgroundFetchRegistrationId deserialized_id; | |
| 53 if (!BackgroundFetchRegistrationId::Deserialize(registration_id, | |
| 54 deserialized_id)) | |
| 55 return; | |
| 56 | |
| 57 BrowserThread::PostTask( | |
| 58 BrowserThread::IO, FROM_HERE, | |
| 59 base::Bind(&BackgroundFetchContext::ResumeFetch, | |
| 60 background_fetch_context_, deserialized_id)); | |
| 61 } | |
| 62 | |
| 63 } // namespace content | |
| OLD | NEW |