Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 // The Safe Browsing service is responsible for downloading anti-phishing and | 5 // The Safe Browsing service is responsible for downloading anti-phishing and |
| 6 // anti-malware tables and checking urls against them. | 6 // anti-malware tables and checking urls against them. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ | 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ |
| 9 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ | 9 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ |
| 10 #pragma once | 10 #pragma once |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 scoped_ptr<SBFullHash> full_hash; | 95 scoped_ptr<SBFullHash> full_hash; |
| 96 | 96 |
| 97 Client* client; | 97 Client* client; |
| 98 bool need_get_hash; | 98 bool need_get_hash; |
| 99 base::TimeTicks start; // When check was sent to SB service. | 99 base::TimeTicks start; // When check was sent to SB service. |
| 100 UrlCheckResult result; | 100 UrlCheckResult result; |
| 101 bool is_download; // If this check for download url or hash. | 101 bool is_download; // If this check for download url or hash. |
| 102 std::vector<SBPrefix> prefix_hits; | 102 std::vector<SBPrefix> prefix_hits; |
| 103 std::vector<SBFullHashResult> full_hits; | 103 std::vector<SBFullHashResult> full_hits; |
| 104 | 104 |
| 105 // Task to make the callback to safebrowsing clients in case | 105 // Flag to cancel the check if it takes too long. This is owned |
| 106 // safebrowsing check takes too long to finish. Not owned by | 106 // by the timeout task. If the timeout runs first, the check's |
| 107 // this class. | 107 // client will be cleared, as will this pointer. If the check is |
| 108 // completed before the timeout, the flag is set and the timeout | |
| 109 // will not fire. | |
|
awong
2011/11/14 20:13:37
Wow. complicated.
So the flag is owned by the tim
Scott Hess - ex-Googler
2011/11/14 23:21:54
I think so. Author has left the project ...
| |
| 108 // TODO(lzheng): We should consider to use this time out check | 110 // TODO(lzheng): We should consider to use this time out check |
| 109 // for browsing too (instead of implementin in | 111 // for browsing too (instead of implementin in |
| 110 // safe_browsing_resource_handler.cc). | 112 // safe_browsing_resource_handler.cc). |
| 111 CancelableTask* timeout_task; | 113 bool* cancel_timeout; |
| 112 | 114 |
| 113 private: | 115 private: |
| 114 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingCheck); | 116 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingCheck); |
| 115 }; | 117 }; |
| 116 | 118 |
| 117 // Observer class can be used to get notified when a SafeBrowsing hit | 119 // Observer class can be used to get notified when a SafeBrowsing hit |
| 118 // was found. | 120 // was found. |
| 119 class Observer { | 121 class Observer { |
| 120 public: | 122 public: |
| 121 // The |resource| must not be accessed after OnSafeBrowsingHit returns. | 123 // The |resource| must not be accessed after OnSafeBrowsingHit returns. |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 435 | 437 |
| 436 // Checks the download hash on safe_browsing_thread_. | 438 // Checks the download hash on safe_browsing_thread_. |
| 437 void CheckDownloadHashOnSBThread(SafeBrowsingCheck* check); | 439 void CheckDownloadHashOnSBThread(SafeBrowsingCheck* check); |
| 438 | 440 |
| 439 // Invoked by CheckDownloadUrl. It checks the download URL on | 441 // Invoked by CheckDownloadUrl. It checks the download URL on |
| 440 // safe_browsing_thread_. | 442 // safe_browsing_thread_. |
| 441 void CheckDownloadUrlOnSBThread(SafeBrowsingCheck* check); | 443 void CheckDownloadUrlOnSBThread(SafeBrowsingCheck* check); |
| 442 | 444 |
| 443 // The callback function when a safebrowsing check is timed out. Client will | 445 // The callback function when a safebrowsing check is timed out. Client will |
| 444 // be notified that the safebrowsing check is SAFE when this happens. | 446 // be notified that the safebrowsing check is SAFE when this happens. |
| 445 void TimeoutCallback(SafeBrowsingCheck* check); | 447 void TimeoutCallback(SafeBrowsingCheck* check, bool* cancel_timeout); |
| 446 | 448 |
| 447 // Calls the Client's callback on IO thread after CheckDownloadUrl finishes. | 449 // Calls the Client's callback on IO thread after CheckDownloadUrl finishes. |
| 448 void CheckDownloadUrlDone(SafeBrowsingCheck* check); | 450 void CheckDownloadUrlDone(SafeBrowsingCheck* check); |
| 449 | 451 |
| 450 // Calls the Client's callback on IO thread after CheckDownloadHash finishes. | 452 // Calls the Client's callback on IO thread after CheckDownloadHash finishes. |
| 451 void CheckDownloadHashDone(SafeBrowsingCheck* check); | 453 void CheckDownloadHashDone(SafeBrowsingCheck* check); |
| 452 | 454 |
| 453 // Helper function that calls safe browsing client and cleans up |checks_|. | 455 // Helper function that calls safe browsing client and cleans up |checks_|. |
| 454 void SafeBrowsingCheckDone(SafeBrowsingCheck* check); | 456 void SafeBrowsingCheckDone(SafeBrowsingCheck* check); |
| 455 | 457 |
| 456 // Helper function to set |check| with default values and start a safe | 458 // Helper function to set |check| with default values and start a safe |
| 457 // browsing check with timeout of |timeout_ms|. |task| will be called upon | 459 // browsing check with timeout of |timeout_ms|. |task| will be called upon |
| 458 // success, otherwise TimeoutCallback will be called. | 460 // success, otherwise TimeoutCallback will be called. |
| 459 void StartDownloadCheck(SafeBrowsingCheck* check, | 461 void StartDownloadCheck(SafeBrowsingCheck* check, |
| 460 Client* client, | 462 Client* client, |
| 461 CancelableTask* task, | 463 const base::Closure& task, |
| 462 int64 timeout_ms); | 464 int64 timeout_ms); |
| 463 | 465 |
| 464 // Adds the given entry to the whitelist. Called on the UI thread. | 466 // Adds the given entry to the whitelist. Called on the UI thread. |
| 465 void UpdateWhitelist(const UnsafeResource& resource); | 467 void UpdateWhitelist(const UnsafeResource& resource); |
| 466 | 468 |
| 467 // content::NotificationObserver override | 469 // content::NotificationObserver override |
| 468 virtual void Observe(int type, | 470 virtual void Observe(int type, |
| 469 const content::NotificationSource& source, | 471 const content::NotificationSource& source, |
| 470 const content::NotificationDetails& details) OVERRIDE; | 472 const content::NotificationDetails& details) OVERRIDE; |
| 471 | 473 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 572 class SafeBrowsingServiceFactory { | 574 class SafeBrowsingServiceFactory { |
| 573 public: | 575 public: |
| 574 SafeBrowsingServiceFactory() { } | 576 SafeBrowsingServiceFactory() { } |
| 575 virtual ~SafeBrowsingServiceFactory() { } | 577 virtual ~SafeBrowsingServiceFactory() { } |
| 576 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; | 578 virtual SafeBrowsingService* CreateSafeBrowsingService() = 0; |
| 577 private: | 579 private: |
| 578 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); | 580 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceFactory); |
| 579 }; | 581 }; |
| 580 | 582 |
| 581 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ | 583 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_SERVICE_H_ |
| OLD | NEW |