Chromium Code Reviews| Index: components/offline_pages/core/prefetch/add_unique_urls_task.h |
| diff --git a/components/offline_pages/core/prefetch/add_unique_urls_task.h b/components/offline_pages/core/prefetch/add_unique_urls_task.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..16e37a980c9d252e1a16edafaaafd392e0e82c6e |
| --- /dev/null |
| +++ b/components/offline_pages/core/prefetch/add_unique_urls_task.h |
| @@ -0,0 +1,48 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_ADD_UNIQUE_URLS_TASK_H_ |
| +#define COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_ADD_UNIQUE_URLS_TASK_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/memory/weak_ptr.h" |
| +#include "components/offline_pages/core/prefetch/prefetch_store.h" |
| +#include "components/offline_pages/core/prefetch/prefetch_types.h" |
| +#include "components/offline_pages/core/task.h" |
| +#include "url/gurl.h" |
| + |
| +namespace offline_pages { |
| + |
| +// Task that adds new URL suggestions to the pipeline. URLs are matched against |
| +// existing ones from any stage of the process so that only new, unique ones are |
| +// actually added. |
| +// Fully processed items are kept in the store in the PrefetchItemState::ZOMBIE |
| +// state until it is confirmed that the client for its namespace is not |
| +// recommending the same URL anymore to avoid processing it twice. So once the |
| +// step described above is done, all same namespace items in the ZOMBIE state |
|
fgorski
2017/05/30 17:21:45
Zombie clean up could be a separate task that is s
carlosk
2017/06/01 01:49:59
With the current design of using zombies as a dupl
|
| +// whose URL didn't match any of the just suggested ones are finally deleted |
| +// from the store. |
| +class AddUniqueUrlsTask : public Task { |
| + public: |
| + AddUniqueUrlsTask(PrefetchStore* store, |
| + const std::string& name_space, |
| + const std::vector<PrefetchURL>& prefetch_urls); |
| + ~AddUniqueUrlsTask() override; |
| + |
| + void Run() override; |
| + |
| + private: |
| + PrefetchStore* store_; |
|
Dmitry Titov
2017/05/26 23:05:06
Naming: I think it should be prefetch_store_.
carlosk
2017/06/01 01:49:59
Done.
|
| + std::string name_space_; |
| + std::vector<PrefetchURL> prefetch_urls_; |
| + |
| + base::WeakPtrFactory<AddUniqueUrlsTask> weak_ptr_factory_; |
| + DISALLOW_COPY_AND_ASSIGN(AddUniqueUrlsTask); |
| +}; |
| + |
| +} // namespace offline_pages |
| + |
| +#endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_ADD_UNIQUE_URLS_TASK_H_ |