| 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_service_impl.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/memory/ptr_util.h" |
| 9 #include "content/browser/background_fetch/background_fetch_context.h" |
| 10 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 13 |
| 14 namespace content { |
| 15 |
| 16 // static |
| 17 void BackgroundFetchServiceImpl::Create( |
| 18 BackgroundFetchContext* background_fetch_context, |
| 19 ServiceWorkerContextWrapper* service_worker_context, |
| 20 blink::mojom::BackgroundFetchServiceRequest request) { |
| 21 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 22 mojo::MakeStrongBinding(base::MakeUnique<BackgroundFetchServiceImpl>( |
| 23 background_fetch_context, service_worker_context), |
| 24 std::move(request)); |
| 25 } |
| 26 |
| 27 BackgroundFetchServiceImpl::BackgroundFetchServiceImpl( |
| 28 BackgroundFetchContext* background_fetch_context, |
| 29 ServiceWorkerContextWrapper* service_worker_context) |
| 30 : background_fetch_context_(background_fetch_context), |
| 31 service_worker_context_(service_worker_context) { |
| 32 DCHECK(background_fetch_context); |
| 33 DCHECK(service_worker_context); |
| 34 } |
| 35 |
| 36 BackgroundFetchServiceImpl::~BackgroundFetchServiceImpl() = default; |
| 37 |
| 38 void BackgroundFetchServiceImpl::UpdateUI( |
| 39 int64_t service_worker_registration_id, |
| 40 const std::string& tag, |
| 41 const std::string& title, |
| 42 const UpdateUICallback& callback) { |
| 43 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 44 |
| 45 // TODO(peter): Get the BackgroundFetchJobController for the |
| 46 // {service_worker_registration_id, tag} pair and call UpdateUI() on it. |
| 47 |
| 48 callback.Run(blink::mojom::BackgroundFetchError::NONE); |
| 49 } |
| 50 |
| 51 void BackgroundFetchServiceImpl::Abort(int64_t service_worker_registration_id, |
| 52 const std::string& tag) { |
| 53 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 54 |
| 55 // TODO(peter): Get the BackgroundFetchJobController for the |
| 56 // {service_worker_registration_id, tag} pair and call Abort() on it. |
| 57 } |
| 58 |
| 59 void BackgroundFetchServiceImpl::GetRegistration( |
| 60 int64_t service_worker_registration_id, |
| 61 const std::string& tag, |
| 62 const GetRegistrationCallback& callback) { |
| 63 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 64 |
| 65 // TODO(peter): Get the registration for {service_worker_registration_id, tag} |
| 66 // and construct a BackgroundFetchRegistrationPtr for it. |
| 67 |
| 68 callback.Run(blink::mojom::BackgroundFetchError::NONE, |
| 69 nullptr /* registration */); |
| 70 } |
| 71 |
| 72 void BackgroundFetchServiceImpl::GetTags(int64_t service_worker_registration_id, |
| 73 const GetTagsCallback& callback) { |
| 74 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 75 |
| 76 // TODO(peter): Get the list of active Background Fetches associated with |
| 77 // service_worker_registration_id and share their tags. |
| 78 |
| 79 callback.Run(blink::mojom::BackgroundFetchError::NONE, |
| 80 std::vector<std::string>()); |
| 81 } |
| 82 |
| 83 } // namespace content |
| OLD | NEW |