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

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

Issue 10386063: Move URLFetcherDelegate to net/ and split URLFetcher between net/ and content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync to head, fix win component build Created 8 years, 7 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 #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,
(...skipping 14 matching lines...) Expand all
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/public/common/url_fetcher_delegate.h" 28 #include "content/public/common/url_fetcher_delegate.h"
29 29
30 #if defined(COMPILER_GCC) 30 #if defined(COMPILER_GCC)
31 // Allows us to use URLFetchers in a hash_map with gcc (MSVC is okay without 31 // Allows us to use URLFetchers in a hash_map with gcc (MSVC is okay without
32 // specifying this). 32 // specifying this).
33 namespace __gnu_cxx { 33 namespace __gnu_cxx {
34 template<> 34 template<>
35 struct hash<const content::URLFetcher*> { 35 struct hash<const net::URLFetcher*> {
36 size_t operator()(const content::URLFetcher* fetcher) const { 36 size_t operator()(const net::URLFetcher* fetcher) const {
37 return reinterpret_cast<size_t>(fetcher); 37 return reinterpret_cast<size_t>(fetcher);
38 } 38 }
39 }; 39 };
40 } 40 }
41 #endif 41 #endif
42 42
43 class SafeBrowsingProtocolManager; 43 class SafeBrowsingProtocolManager;
44 // Interface of a factory to create ProtocolManager. Useful for tests. 44 // Interface of a factory to create ProtocolManager. Useful for tests.
45 class SBProtocolManagerFactory { 45 class SBProtocolManagerFactory {
46 public: 46 public:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 const std::string& client_name, 85 const std::string& client_name,
86 net::URLRequestContextGetter* request_context_getter, 86 net::URLRequestContextGetter* request_context_getter,
87 const std::string& url_prefix, 87 const std::string& url_prefix,
88 bool disable_auto_update); 88 bool disable_auto_update);
89 89
90 // Sets up the update schedule and internal state for making periodic requests 90 // Sets up the update schedule and internal state for making periodic requests
91 // of the SafeBrowsing service. 91 // of the SafeBrowsing service.
92 virtual void Initialize(); 92 virtual void Initialize();
93 93
94 // content::URLFetcherDelegate interface. 94 // content::URLFetcherDelegate interface.
95 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; 95 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
96 96
97 // API used by the SafeBrowsingService for issuing queries. When the results 97 // API used by the SafeBrowsingService for issuing queries. When the results
98 // are available, SafeBrowsingService::HandleGetHashResults is called. 98 // are available, SafeBrowsingService::HandleGetHashResults is called.
99 virtual void GetFullHash(SafeBrowsingService::SafeBrowsingCheck* check, 99 virtual void GetFullHash(SafeBrowsingService::SafeBrowsingCheck* check,
100 const std::vector<SBPrefix>& prefixes); 100 const std::vector<SBPrefix>& prefixes);
101 101
102 // Forces the start of next update after |next_update_msec| in msec. 102 // Forces the start of next update after |next_update_msec| in msec.
103 void ForceScheduleNextUpdate(int next_update_msec); 103 void ForceScheduleNextUpdate(int next_update_msec);
104 104
105 // Scheduled update callback. 105 // Scheduled update callback.
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 303
304 // For managing the next earliest time to query the SafeBrowsing servers for 304 // For managing the next earliest time to query the SafeBrowsing servers for
305 // updates. 305 // updates.
306 int next_update_sec_; 306 int next_update_sec_;
307 base::OneShotTimer<SafeBrowsingProtocolManager> update_timer_; 307 base::OneShotTimer<SafeBrowsingProtocolManager> update_timer_;
308 308
309 // All chunk requests that need to be made. 309 // All chunk requests that need to be made.
310 std::deque<ChunkUrl> chunk_request_urls_; 310 std::deque<ChunkUrl> chunk_request_urls_;
311 311
312 // Map of GetHash requests. 312 // Map of GetHash requests.
313 typedef base::hash_map<const content::URLFetcher*, 313 typedef base::hash_map<const net::URLFetcher*,
314 SafeBrowsingService::SafeBrowsingCheck*> HashRequests; 314 SafeBrowsingService::SafeBrowsingCheck*> HashRequests;
315 HashRequests hash_requests_; 315 HashRequests hash_requests_;
316 316
317 // The next scheduled update has special behavior for the first 2 requests. 317 // The next scheduled update has special behavior for the first 2 requests.
318 enum UpdateRequestState { 318 enum UpdateRequestState {
319 FIRST_REQUEST = 0, 319 FIRST_REQUEST = 0,
320 SECOND_REQUEST, 320 SECOND_REQUEST,
321 NORMAL_REQUEST 321 NORMAL_REQUEST
322 }; 322 };
323 UpdateRequestState update_state_; 323 UpdateRequestState update_state_;
(...skipping 12 matching lines...) Expand all
336 std::string version_; 336 std::string version_;
337 337
338 // Used for measuring chunk request latency. 338 // Used for measuring chunk request latency.
339 base::Time chunk_request_start_; 339 base::Time chunk_request_start_;
340 340
341 // Tracks the size of each update (in bytes). 341 // Tracks the size of each update (in bytes).
342 int update_size_; 342 int update_size_;
343 343
344 // Track outstanding SafeBrowsing report fetchers for clean up. 344 // Track outstanding SafeBrowsing report fetchers for clean up.
345 // We add both "hit" and "detail" fetchers in this set. 345 // We add both "hit" and "detail" fetchers in this set.
346 std::set<const content::URLFetcher*> safebrowsing_reports_; 346 std::set<const net::URLFetcher*> safebrowsing_reports_;
347 347
348 // The safe browsing client name sent in each request. 348 // The safe browsing client name sent in each request.
349 std::string client_name_; 349 std::string client_name_;
350 350
351 // A string that is appended to the end of URLs for download, gethash, 351 // A string that is appended to the end of URLs for download, gethash,
352 // safebrowsing hits and chunk update requests. 352 // safebrowsing hits and chunk update requests.
353 std::string additional_query_; 353 std::string additional_query_;
354 354
355 // The context we use to issue network requests. 355 // The context we use to issue network requests.
356 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 356 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
357 357
358 // URL prefix where browser fetches safebrowsing chunk updates, hashes, and 358 // URL prefix where browser fetches safebrowsing chunk updates, hashes, and
359 // reports hits to the safebrowsing list and sends detaild malware reports 359 // reports hits to the safebrowsing list and sends detaild malware reports
360 // for UMA users. 360 // for UMA users.
361 std::string url_prefix_; 361 std::string url_prefix_;
362 362
363 // When true, protocol manager will not start an update unless 363 // When true, protocol manager will not start an update unless
364 // ForceScheduleNextUpdate() is called. This is set for testing purpose. 364 // ForceScheduleNextUpdate() is called. This is set for testing purpose.
365 bool disable_auto_update_; 365 bool disable_auto_update_;
366 366
367 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingProtocolManager); 367 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingProtocolManager);
368 }; 368 };
369 369
370 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ 370 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/malware_details_cache.cc ('k') | chrome/browser/safe_browsing/protocol_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698