| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/message_loop/message_loop.h" | |
| 13 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 14 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 15 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
| 16 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 15 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 17 #include "chrome/browser/download/download_item_model.h" | 16 #include "chrome/browser/download/download_item_model.h" |
| 18 #include "chrome/browser/download/download_prefs.h" | 17 #include "chrome/browser/download/download_prefs.h" |
| 19 #include "chrome/browser/download/download_target_info.h" | 18 #include "chrome/browser/download/download_target_info.h" |
| 20 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 21 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 20 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 22 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // bound as that parameter. | 61 // bound as that parameter. |
| 63 // Example: | 62 // Example: |
| 64 // class FooClass { | 63 // class FooClass { |
| 65 // public: | 64 // public: |
| 66 // virtual void Foo(base::Callback<void(bool)> callback); | 65 // virtual void Foo(base::Callback<void(bool)> callback); |
| 67 // }; | 66 // }; |
| 68 // ... | 67 // ... |
| 69 // EXPECT_CALL(mock_fooclass_instance, Foo(callback)) | 68 // EXPECT_CALL(mock_fooclass_instance, Foo(callback)) |
| 70 // .WillOnce(ScheduleCallback(false)); | 69 // .WillOnce(ScheduleCallback(false)); |
| 71 ACTION_P(ScheduleCallback, result) { | 70 ACTION_P(ScheduleCallback, result) { |
| 72 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(arg0, result)); | 71 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| 72 base::Bind(arg0, result)); |
| 73 } | 73 } |
| 74 | 74 |
| 75 // Similar to ScheduleCallback, but binds 2 arguments. | 75 // Similar to ScheduleCallback, but binds 2 arguments. |
| 76 ACTION_P2(ScheduleCallback2, result0, result1) { | 76 ACTION_P2(ScheduleCallback2, result0, result1) { |
| 77 base::MessageLoop::current()->PostTask( | 77 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 78 FROM_HERE, base::Bind(arg0, result0, result1)); | 78 FROM_HERE, base::Bind(arg0, result0, result1)); |
| 79 } | 79 } |
| 80 | 80 |
| 81 // Subclass of the ChromeDownloadManagerDelegate that uses a mock | 81 // Subclass of the ChromeDownloadManagerDelegate that uses a mock |
| 82 // DownloadProtectionService. | 82 // DownloadProtectionService. |
| 83 class TestChromeDownloadManagerDelegate : public ChromeDownloadManagerDelegate { | 83 class TestChromeDownloadManagerDelegate : public ChromeDownloadManagerDelegate { |
| 84 public: | 84 public: |
| 85 explicit TestChromeDownloadManagerDelegate(Profile* profile) | 85 explicit TestChromeDownloadManagerDelegate(Profile* profile) |
| 86 : ChromeDownloadManagerDelegate(profile) { | 86 : ChromeDownloadManagerDelegate(profile) { |
| 87 ON_CALL(*this, MockCheckDownloadUrl(_, _)) | 87 ON_CALL(*this, MockCheckDownloadUrl(_, _)) |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 EXPECT_CALL(*download_item, OnContentCheckCompleted(_)).Times(0); | 666 EXPECT_CALL(*download_item, OnContentCheckCompleted(_)).Times(0); |
| 667 } | 667 } |
| 668 | 668 |
| 669 base::RunLoop run_loop; | 669 base::RunLoop run_loop; |
| 670 ASSERT_FALSE(delegate()->ShouldCompleteDownload(download_item.get(), | 670 ASSERT_FALSE(delegate()->ShouldCompleteDownload(download_item.get(), |
| 671 run_loop.QuitClosure())); | 671 run_loop.QuitClosure())); |
| 672 run_loop.Run(); | 672 run_loop.Run(); |
| 673 } | 673 } |
| 674 | 674 |
| 675 #endif // FULL_SAFE_BROWSING | 675 #endif // FULL_SAFE_BROWSING |
| OLD | NEW |