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