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 #ifndef CONTENT_BROWSER_BACKGROUND_FETCH_STORAGE_GET_DEVELOPER_IDS_TASK_H_ 6 #define CONTENT_BROWSER_BACKGROUND_FETCH_STORAGE_GET_DEVELOPER_IDS_TASK_H_ 7 8 #include <string> 9 #include <utility> 10 11 #include "base/callback_forward.h" 12 #include "base/containers/flat_map.h" 13 #include "content/browser/background_fetch/storage/database_task.h" 14 #include "third_party/blink/public/common/service_worker/service_worker_status_code.h" 15 #include "third_party/blink/public/mojom/background_fetch/background_fetch.mojom.h" 16 #include "url/origin.h" 17 18 namespace content { 19 namespace background_fetch { 20 21 // Gets the developer ids for all active registrations - registrations that have 22 // not completed. 23 class GetDeveloperIdsTask : public DatabaseTask { 24 public: 25 GetDeveloperIdsTask( 26 DatabaseTaskHost* host, 27 int64_t service_worker_registration_id, 28 const url::Origin& origin, 29 blink::mojom::BackgroundFetchService::GetDeveloperIdsCallback callback); 30 31 ~GetDeveloperIdsTask() override; 32 33 // DatabaseTask implementation: 34 void Start() override; 35 36 private: 37 void DidGetUniqueIds( 38 blink::ServiceWorkerStatusCode status, 39 const base::flat_map<std::string, std::string>& data_map); 40 41 void FinishWithError(blink::mojom::BackgroundFetchError error) override; 42 43 std::string HistogramName() const override; 44 45 int64_t service_worker_registration_id_; 46 url::Origin origin_; 47 48 blink::mojom::BackgroundFetchService::GetDeveloperIdsCallback callback_; 49 50 std::vector<std::string> developer_ids_; 51 52 base::WeakPtrFactory<GetDeveloperIdsTask> weak_factory_{ 53 this}; // Keep as last. 54 55 DISALLOW_COPY_AND_ASSIGN(GetDeveloperIdsTask); 56 }; 57 58 } // namespace background_fetch 59 } // namespace content 60 61 #endif // CONTENT_BROWSER_BACKGROUND_FETCH_STORAGE_GET_DEVELOPER_IDS_TASK_H_ 62