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

Side by Side Diff: components/previews/core/previews_black_list_unittest.cc

Issue 2375663002: Replace MessageLoop::current()->task_runner() with ThreadTaskRunnerHandle::Get(). (Closed)
Patch Set: rebase Created 4 years, 2 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
« no previous file with comments | « components/leveldb/leveldb_app.cc ('k') | components/safe_browsing_db/v4_database.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/previews/core/previews_black_list.h" 5 #include "components/previews/core/previews_black_list.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/metrics/field_trial.h" 14 #include "base/metrics/field_trial.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "base/test/simple_test_clock.h" 17 #include "base/test/simple_test_clock.h"
18 #include "base/threading/thread_task_runner_handle.h"
18 #include "base/time/time.h" 19 #include "base/time/time.h"
19 #include "components/previews/core/previews_black_list_item.h" 20 #include "components/previews/core/previews_black_list_item.h"
20 #include "components/previews/core/previews_experiments.h" 21 #include "components/previews/core/previews_experiments.h"
21 #include "components/previews/core/previews_opt_out_store.h" 22 #include "components/previews/core/previews_opt_out_store.h"
22 #include "components/variations/variations_associated_data.h" 23 #include "components/variations/variations_associated_data.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
24 #include "url/gurl.h" 25 #include "url/gurl.h"
25 26
26 namespace { 27 namespace {
27 28
(...skipping 18 matching lines...) Expand all
46 private: 47 private:
47 // PreviewsOptOutStore implementation: 48 // PreviewsOptOutStore implementation:
48 void AddPreviewNavigation(bool opt_out, 49 void AddPreviewNavigation(bool opt_out,
49 const std::string& host_name, 50 const std::string& host_name,
50 PreviewsType type, 51 PreviewsType type,
51 base::Time now) override {} 52 base::Time now) override {}
52 53
53 void LoadBlackList(LoadBlackListCallback callback) override { 54 void LoadBlackList(LoadBlackListCallback callback) override {
54 std::unique_ptr<BlackListItemMap> black_list_item_map( 55 std::unique_ptr<BlackListItemMap> black_list_item_map(
55 new BlackListItemMap()); 56 new BlackListItemMap());
56 base::MessageLoop::current()->task_runner()->PostTask( 57 base::ThreadTaskRunnerHandle::Get()->PostTask(
57 FROM_HERE, base::Bind(&RunLoadCallback, callback, 58 FROM_HERE, base::Bind(&RunLoadCallback, callback,
58 base::Passed(&black_list_item_map))); 59 base::Passed(&black_list_item_map)));
59 } 60 }
60 }; 61 };
61 62
62 } // namespace 63 } // namespace
63 64
64 TEST_F(PreviewsBlackListTest, BlackListNoStore) { 65 TEST_F(PreviewsBlackListTest, BlackListNoStore) {
65 // Tests the black list behavior when a null OptOutSture is passed in. 66 // Tests the black list behavior when a null OptOutSture is passed in.
66 const GURL url_a("http://www.url_a.com"); 67 const GURL url_a("http://www.url_a.com");
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 black_list->AddPreviewNavigation(url_e, true, PreviewsType::OFFLINE); 254 black_list->AddPreviewNavigation(url_e, true, PreviewsType::OFFLINE);
254 // url_d and url_e should remain in the map, but url_a should be evicted. 255 // url_d and url_e should remain in the map, but url_a should be evicted.
255 EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_a, PreviewsType::OFFLINE)); 256 EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_a, PreviewsType::OFFLINE));
256 EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_d, PreviewsType::OFFLINE)); 257 EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_d, PreviewsType::OFFLINE));
257 EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_e, PreviewsType::OFFLINE)); 258 EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_e, PreviewsType::OFFLINE));
258 259
259 variations::testing::ClearAllVariationParams(); 260 variations::testing::ClearAllVariationParams();
260 } 261 }
261 262
262 } // namespace previews 263 } // namespace previews
OLDNEW
« no previous file with comments | « components/leveldb/leveldb_app.cc ('k') | components/safe_browsing_db/v4_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698