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

Side by Side Diff: components/offline_pages/content/suggested_articles_observer_unittest.cc

Issue 2914703002: [Offline Prefetch] Backoff support for PrefetchBackgroundTask (Closed)
Patch Set: Address feedback 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 #include "components/offline_pages/content/suggested_articles_observer.h" 5 #include "components/offline_pages/content/suggested_articles_observer.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/test/test_simple_task_runner.h" 8 #include "base/test/test_simple_task_runner.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "components/offline_pages/core/client_namespace_constants.h" 10 #include "components/offline_pages/core/client_namespace_constants.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 } 46 }
47 47
48 void RemovePrefetchURLsByClientId(const ClientId& client_id) override { 48 void RemovePrefetchURLsByClientId(const ClientId& client_id) override {
49 DCHECK_EQ(client_id.name_space, kSuggestedArticlesNamespace); 49 DCHECK_EQ(client_id.name_space, kSuggestedArticlesNamespace);
50 remove_by_client_id_count++; 50 remove_by_client_id_count++;
51 last_removed_client_id = base::MakeUnique<ClientId>(client_id); 51 last_removed_client_id = base::MakeUnique<ClientId>(client_id);
52 } 52 }
53 53
54 void BeginBackgroundTask( 54 void BeginBackgroundTask(
55 std::unique_ptr<ScopedBackgroundTask> task) override {} 55 std::unique_ptr<ScopedBackgroundTask> task) override {}
56 void StopBackgroundTask(ScopedBackgroundTask* task) override {} 56 void StopBackgroundTask() override {}
57 void RequestFinishBackgroundTaskForTest() {}
57 58
58 std::vector<PrefetchURL> latest_prefetch_urls; 59 std::vector<PrefetchURL> latest_prefetch_urls;
59 std::unique_ptr<ClientId> last_removed_client_id; 60 std::unique_ptr<ClientId> last_removed_client_id;
60 61
61 int new_suggestions_count = 0; 62 int new_suggestions_count = 0;
62 int remove_all_suggestions_count = 0; 63 int remove_all_suggestions_count = 0;
63 int remove_by_client_id_count = 0; 64 int remove_by_client_id_count = 0;
64 }; 65 };
65 66
66 class TestingPrefetchService : public PrefetchService { 67 class TestingPrefetchService : public PrefetchService {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 207
207 observer()->OnSuggestionInvalidated( 208 observer()->OnSuggestionInvalidated(
208 ntp_snippets::ContentSuggestion::ID(category, test_url_1.spec())); 209 ntp_snippets::ContentSuggestion::ID(category, test_url_1.spec()));
209 210
210 EXPECT_EQ(1, test_prefetch_dispatcher()->remove_by_client_id_count); 211 EXPECT_EQ(1, test_prefetch_dispatcher()->remove_by_client_id_count);
211 EXPECT_EQ(ClientId(kSuggestedArticlesNamespace, test_url_1.spec()), 212 EXPECT_EQ(ClientId(kSuggestedArticlesNamespace, test_url_1.spec()),
212 *test_prefetch_dispatcher()->last_removed_client_id); 213 *test_prefetch_dispatcher()->last_removed_client_id);
213 } 214 }
214 215
215 } // namespace offline_pages 216 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698