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

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

Issue 1420053005: Move code in components/safe_browsing_db and chrome/browser/s_b/ under the safe_browsing namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@02_components_move
Patch Set: Remove '// namespace safe_browsing' for a small fwd decl block. Created 5 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
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_THREAT_DETAILS_CACHE_H_ 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_CACHE_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_CACHE_H_ 6 #define CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_CACHE_H_
7 7
8 // A class that gets threat details from the HTTP Cache. 8 // A class that gets threat details from the HTTP Cache.
9 // An instance of this class is generated by ThreatDetails. 9 // An instance of this class is generated by ThreatDetails.
10 10
(...skipping 11 matching lines...) Expand all
22 namespace net { 22 namespace net {
23 class URLFetcher; 23 class URLFetcher;
24 class URLRequestContext; 24 class URLRequestContext;
25 } 25 }
26 26
27 namespace safe_browsing { 27 namespace safe_browsing {
28 28
29 // Maps a URL to its Resource. 29 // Maps a URL to its Resource.
30 typedef base::hash_map< 30 typedef base::hash_map<
31 std::string, 31 std::string,
32 linked_ptr<safe_browsing::ClientSafeBrowsingReportRequest::Resource>> 32 linked_ptr<ClientSafeBrowsingReportRequest::Resource>>
33 ResourceMap; 33 ResourceMap;
34 }
35 34
36 class ThreatDetailsCacheCollector 35 class ThreatDetailsCacheCollector
37 : public base::RefCountedThreadSafe<ThreatDetailsCacheCollector>, 36 : public base::RefCountedThreadSafe<ThreatDetailsCacheCollector>,
38 public net::URLFetcherDelegate { 37 public net::URLFetcherDelegate {
39 public: 38 public:
40 ThreatDetailsCacheCollector(); 39 ThreatDetailsCacheCollector();
41 40
42 // We use |request_context_getter|, we modify |resources| and 41 // We use |request_context_getter|, we modify |resources| and
43 // |result|, and we call |callback|, so they must all remain alive 42 // |result|, and we call |callback|, so they must all remain alive
44 // for the lifetime of this object. 43 // for the lifetime of this object.
45 void StartCacheCollection( 44 void StartCacheCollection(
46 net::URLRequestContextGetter* request_context_getter, 45 net::URLRequestContextGetter* request_context_getter,
47 safe_browsing::ResourceMap* resources, 46 ResourceMap* resources,
48 bool* result, 47 bool* result,
49 const base::Closure& callback); 48 const base::Closure& callback);
50 49
51 // Returns whether or not StartCacheCollection has been called. 50 // Returns whether or not StartCacheCollection has been called.
52 bool HasStarted(); 51 bool HasStarted();
53 52
54 protected: 53 protected:
55 // Implementation of URLFetcher::Delegate. Called after the request 54 // Implementation of URLFetcher::Delegate. Called after the request
56 // completes (either successfully or with failure). 55 // completes (either successfully or with failure).
57 void OnURLFetchComplete(const net::URLFetcher* source) override; 56 void OnURLFetchComplete(const net::URLFetcher* source) override;
58 57
59 private: 58 private:
60 friend class base::RefCountedThreadSafe<ThreatDetailsCacheCollector>; 59 friend class base::RefCountedThreadSafe<ThreatDetailsCacheCollector>;
61 60
62 ~ThreatDetailsCacheCollector() override; 61 ~ThreatDetailsCacheCollector() override;
63 62
64 // Points to the url for which we are fetching the HTTP cache entry or 63 // Points to the url for which we are fetching the HTTP cache entry or
65 // redirect chain. 64 // redirect chain.
66 safe_browsing::ResourceMap::iterator resources_it_; 65 ResourceMap::iterator resources_it_;
67 66
68 // Points to the resources_ map in the ThreatDetails. 67 // Points to the resources_ map in the ThreatDetails.
69 safe_browsing::ResourceMap* resources_; 68 ResourceMap* resources_;
70 69
71 // Points to the cache_result_ in the ThreatDetails. 70 // Points to the cache_result_ in the ThreatDetails.
72 bool* result_; 71 bool* result_;
73 72
74 // Method we call when we are done. The caller must be alive for the 73 // Method we call when we are done. The caller must be alive for the
75 // whole time, we are modifying its state (see above). 74 // whole time, we are modifying its state (see above).
76 base::Closure callback_; 75 base::Closure callback_;
77 76
78 // Set to true as soon as StartCacheCollection is called. 77 // Set to true as soon as StartCacheCollection is called.
79 bool has_started_; 78 bool has_started_;
80 79
81 // Used to get a pointer to the current request context. 80 // Used to get a pointer to the current request context.
82 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 81 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
83 82
84 // The current URLFetcher. 83 // The current URLFetcher.
85 scoped_ptr<net::URLFetcher> current_fetch_; 84 scoped_ptr<net::URLFetcher> current_fetch_;
86 85
87 // Returns the resource from resources_ that corresponds to |url| 86 // Returns the resource from resources_ that corresponds to |url|
88 safe_browsing::ClientSafeBrowsingReportRequest::Resource* GetResource( 87 ClientSafeBrowsingReportRequest::Resource* GetResource(
89 const GURL& url); 88 const GURL& url);
90 89
91 // Creates a new URLFetcher and starts it. 90 // Creates a new URLFetcher and starts it.
92 void OpenEntry(); 91 void OpenEntry();
93 92
94 // Read the HTTP response from |source| and add it to |pb_resource|. 93 // Read the HTTP response from |source| and add it to |pb_resource|.
95 void ReadResponse( 94 void ReadResponse(
96 safe_browsing::ClientSafeBrowsingReportRequest::Resource* pb_resource, 95 ClientSafeBrowsingReportRequest::Resource* pb_resource,
97 const net::URLFetcher* source); 96 const net::URLFetcher* source);
98 97
99 // Read the body |data| and add it to |pb_resource|. 98 // Read the body |data| and add it to |pb_resource|.
100 void ReadData( 99 void ReadData(
101 safe_browsing::ClientSafeBrowsingReportRequest::Resource* pb_resource, 100 ClientSafeBrowsingReportRequest::Resource* pb_resource,
102 const std::string& data); 101 const std::string& data);
103 102
104 // Called when we are done. 103 // Called when we are done.
105 void AllDone(bool success); 104 void AllDone(bool success);
106 105
107 // Advances to the next entry in resources_it_. 106 // Advances to the next entry in resources_it_.
108 void AdvanceEntry(); 107 void AdvanceEntry();
109 }; 108 };
110 109
110 } // namespace safe_browsing
111
111 #endif // CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_CACHE_H_ 112 #endif // CHROME_BROWSER_SAFE_BROWSING_THREAT_DETAILS_CACHE_H_
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/threat_details.cc ('k') | chrome/browser/safe_browsing/threat_details_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698