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

Side by Side Diff: components/subresource_filter/content/browser/content_ruleset_service_unittest.cc

Issue 2726523002: Pass Callback to TaskRunner by value and consume it on invocation (1) (Closed)
Patch Set: rebase Created 3 years, 9 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 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/subresource_filter/content/browser/content_ruleset_service. h" 5 #include "components/subresource_filter/content/browser/content_ruleset_service. h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <tuple> 10 #include <tuple>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/bind_helpers.h" 14 #include "base/bind_helpers.h"
15 #include "base/callback.h" 15 #include "base/callback.h"
16 #include "base/callback_helpers.h"
engedy 2017/03/23 14:09:26 nit: I think this isn't actually used here.
tzik 2017/03/24 09:25:55 Removed. Right, it was needed by ResetAndReturn in
16 #include "base/files/file.h" 17 #include "base/files/file.h"
17 #include "base/files/file_util.h" 18 #include "base/files/file_util.h"
18 #include "base/files/scoped_temp_dir.h" 19 #include "base/files/scoped_temp_dir.h"
19 #include "base/numerics/safe_conversions.h" 20 #include "base/numerics/safe_conversions.h"
20 #include "base/run_loop.h" 21 #include "base/run_loop.h"
21 #include "base/task_runner.h" 22 #include "base/task_runner.h"
22 #include "components/subresource_filter/content/common/subresource_filter_messag es.h" 23 #include "components/subresource_filter/content/common/subresource_filter_messag es.h"
23 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/content_browser_client.h" 25 #include "content/public/browser/content_browser_client.h"
25 #include "content/public/browser/notification_service.h" 26 #include "content/public/browser/notification_service.h"
(...skipping 14 matching lines...) Expand all
40 using MockClosureTarget = 41 using MockClosureTarget =
41 ::testing::StrictMock<::testing::MockFunction<void()>>; 42 ::testing::StrictMock<::testing::MockFunction<void()>>;
42 43
43 class TestContentBrowserClient : public ::content::ContentBrowserClient { 44 class TestContentBrowserClient : public ::content::ContentBrowserClient {
44 public: 45 public:
45 TestContentBrowserClient() {} 46 TestContentBrowserClient() {}
46 47
47 // ::content::ContentBrowserClient: 48 // ::content::ContentBrowserClient:
48 void PostAfterStartupTask(const tracked_objects::Location&, 49 void PostAfterStartupTask(const tracked_objects::Location&,
49 const scoped_refptr<base::TaskRunner>& task_runner, 50 const scoped_refptr<base::TaskRunner>& task_runner,
50 const base::Closure& task) override { 51 base::Closure task) override {
51 scoped_refptr<base::TaskRunner> ui_task_runner = 52 scoped_refptr<base::TaskRunner> ui_task_runner =
52 content::BrowserThread::GetTaskRunnerForThread( 53 content::BrowserThread::GetTaskRunnerForThread(
53 content::BrowserThread::UI); 54 content::BrowserThread::UI);
54 EXPECT_EQ(ui_task_runner, task_runner); 55 EXPECT_EQ(ui_task_runner, task_runner);
55 last_task_ = task; 56 last_task_ = std::move(task);
56 } 57 }
57 58
58 void RunAfterStartupTask() { 59 void RunAfterStartupTask() {
59 if (!last_task_.is_null()) 60 if (!last_task_.is_null())
60 last_task_.Run(); 61 std::move(last_task_).Run();
61 } 62 }
62 63
63 private: 64 private:
64 base::Closure last_task_; 65 base::Closure last_task_;
65 66
66 DISALLOW_COPY_AND_ASSIGN(TestContentBrowserClient); 67 DISALLOW_COPY_AND_ASSIGN(TestContentBrowserClient);
67 }; 68 };
68 69
69 class NotifyingMockRenderProcessHost : public content::MockRenderProcessHost { 70 class NotifyingMockRenderProcessHost : public content::MockRenderProcessHost {
70 public: 71 public:
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 183
183 MockClosureTarget mock_closure_target; 184 MockClosureTarget mock_closure_target;
184 service.PostAfterStartupTask(base::Bind( 185 service.PostAfterStartupTask(base::Bind(
185 &MockClosureTarget::Call, base::Unretained(&mock_closure_target))); 186 &MockClosureTarget::Call, base::Unretained(&mock_closure_target)));
186 187
187 EXPECT_CALL(mock_closure_target, Call()).Times(1); 188 EXPECT_CALL(mock_closure_target, Call()).Times(1);
188 browser_client()->RunAfterStartupTask(); 189 browser_client()->RunAfterStartupTask();
189 } 190 }
190 191
191 } // namespace subresource_filter 192 } // namespace subresource_filter
OLDNEW
« no previous file with comments | « components/memory_pressure/memory_pressure_monitor_unittest.cc ('k') | components/user_manager/fake_user_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698