| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/extensions/test_blacklist.h" | 5 #include "chrome/browser/extensions/test_blacklist.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "base/thread_task_runner_handle.h" |
| 13 #include "chrome/browser/extensions/blacklist.h" | 14 #include "chrome/browser/extensions/blacklist.h" |
| 14 #include "chrome/browser/extensions/blacklist_state_fetcher.h" | 15 #include "chrome/browser/extensions/blacklist_state_fetcher.h" |
| 15 #include "chrome/browser/extensions/fake_safe_browsing_database_manager.h" | 16 #include "chrome/browser/extensions/fake_safe_browsing_database_manager.h" |
| 16 | 17 |
| 17 namespace extensions { | 18 namespace extensions { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 void Assign(BlacklistState *out, BlacklistState in) { | 22 void Assign(BlacklistState *out, BlacklistState in) { |
| 22 *out = in; | 23 *out = in; |
| 23 } | 24 } |
| 24 | 25 |
| 25 } // namespace | 26 } // namespace |
| 26 | 27 |
| 27 BlacklistStateFetcherMock::BlacklistStateFetcherMock() : request_count_(0) {} | 28 BlacklistStateFetcherMock::BlacklistStateFetcherMock() : request_count_(0) {} |
| 28 | 29 |
| 29 BlacklistStateFetcherMock::~BlacklistStateFetcherMock() {} | 30 BlacklistStateFetcherMock::~BlacklistStateFetcherMock() {} |
| 30 | 31 |
| 31 void BlacklistStateFetcherMock::Request(const std::string& id, | 32 void BlacklistStateFetcherMock::Request(const std::string& id, |
| 32 const RequestCallback& callback) { | 33 const RequestCallback& callback) { |
| 33 ++request_count_; | 34 ++request_count_; |
| 34 | 35 |
| 35 BlacklistState result = NOT_BLACKLISTED; | 36 BlacklistState result = NOT_BLACKLISTED; |
| 36 if (ContainsKey(states_, id)) | 37 if (ContainsKey(states_, id)) |
| 37 result = states_[id]; | 38 result = states_[id]; |
| 38 | 39 |
| 39 base::MessageLoopProxy::current()->PostTask(FROM_HERE, | 40 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| 40 base::Bind(callback, result)); | 41 base::Bind(callback, result)); |
| 41 } | 42 } |
| 42 | 43 |
| 43 void BlacklistStateFetcherMock::SetState(const std::string& id, | 44 void BlacklistStateFetcherMock::SetState(const std::string& id, |
| 44 BlacklistState state) { | 45 BlacklistState state) { |
| 45 states_[id] = state; | 46 states_[id] = state; |
| 46 } | 47 } |
| 47 | 48 |
| 48 void BlacklistStateFetcherMock::Clear() { | 49 void BlacklistStateFetcherMock::Clear() { |
| 49 states_.clear(); | 50 states_.clear(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 127 |
| 127 void TestBlacklist::EnableSafeBrowsing() { | 128 void TestBlacklist::EnableSafeBrowsing() { |
| 128 blacklist_db_->Enable(); | 129 blacklist_db_->Enable(); |
| 129 } | 130 } |
| 130 | 131 |
| 131 void TestBlacklist::NotifyUpdate() { | 132 void TestBlacklist::NotifyUpdate() { |
| 132 blacklist_db_->NotifyUpdate(); | 133 blacklist_db_->NotifyUpdate(); |
| 133 } | 134 } |
| 134 | 135 |
| 135 } // namespace extensions | 136 } // namespace extensions |
| OLD | NEW |