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

Side by Side Diff: chrome/browser/loader/safe_browsing_resource_throttle.h

Issue 2876473003: [ABANDONED] [WIP] Refactor SafeBrowsingResourceThrottle in preparation for WebSocket (Closed)
Patch Set: Minor fixes Created 3 years, 6 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
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_LOADER_SAFE_BROWSING_RESOURCE_THROTTLE_H_ 5 #ifndef CHROME_BROWSER_LOADER_SAFE_BROWSING_RESOURCE_THROTTLE_H_
6 #define CHROME_BROWSER_LOADER_SAFE_BROWSING_RESOURCE_THROTTLE_H_ 6 #define CHROME_BROWSER_LOADER_SAFE_BROWSING_RESOURCE_THROTTLE_H_
7 7
8 #include <string> 8 #include <memory>
9 #include <vector>
10 9
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/time/time.h"
14 #include "base/timer/timer.h"
15 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
16 #include "chrome/browser/safe_browsing/ui_manager.h"
17 #include "components/safe_browsing/base_resource_throttle.h"
18 #include "components/safe_browsing/base_ui_manager.h"
19 #include "components/safe_browsing_db/database_manager.h"
20 #include "components/security_interstitials/content/unsafe_resource.h"
21 #include "content/public/browser/resource_throttle.h"
22 #include "content/public/common/resource_type.h" 10 #include "content/public/common/resource_type.h"
23 #include "url/gurl.h"
24 11
25 namespace content { 12 namespace content {
26 class ResourceRequestInfo; 13 class ResourceThrottle;
27 } 14 }
28 15
29 namespace net { 16 namespace net {
30 class URLRequest; 17 class URLRequest;
31 } 18 }
32 19
33 namespace safe_browsing { 20 namespace safe_browsing {
34 class BaseUIManager; 21 class SafeBrowsingService;
35 } 22 }
36 23
37 // SafeBrowsingResourceThrottle functions as its base class 24 // SafeBrowsingResourceThrottle functions as its base class
38 // safe_browsing::BaseResourceThrottle, but dispatches to either the local or 25 // safe_browsing::BaseResourceThrottle, but dispatches to either the local or
39 // remote SafeBrowsingDatabaseManager, depending on if running on desktop or 26 // remote SafeBrowsingDatabaseManager, depending on if running on desktop or
40 // mobile. It also has its own chrome-specific prerender check of redirect URLs 27 // mobile. It also has its own chrome-specific prerender check of redirect URLs
41 // inside StartDisplayingBlockingPage(). 28 // inside StartDisplayingBlockingPage().
42 // 29 //
43 // See also safe_browsing::BaseResourceThrottle for details on how the safe 30 // See also safe_browsing::BaseResourceThrottle for details on how the safe
44 // browsing check occurs. 31 // browsing check occurs.
(...skipping 10 matching lines...) Expand all
55 // 42 //
56 // On mobile (ifdef SAFE_BROWSING_DB_REMOTE): 43 // On mobile (ifdef SAFE_BROWSING_DB_REMOTE):
57 // ----------------------------------------- 44 // -----------------------------------------
58 // The check is started and runs in parallel with the resource load. If the 45 // The check is started and runs in parallel with the resource load. If the
59 // check is not complete by the time the headers are loaded, the request is 46 // check is not complete by the time the headers are loaded, the request is
60 // suspended until the URL is classified. We let the headers load on mobile 47 // suspended until the URL is classified. We let the headers load on mobile
61 // since the RemoteSafeBrowsingDatabase checks always have some non-zero 48 // since the RemoteSafeBrowsingDatabase checks always have some non-zero
62 // latency -- there no synchronous pass. This parallelism helps 49 // latency -- there no synchronous pass. This parallelism helps
63 // performance. Redirects are handled the same way as desktop so they 50 // performance. Redirects are handled the same way as desktop so they
64 // always defer. 51 // always defer.
65 class SafeBrowsingResourceThrottle
66 : public safe_browsing::BaseResourceThrottle {
67 public:
68 // Will construct a SafeBrowsingResourceThrottle, or return NULL
69 // if on Android and not in the field trial.
70 static SafeBrowsingResourceThrottle* MaybeCreate(
71 net::URLRequest* request,
72 content::ResourceType resource_type,
73 safe_browsing::SafeBrowsingService* sb_service);
74 52
75 const char* GetNameForLogging() const override; 53 extern std::unique_ptr<content::ResourceThrottle>
76 54 MaybeCreateSafeBrowsingResourceThrottle(
77 protected: 55 net::URLRequest* request,
78 SafeBrowsingResourceThrottle(const net::URLRequest* request, 56 content::ResourceType resource_type,
79 content::ResourceType resource_type, 57 safe_browsing::SafeBrowsingService* sb_service);
80 safe_browsing::SafeBrowsingService* sb_service);
81
82 private:
83 ~SafeBrowsingResourceThrottle() override;
84
85 // This posts a task to destroy prerender contents
86 void MaybeDestroyPrerenderContents(
87 const content::ResourceRequestInfo* info) override;
88
89 void StartDisplayingBlockingPageHelper(
90 security_interstitials::UnsafeResource resource) override;
91
92 // Starts displaying the safe browsing interstitial page if it's not
93 // prerendering. Called on the UI thread.
94 static void StartDisplayingBlockingPage(
95 const base::WeakPtr<safe_browsing::BaseResourceThrottle>& throttle,
96 scoped_refptr<safe_browsing::BaseUIManager> ui_manager,
97 const security_interstitials::UnsafeResource& resource);
98
99 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingResourceThrottle);
100 };
101 58
102 #endif // CHROME_BROWSER_LOADER_SAFE_BROWSING_RESOURCE_THROTTLE_H_ 59 #endif // CHROME_BROWSER_LOADER_SAFE_BROWSING_RESOURCE_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698