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_CLEANUP_TASK_H_
6 #define CONTENT_BROWSER_BACKGROUND_FETCH_STORAGE_CLEANUP_TASK_H_
7 
8 #include <string>
9 #include <utility>
10 #include <vector>
11 
12 #include "content/browser/background_fetch/storage/database_task.h"
13 #include "third_party/blink/public/common/service_worker/service_worker_status_code.h"
14 
15 namespace content {
16 namespace background_fetch {
17 
18 // Deletes inactive registrations marked for deletion.
19 class CleanupTask : public background_fetch::DatabaseTask {
20  public:
21   explicit CleanupTask(DatabaseTaskHost* host);
22 
23   ~CleanupTask() override;
24 
25   void Start() override;
26 
27  private:
28   void DidGetRegistrations(
29       const std::vector<std::pair<int64_t, std::string>>& registration_data,
30       blink::ServiceWorkerStatusCode status);
31 
32   void DidGetActiveUniqueIds(
33       const std::vector<std::pair<int64_t, std::string>>& registration_data,
34       const std::vector<std::pair<int64_t, std::string>>& active_unique_id_data,
35       blink::ServiceWorkerStatusCode status);
36 
37   void FinishWithError(blink::mojom::BackgroundFetchError error) override;
38 
39   std::string HistogramName() const override;
40 
41   base::WeakPtrFactory<CleanupTask> weak_factory_{this};  // Keep as last.
42 
43   DISALLOW_COPY_AND_ASSIGN(CleanupTask);
44 };
45 
46 }  // namespace background_fetch
47 }  // namespace content
48 
49 #endif  // CONTENT_BROWSER_BACKGROUND_FETCH_STORAGE_CLEANUP_TASK_H_
50