Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: components/offline_pages/core/prefetch/add_unique_urls_task.h

Issue 2920083002: Prefetching: Introduce store commands abstractions to be used by tasks. (Closed)
Patch Set: Added TODO for NWake Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_ADD_UNIQUE_URLS_TASK_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_ADD_UNIQUE_URLS_TASK_H_
6 #define COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_ADD_UNIQUE_URLS_TASK_H_ 6 #define COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_ADD_UNIQUE_URLS_TASK_H_
7 7
8 #include <string>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
11 #include "components/offline_pages/core/prefetch/prefetch_store.h"
12 #include "components/offline_pages/core/prefetch/prefetch_types.h" 12 #include "components/offline_pages/core/prefetch/prefetch_types.h"
13 #include "components/offline_pages/core/prefetch/store/add_urls_store_command.h"
14 #include "components/offline_pages/core/prefetch/store/cleanup_zombies_store_com mand.h"
13 #include "components/offline_pages/core/task.h" 15 #include "components/offline_pages/core/task.h"
14 #include "url/gurl.h"
15 16
16 namespace offline_pages { 17 namespace offline_pages {
17 18
18 // Task that adds new URL suggestions to the pipeline. URLs are matched against 19 // Task that adds new URL suggestions to the pipeline. URLs are matched against
19 // existing ones from any stage of the process so that only new, unique ones are 20 // existing ones from any stage of the process so that only new, unique ones are
20 // actually added. 21 // actually added.
21 // Fully processed items are kept in the store in the PrefetchItemState::ZOMBIE 22 // Fully processed items are kept in the store in the PrefetchItemState::ZOMBIE
22 // state until it is confirmed that the client for its namespace is not 23 // state until it is confirmed that the client for its namespace is not
23 // recommending the same URL anymore to avoid processing it twice. So once the 24 // recommending the same URL anymore to avoid processing it twice. So once the
24 // step described above is done, all same namespace items in the ZOMBIE state 25 // step described above is done, all same namespace items in the ZOMBIE state
25 // whose URL didn't match any of the just suggested ones are finally deleted 26 // whose URL didn't match any of the just suggested ones are finally deleted
26 // from the store. 27 // from the store.
27 class AddUniqueUrlsTask : public Task { 28 class AddUniqueUrlsTask : public Task {
28 public: 29 public:
29 AddUniqueUrlsTask(PrefetchStore* store, 30 AddUniqueUrlsTask(
30 const std::vector<PrefetchURL>& prefetch_urls); 31 std::unique_ptr<AddUrlsStoreCommand> add_urls_command,
32 std::unique_ptr<CleanupZombiesStoreCommand> zombies_cleanup_command,
33 const std::string& name_space,
34 const std::vector<PrefetchURL>& prefetch_urls);
31 ~AddUniqueUrlsTask() override; 35 ~AddUniqueUrlsTask() override;
32 36
33 void Run() override; 37 void Run() override;
34 38
35 private: 39 private:
36 PrefetchStore* prefetch_store_; 40 void OnUrlsAdded(bool success);
41
42 std::unique_ptr<AddUrlsStoreCommand> add_urls_command_;
43 std::unique_ptr<CleanupZombiesStoreCommand> zombies_cleanup_command_;
44 const std::string& name_space_;
37 std::vector<PrefetchURL> prefetch_urls_; 45 std::vector<PrefetchURL> prefetch_urls_;
38 46
39 base::WeakPtrFactory<AddUniqueUrlsTask> weak_ptr_factory_; 47 base::WeakPtrFactory<AddUniqueUrlsTask> weak_ptr_factory_;
40 DISALLOW_COPY_AND_ASSIGN(AddUniqueUrlsTask); 48 DISALLOW_COPY_AND_ASSIGN(AddUniqueUrlsTask);
41 }; 49 };
42 50
43 } // namespace offline_pages 51 } // namespace offline_pages
44 52
45 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_ADD_UNIQUE_URLS_TASK_H_ 53 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_ADD_UNIQUE_URLS_TASK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698