OLD | NEW |
---|---|
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 "content/browser/background_fetch/background_fetch_context.h" | 5 #include "content/browser/background_fetch/background_fetch_context.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "content/browser/background_fetch/background_fetch_data_manager.h" | 8 #include "content/browser/background_fetch/background_fetch_data_manager.h" |
9 #include "content/browser/background_fetch/background_fetch_job_controller.h" | 9 #include "content/browser/background_fetch/background_fetch_job_controller.h" |
10 #include "content/browser/background_fetch/background_fetch_registration_id.h" | 10 #include "content/browser/background_fetch/background_fetch_registration_id.h" |
11 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 11 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
12 #include "content/browser/storage_partition_impl.h" | 12 #include "content/browser/storage_partition_impl.h" |
13 #include "content/public/browser/browser_context.h" | 13 #include "content/public/browser/browser_context.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 BackgroundFetchContext::BackgroundFetchContext( | 17 BackgroundFetchContext::BackgroundFetchContext( |
18 BrowserContext* browser_context, | 18 BrowserContext* browser_context, |
19 StoragePartitionImpl* storage_partition, | 19 StoragePartitionImpl* storage_partition, |
20 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context) | 20 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context) |
21 : browser_context_(browser_context), | 21 : browser_context_(browser_context), |
22 storage_partition_(storage_partition), | 22 storage_partition_(storage_partition), |
23 service_worker_context_(service_worker_context), | 23 service_worker_context_(service_worker_context), |
24 background_fetch_data_manager_( | 24 background_fetch_data_manager_( |
25 base::MakeUnique<BackgroundFetchDataManager>(browser_context)) { | 25 base::MakeUnique<BackgroundFetchDataManager>(browser_context)) { |
26 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 26 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
Peter Beverloo
2017/03/29 14:32:12
BackgroundFetchClient* client = browser_context_->
harkness
2017/03/30 12:42:35
Done.
| |
27 } | 27 } |
28 | 28 |
29 BackgroundFetchContext::~BackgroundFetchContext() { | 29 BackgroundFetchContext::~BackgroundFetchContext() { |
30 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 30 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
Peter Beverloo
2017/03/29 14:32:12
BackgroundFetchClient* client = browser_context_->
harkness
2017/03/30 12:42:35
Done.
| |
31 } | 31 } |
32 | 32 |
33 void BackgroundFetchContext::Shutdown() { | 33 void BackgroundFetchContext::Shutdown() { |
34 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 34 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
35 BrowserThread::PostTask( | 35 BrowserThread::PostTask( |
36 BrowserThread::IO, FROM_HERE, | 36 BrowserThread::IO, FROM_HERE, |
37 base::Bind(&BackgroundFetchContext::ShutdownOnIO, this)); | 37 base::Bind(&BackgroundFetchContext::ShutdownOnIO, this)); |
38 } | 38 } |
39 | 39 |
40 void BackgroundFetchContext::ShutdownOnIO() { | 40 void BackgroundFetchContext::ShutdownOnIO() { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 void BackgroundFetchContext::DidFinishFetch( | 94 void BackgroundFetchContext::DidFinishFetch( |
95 const BackgroundFetchRegistrationId& registration_id) { | 95 const BackgroundFetchRegistrationId& registration_id) { |
96 DCHECK_GT(active_fetches_.count(registration_id), 0u); | 96 DCHECK_GT(active_fetches_.count(registration_id), 0u); |
97 | 97 |
98 // TODO(peter): Dispatch the `backgroundfetched` or the `backgroundfetchfail` | 98 // TODO(peter): Dispatch the `backgroundfetched` or the `backgroundfetchfail` |
99 // event to the Service Worker. | 99 // event to the Service Worker. |
100 | 100 |
101 active_fetches_.erase(registration_id); | 101 active_fetches_.erase(registration_id); |
102 } | 102 } |
103 | 103 |
104 void BackgroundFetchContext::CancelDownload( | |
105 const std::string& registration_id) {} | |
Peter Beverloo
2017/03/29 14:32:12
micro nit: lack of symmetry in the argument names
harkness
2017/03/30 12:42:35
Done.
| |
106 | |
107 void BackgroundFetchContext::PauseDownload(const std::string& registration_id) { | |
108 } | |
109 | |
110 void BackgroundFetchContext::ResumeDownload( | |
111 const std::string& registration_id) {} | |
Peter Beverloo
2017/03/29 14:32:12
nit: it'd be best to hook these up with the JobCon
harkness
2017/03/30 12:42:35
My plan was to hook these up in the next CL to min
| |
112 | |
104 } // namespace content | 113 } // namespace content |
OLD | NEW |