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

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: Minor changes 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/task.h" 13 #include "components/offline_pages/core/task.h"
14 #include "url/gurl.h"
15 14
16 namespace offline_pages { 15 namespace offline_pages {
17 16
18 // Task that adds new URL suggestions to the pipeline. URLs are matched against 17 // 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 18 // existing ones from any stage of the process so that only new, unique ones are
20 // actually added. 19 // actually added.
21 // Fully processed items are kept in the store in the PrefetchItemState::ZOMBIE 20 // 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 21 // 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 22 // 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 23 // 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 24 // whose URL didn't match any of the just suggested ones are finally deleted
26 // from the store. 25 // from the store.
27 class AddUniqueUrlsTask : public Task { 26 class AddUniqueUrlsTask : public Task {
28 public: 27 public:
29 AddUniqueUrlsTask(PrefetchStore* store, 28 AddUniqueUrlsTask(const std::string& name_space,
30 const std::vector<PrefetchURL>& prefetch_urls); 29 const std::vector<PrefetchURL>& prefetch_urls);
31 ~AddUniqueUrlsTask() override; 30 ~AddUniqueUrlsTask() override;
32 31
33 void Run() override; 32 void Run() override;
34 33
35 private: 34 private:
36 PrefetchStore* prefetch_store_; 35 void OnUrlsAdded(int added_entry_count);
36
37 const std::string& name_space_;
37 std::vector<PrefetchURL> prefetch_urls_; 38 std::vector<PrefetchURL> prefetch_urls_;
38 39
39 base::WeakPtrFactory<AddUniqueUrlsTask> weak_ptr_factory_; 40 base::WeakPtrFactory<AddUniqueUrlsTask> weak_ptr_factory_;
40 DISALLOW_COPY_AND_ASSIGN(AddUniqueUrlsTask); 41 DISALLOW_COPY_AND_ASSIGN(AddUniqueUrlsTask);
41 }; 42 };
42 43
43 } // namespace offline_pages 44 } // namespace offline_pages
44 45
45 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_ADD_UNIQUE_URLS_TASK_H_ 46 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_ADD_UNIQUE_URLS_TASK_H_
OLDNEW
« no previous file with comments | « components/offline_pages/core/prefetch/README.md ('k') | components/offline_pages/core/prefetch/add_unique_urls_task.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698