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

Side by Side Diff: chrome/browser/safe_browsing/protocol_manager.h

Issue 8373021: Convert URLFetcher::Delegates to use an interface in content/public/common. Also remove the old U... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync and remove unncessary forward declares Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ 6 #define CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 // A class that implements Chrome's interface with the SafeBrowsing protocol. 9 // A class that implements Chrome's interface with the SafeBrowsing protocol.
10 // The SafeBrowsingProtocolManager handles formatting and making requests of, 10 // The SafeBrowsingProtocolManager handles formatting and making requests of,
11 // and handling responses from, Google's SafeBrowsing servers. This class uses 11 // and handling responses from, Google's SafeBrowsing servers. This class uses
12 // The SafeBrowsingProtocolParser class to do the actual parsing. 12 // The SafeBrowsingProtocolParser class to do the actual parsing.
13 13
14 #include <deque> 14 #include <deque>
15 #include <set> 15 #include <set>
16 #include <string> 16 #include <string>
17 #include <vector> 17 #include <vector>
18 18
19 #include "base/gtest_prod_util.h" 19 #include "base/gtest_prod_util.h"
20 #include "base/hash_tables.h" 20 #include "base/hash_tables.h"
21 #include "base/memory/scoped_ptr.h" 21 #include "base/memory/scoped_ptr.h"
22 #include "base/time.h" 22 #include "base/time.h"
23 #include "base/timer.h" 23 #include "base/timer.h"
24 #include "chrome/browser/safe_browsing/chunk_range.h" 24 #include "chrome/browser/safe_browsing/chunk_range.h"
25 #include "chrome/browser/safe_browsing/protocol_parser.h" 25 #include "chrome/browser/safe_browsing/protocol_parser.h"
26 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 26 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
27 #include "chrome/browser/safe_browsing/safe_browsing_util.h" 27 #include "chrome/browser/safe_browsing/safe_browsing_util.h"
28 #include "content/common/net/url_fetcher.h" 28 #include "content/public/common/url_fetcher_delegate.h"
29 29
30 namespace net { 30 namespace net {
31 class URLRequestStatus; 31 class URLRequestStatus;
32 } // namespace net 32 } // namespace net
33 33
34 #if defined(COMPILER_GCC) 34 #if defined(COMPILER_GCC)
35 // Allows us to use URLFetchers in a hash_map with gcc (MSVC is okay without 35 // Allows us to use URLFetchers in a hash_map with gcc (MSVC is okay without
36 // specifying this). 36 // specifying this).
37 namespace __gnu_cxx { 37 namespace __gnu_cxx {
38 template<> 38 template<>
(...skipping 17 matching lines...) Expand all
56 const std::string& client_key, 56 const std::string& client_key,
57 const std::string& wrapped_key, 57 const std::string& wrapped_key,
58 net::URLRequestContextGetter* request_context_getter, 58 net::URLRequestContextGetter* request_context_getter,
59 const std::string& info_url_prefix, 59 const std::string& info_url_prefix,
60 const std::string& mackey_url_prefix, 60 const std::string& mackey_url_prefix,
61 bool disable_auto_update) = 0; 61 bool disable_auto_update) = 0;
62 private: 62 private:
63 DISALLOW_COPY_AND_ASSIGN(SBProtocolManagerFactory); 63 DISALLOW_COPY_AND_ASSIGN(SBProtocolManagerFactory);
64 }; 64 };
65 65
66 class SafeBrowsingProtocolManager : public URLFetcher::Delegate { 66 class SafeBrowsingProtocolManager : public content::URLFetcherDelegate {
67 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestBackOffTimes); 67 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestBackOffTimes);
68 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestChunkStrings); 68 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestChunkStrings);
69 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestGetHashUrl); 69 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestGetHashUrl);
70 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, 70 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest,
71 TestGetHashBackOffTimes); 71 TestGetHashBackOffTimes);
72 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestMacKeyUrl); 72 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestMacKeyUrl);
73 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, 73 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest,
74 TestSafeBrowsingHitUrl); 74 TestSafeBrowsingHitUrl);
75 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, 75 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest,
76 TestMalwareDetailsUrl); 76 TestMalwareDetailsUrl);
(...skipping 18 matching lines...) Expand all
95 const std::string& wrapped_key, 95 const std::string& wrapped_key,
96 net::URLRequestContextGetter* request_context_getter, 96 net::URLRequestContextGetter* request_context_getter,
97 const std::string& info_url_prefix, 97 const std::string& info_url_prefix,
98 const std::string& mackey_url_prefix, 98 const std::string& mackey_url_prefix,
99 bool disable_auto_update); 99 bool disable_auto_update);
100 100
101 // Sets up the update schedule and internal state for making periodic requests 101 // Sets up the update schedule and internal state for making periodic requests
102 // of the SafeBrowsing service. 102 // of the SafeBrowsing service.
103 virtual void Initialize(); 103 virtual void Initialize();
104 104
105 // URLFetcher::Delegate interface. 105 // content::URLFetcherDelegate interface.
106 virtual void OnURLFetchComplete(const URLFetcher* source, 106 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE;
107 const GURL& url,
108 const net::URLRequestStatus& status,
109 int response_code,
110 const net::ResponseCookies& cookies,
111 const std::string& data) OVERRIDE;
112 107
113 // API used by the SafeBrowsingService for issuing queries. When the results 108 // API used by the SafeBrowsingService for issuing queries. When the results
114 // are available, SafeBrowsingService::HandleGetHashResults is called. 109 // are available, SafeBrowsingService::HandleGetHashResults is called.
115 virtual void GetFullHash(SafeBrowsingService::SafeBrowsingCheck* check, 110 virtual void GetFullHash(SafeBrowsingService::SafeBrowsingCheck* check,
116 const std::vector<SBPrefix>& prefixes); 111 const std::vector<SBPrefix>& prefixes);
117 112
118 // Forces the start of next update after |next_update_msec| in msec. 113 // Forces the start of next update after |next_update_msec| in msec.
119 void ForceScheduleNextUpdate(int next_update_msec); 114 void ForceScheduleNextUpdate(int next_update_msec);
120 115
121 // Scheduled update callback. 116 // Scheduled update callback.
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 std::string https_url_prefix_; 402 std::string https_url_prefix_;
408 403
409 // When true, protocol manager will not start an update unless 404 // When true, protocol manager will not start an update unless
410 // ForceScheduleNextUpdate() is called. This is set for testing purpose. 405 // ForceScheduleNextUpdate() is called. This is set for testing purpose.
411 bool disable_auto_update_; 406 bool disable_auto_update_;
412 407
413 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingProtocolManager); 408 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingProtocolManager);
414 }; 409 };
415 410
416 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ 411 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698