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

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

Issue 1569993003: Ensure ThreatDetails is always destroyed on the UI thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_THREAT_DETAILS_H_ 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_H_ 6 #define CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_H_
7 7
8 // A class that encapsulates the detailed threat reports sent when 8 // A class that encapsulates the detailed threat reports sent when
9 // users opt-in to do so from the safe browsing warning page. 9 // users opt-in to do so from the safe browsing warning page.
10 10
11 // An instance of this class is generated when a safe browsing warning page 11 // An instance of this class is generated when a safe browsing warning page
12 // is shown (SafeBrowsingBlockingPage). 12 // is shown (SafeBrowsingBlockingPage).
13 13
14 #include <string> 14 #include <string>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/containers/hash_tables.h" 17 #include "base/containers/hash_tables.h"
18 #include "base/gtest_prod_util.h" 18 #include "base/gtest_prod_util.h"
19 #include "base/macros.h" 19 #include "base/macros.h"
20 #include "base/memory/linked_ptr.h" 20 #include "base/memory/linked_ptr.h"
21 #include "base/memory/ref_counted.h" 21 #include "base/memory/ref_counted.h"
22 #include "base/memory/scoped_ptr.h" 22 #include "base/memory/scoped_ptr.h"
23 #include "chrome/browser/safe_browsing/ui_manager.h" 23 #include "chrome/browser/safe_browsing/ui_manager.h"
24 #include "chrome/common/safe_browsing/csd.pb.h" 24 #include "chrome/common/safe_browsing/csd.pb.h"
25 #include "content/public/browser/browser_thread.h"
25 #include "content/public/browser/web_contents_observer.h" 26 #include "content/public/browser/web_contents_observer.h"
26 #include "net/base/completion_callback.h" 27 #include "net/base/completion_callback.h"
27 28
28 namespace net { 29 namespace net {
29 class URLRequestContextGetter; 30 class URLRequestContextGetter;
30 } 31 }
31 32
32 class Profile; 33 class Profile;
33 struct SafeBrowsingHostMsg_ThreatDOMDetails_Node; 34 struct SafeBrowsingHostMsg_ThreatDOMDetails_Node;
34 35
35 namespace safe_browsing { 36 namespace safe_browsing {
36 37
37 // Maps a URL to its Resource. 38 // Maps a URL to its Resource.
38 class ThreatDetailsCacheCollector; 39 class ThreatDetailsCacheCollector;
39 class ThreatDetailsRedirectsCollector; 40 class ThreatDetailsRedirectsCollector;
40 class ThreatDetailsFactory; 41 class ThreatDetailsFactory;
41 42
42 typedef base::hash_map< 43 typedef base::hash_map<
43 std::string, 44 std::string,
44 linked_ptr<ClientSafeBrowsingReportRequest::Resource>> 45 linked_ptr<ClientSafeBrowsingReportRequest::Resource>>
45 ResourceMap; 46 ResourceMap;
46 47
47 class ThreatDetails : public base::RefCountedThreadSafe<ThreatDetails>, 48 class ThreatDetails : public base::RefCountedThreadSafe<
49 ThreatDetails,
50 content::BrowserThread::DeleteOnUIThread>,
48 public content::WebContentsObserver { 51 public content::WebContentsObserver {
49 public: 52 public:
50 typedef SafeBrowsingUIManager::UnsafeResource UnsafeResource; 53 typedef SafeBrowsingUIManager::UnsafeResource UnsafeResource;
51 54
52 // Constructs a new ThreatDetails instance, using the factory. 55 // Constructs a new ThreatDetails instance, using the factory.
53 static ThreatDetails* NewThreatDetails(SafeBrowsingUIManager* ui_manager, 56 static ThreatDetails* NewThreatDetails(SafeBrowsingUIManager* ui_manager,
54 content::WebContents* web_contents, 57 content::WebContents* web_contents,
55 const UnsafeResource& resource); 58 const UnsafeResource& resource);
56 59
57 // Makes the passed |factory| the factory used to instanciate 60 // Makes the passed |factory| the factory used to instanciate
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 Profile* profile_; 94 Profile* profile_;
92 95
93 // The report protocol buffer. 96 // The report protocol buffer.
94 scoped_ptr<ClientSafeBrowsingReportRequest> report_; 97 scoped_ptr<ClientSafeBrowsingReportRequest> report_;
95 98
96 // Used to get a pointer to the HTTP cache. 99 // Used to get a pointer to the HTTP cache.
97 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 100 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
98 101
99 private: 102 private:
100 friend class base::RefCountedThreadSafe<ThreatDetails>; 103 friend class base::RefCountedThreadSafe<ThreatDetails>;
104 friend struct content::BrowserThread::DeleteOnThread<
105 content::BrowserThread::UI>;
106 friend class base::DeleteHelper<ThreatDetails>;
101 107
102 // Starts the collection of the report. 108 // Starts the collection of the report.
103 void StartCollection(); 109 void StartCollection();
104 110
105 // Whether the url is "public" so we can add it to the report. 111 // Whether the url is "public" so we can add it to the report.
106 bool IsReportableUrl(const GURL& url) const; 112 bool IsReportableUrl(const GURL& url) const;
107 113
108 // Finds an existing Resource for the given url, or creates a new 114 // Finds an existing Resource for the given url, or creates a new
109 // one if not found, and adds it to |resources_|. Returns the 115 // one if not found, and adds it to |resources_|. Returns the
110 // found/created resource. 116 // found/created resource.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 174
169 virtual ThreatDetails* CreateThreatDetails( 175 virtual ThreatDetails* CreateThreatDetails(
170 SafeBrowsingUIManager* ui_manager, 176 SafeBrowsingUIManager* ui_manager,
171 content::WebContents* web_contents, 177 content::WebContents* web_contents,
172 const SafeBrowsingUIManager::UnsafeResource& unsafe_resource) = 0; 178 const SafeBrowsingUIManager::UnsafeResource& unsafe_resource) = 0;
173 }; 179 };
174 180
175 } // namespace safe_browsing 181 } // namespace safe_browsing
176 182
177 #endif // CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_H_ 183 #endif // CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698