OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/blacklist_state_fetcher.h" | 5 #include "chrome/browser/extensions/blacklist_state_fetcher.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/thread_task_runner_handle.h" |
9 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/safe_browsing/protocol_manager_helper.h" | 11 #include "chrome/browser/safe_browsing/protocol_manager_helper.h" |
11 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 12 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
12 #include "chrome/common/safe_browsing/crx_info.pb.h" | 13 #include "chrome/common/safe_browsing/crx_info.pb.h" |
13 #include "google_apis/google_api_keys.h" | 14 #include "google_apis/google_api_keys.h" |
14 #include "net/base/escape.h" | 15 #include "net/base/escape.h" |
15 #include "net/url_request/url_request_context.h" | 16 #include "net/url_request/url_request_context.h" |
16 #include "net/url_request/url_request_context_getter.h" | 17 #include "net/url_request/url_request_context_getter.h" |
17 #include "net/url_request/url_request_status.h" | 18 #include "net/url_request/url_request_status.h" |
18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 82 } |
82 | 83 |
83 void BlacklistStateFetcher::Request(const std::string& id, | 84 void BlacklistStateFetcher::Request(const std::string& id, |
84 const RequestCallback& callback) { | 85 const RequestCallback& callback) { |
85 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 86 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
86 if (!safe_browsing_config_) { | 87 if (!safe_browsing_config_) { |
87 if (g_browser_process && g_browser_process->safe_browsing_service()) { | 88 if (g_browser_process && g_browser_process->safe_browsing_service()) { |
88 SetSafeBrowsingConfig( | 89 SetSafeBrowsingConfig( |
89 g_browser_process->safe_browsing_service()->GetProtocolConfig()); | 90 g_browser_process->safe_browsing_service()->GetProtocolConfig()); |
90 } else { | 91 } else { |
91 base::MessageLoopProxy::current()->PostTask( | 92 base::ThreadTaskRunnerHandle::Get()->PostTask( |
92 FROM_HERE, base::Bind(callback, BLACKLISTED_UNKNOWN)); | 93 FROM_HERE, base::Bind(callback, BLACKLISTED_UNKNOWN)); |
93 return; | 94 return; |
94 } | 95 } |
95 } | 96 } |
96 | 97 |
97 bool request_already_sent = ContainsKey(callbacks_, id); | 98 bool request_already_sent = ContainsKey(callbacks_, id); |
98 callbacks_.insert(std::make_pair(id, callback)); | 99 callbacks_.insert(std::make_pair(id, callback)); |
99 if (request_already_sent) | 100 if (request_already_sent) |
100 return; | 101 return; |
101 | 102 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 callback_it != range.second; | 221 callback_it != range.second; |
221 ++callback_it) { | 222 ++callback_it) { |
222 callback_it->second.Run(state); | 223 callback_it->second.Run(state); |
223 } | 224 } |
224 | 225 |
225 callbacks_.erase(range.first, range.second); | 226 callbacks_.erase(range.first, range.second); |
226 } | 227 } |
227 | 228 |
228 } // namespace extensions | 229 } // namespace extensions |
229 | 230 |
OLD | NEW |