| 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 | 5 |
| 6 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
| 7 #include "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
| 8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "chrome/browser/safe_browsing/protocol_manager.h" | 10 #include "chrome/browser/safe_browsing/protocol_manager.h" |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 // |callback| since SafeBrowsingProtocolManager is not re-entrant at the time | 291 // |callback| since SafeBrowsingProtocolManager is not re-entrant at the time |
| 292 // this is called. This guarantee is part of the | 292 // this is called. This guarantee is part of the |
| 293 // SafeBrowsingProtocolManagerDelegate contract. | 293 // SafeBrowsingProtocolManagerDelegate contract. |
| 294 void HandleAddChunks( | 294 void HandleAddChunks( |
| 295 const std::string& unused_list, | 295 const std::string& unused_list, |
| 296 SBChunkList* chunks, | 296 SBChunkList* chunks, |
| 297 SafeBrowsingProtocolManagerDelegate::AddChunksCallback callback) { | 297 SafeBrowsingProtocolManagerDelegate::AddChunksCallback callback) { |
| 298 delete chunks; | 298 delete chunks; |
| 299 scoped_refptr<base::SingleThreadTaskRunner> task_runner( | 299 scoped_refptr<base::SingleThreadTaskRunner> task_runner( |
| 300 base::ThreadTaskRunnerHandle::Get()); | 300 base::ThreadTaskRunnerHandle::Get()); |
| 301 if (!task_runner) | 301 if (!task_runner.get()) |
| 302 return; | 302 return; |
| 303 task_runner->PostTask(FROM_HERE, callback); | 303 task_runner->PostTask(FROM_HERE, callback); |
| 304 } | 304 } |
| 305 | 305 |
| 306 } // namespace | 306 } // namespace |
| 307 | 307 |
| 308 // Tests that the Update protocol will be skipped if there are problems | 308 // Tests that the Update protocol will be skipped if there are problems |
| 309 // accessing the database. | 309 // accessing the database. |
| 310 TEST_F(SafeBrowsingProtocolManagerTest, ProblemAccessingDatabase) { | 310 TEST_F(SafeBrowsingProtocolManagerTest, ProblemAccessingDatabase) { |
| 311 scoped_refptr<base::TestSimpleTaskRunner> runner( | 311 scoped_refptr<base::TestSimpleTaskRunner> runner( |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 second_chunk_url_fetcher->delegate()->OnURLFetchComplete( | 1062 second_chunk_url_fetcher->delegate()->OnURLFetchComplete( |
| 1063 second_chunk_url_fetcher); | 1063 second_chunk_url_fetcher); |
| 1064 | 1064 |
| 1065 EXPECT_FALSE(pm->IsUpdateScheduled()); | 1065 EXPECT_FALSE(pm->IsUpdateScheduled()); |
| 1066 | 1066 |
| 1067 // Invoke the AddChunksCallback to finish the update. | 1067 // Invoke the AddChunksCallback to finish the update. |
| 1068 runner->RunPendingTasks(); | 1068 runner->RunPendingTasks(); |
| 1069 | 1069 |
| 1070 EXPECT_TRUE(pm->IsUpdateScheduled()); | 1070 EXPECT_TRUE(pm->IsUpdateScheduled()); |
| 1071 } | 1071 } |
| OLD | NEW |