Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc

Issue 10069031: Replace SafeBrowsing MAC with downloads over SSL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // This test creates a safebrowsing service using test safebrowsing database 5 // This test creates a safebrowsing service using test safebrowsing database
6 // and a test protocol manager. It is used to test logics in safebrowsing 6 // and a test protocol manager. It is used to test logics in safebrowsing
7 // service. 7 // service.
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 // Owned by the SafebrowsingService. 187 // Owned by the SafebrowsingService.
188 TestSafeBrowsingDatabase* db_; 188 TestSafeBrowsingDatabase* db_;
189 }; 189 };
190 190
191 // A TestProtocolManager that could return fixed responses from 191 // A TestProtocolManager that could return fixed responses from
192 // safebrowsing server for testing purpose. 192 // safebrowsing server for testing purpose.
193 class TestProtocolManager : public SafeBrowsingProtocolManager { 193 class TestProtocolManager : public SafeBrowsingProtocolManager {
194 public: 194 public:
195 TestProtocolManager(SafeBrowsingService* sb_service, 195 TestProtocolManager(SafeBrowsingService* sb_service,
196 const std::string& client_name, 196 const std::string& client_name,
197 const std::string& client_key,
198 const std::string& wrapped_key,
199 net::URLRequestContextGetter* request_context_getter, 197 net::URLRequestContextGetter* request_context_getter,
200 const std::string& info_url_prefix, 198 const std::string& url_prefix,
201 const std::string& mackey_url_prefix,
202 bool disable_auto_update) 199 bool disable_auto_update)
203 : SafeBrowsingProtocolManager(sb_service, client_name, client_key, 200 : SafeBrowsingProtocolManager(sb_service, client_name,
204 wrapped_key, request_context_getter, 201 request_context_getter, url_prefix,
205 info_url_prefix, mackey_url_prefix,
206 disable_auto_update), 202 disable_auto_update),
207 sb_service_(sb_service), 203 sb_service_(sb_service),
208 delay_ms_(0) { 204 delay_ms_(0) {
209 } 205 }
210 206
211 // This function is called when there is a prefix hit in local safebrowsing 207 // This function is called when there is a prefix hit in local safebrowsing
212 // database and safebrowsing service issues a get hash request to backends. 208 // database and safebrowsing service issues a get hash request to backends.
213 // We return a result from the prefilled full_hashes_ hash_map to simulate 209 // We return a result from the prefilled full_hashes_ hash_map to simulate
214 // server's response. At the same time, latency is added to simulate real 210 // server's response. At the same time, latency is added to simulate real
215 // life network issues. 211 // life network issues.
(...skipping 26 matching lines...) Expand all
242 238
243 // Factory that creates TestProtocolManager instances. 239 // Factory that creates TestProtocolManager instances.
244 class TestSBProtocolManagerFactory : public SBProtocolManagerFactory { 240 class TestSBProtocolManagerFactory : public SBProtocolManagerFactory {
245 public: 241 public:
246 TestSBProtocolManagerFactory() : pm_(NULL) {} 242 TestSBProtocolManagerFactory() : pm_(NULL) {}
247 virtual ~TestSBProtocolManagerFactory() {} 243 virtual ~TestSBProtocolManagerFactory() {}
248 244
249 virtual SafeBrowsingProtocolManager* CreateProtocolManager( 245 virtual SafeBrowsingProtocolManager* CreateProtocolManager(
250 SafeBrowsingService* sb_service, 246 SafeBrowsingService* sb_service,
251 const std::string& client_name, 247 const std::string& client_name,
252 const std::string& client_key,
253 const std::string& wrapped_key,
254 net::URLRequestContextGetter* request_context_getter, 248 net::URLRequestContextGetter* request_context_getter,
255 const std::string& info_url_prefix, 249 const std::string& url_prefix,
256 const std::string& mackey_url_prefix,
257 bool disable_auto_update) { 250 bool disable_auto_update) {
258 pm_ = new TestProtocolManager( 251 pm_ = new TestProtocolManager(
259 sb_service, client_name, client_key, wrapped_key, 252 sb_service, client_name, request_context_getter,
260 request_context_getter, info_url_prefix, mackey_url_prefix, 253 url_prefix, disable_auto_update);
261 disable_auto_update);
262 return pm_; 254 return pm_;
263 } 255 }
264 TestProtocolManager* GetProtocolManager() { 256 TestProtocolManager* GetProtocolManager() {
265 return pm_; 257 return pm_;
266 } 258 }
267 private: 259 private:
268 // Owned by the SafebrowsingService. 260 // Owned by the SafebrowsingService.
269 TestProtocolManager* pm_; 261 TestProtocolManager* pm_;
270 }; 262 };
271 263
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 756
765 // Delete the Profile. SBS stops again. 757 // Delete the Profile. SBS stops again.
766 pref_service2 = NULL; 758 pref_service2 = NULL;
767 profile2.reset(); 759 profile2.reset();
768 WaitForIOThread(); 760 WaitForIOThread();
769 EXPECT_FALSE(sb_service->enabled()); 761 EXPECT_FALSE(sb_service->enabled());
770 EXPECT_FALSE(csd_service->enabled()); 762 EXPECT_FALSE(csd_service->enabled());
771 } 763 }
772 764
773 } // namespace 765 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service.cc ('k') | chrome/browser/safe_browsing/safe_browsing_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698