Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |