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

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

Issue 8373021: Convert URLFetcher::Delegates to use an interface in content/public/common. Also remove the old U... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: take out CHECKs Created 9 years, 2 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) 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_MALWARE_DETAILS_CACHE_H_ 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_CACHE_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_CACHE_H_ 6 #define CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_CACHE_H_
7 #pragma once 7 #pragma once
8 8
9 // A class that gets malware details from the HTTP Cache. 9 // A class that gets malware details from the HTTP Cache.
10 // An instance of this class is generated by MalwareDetails. 10 // An instance of this class is generated by MalwareDetails.
11 11
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/callback.h" 15 #include "base/callback.h"
16 #include "base/hash_tables.h" 16 #include "base/hash_tables.h"
17 #include "base/memory/linked_ptr.h" 17 #include "base/memory/linked_ptr.h"
18 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
19 #include "chrome/browser/safe_browsing/report.pb.h" 19 #include "chrome/browser/safe_browsing/report.pb.h"
20 #include "content/common/net/url_fetcher.h" 20 #include "content/public/common/url_fetcher_delegate.h"
21 #include "net/base/completion_callback.h" 21 #include "net/base/completion_callback.h"
22 22
23 namespace net { 23 namespace net {
24 class URLRequestContext; 24 class URLRequestContext;
25 } 25 }
26 26
27 class MalwareDetailsFactory; 27 class MalwareDetailsFactory;
28 28
29 namespace safe_browsing { 29 namespace safe_browsing {
30 30
31 // Maps a URL to its Resource. 31 // Maps a URL to its Resource.
32 typedef base::hash_map< 32 typedef base::hash_map<
33 std::string, 33 std::string,
34 linked_ptr<safe_browsing::ClientMalwareReportRequest::Resource> > ResourceMap; 34 linked_ptr<safe_browsing::ClientMalwareReportRequest::Resource> > ResourceMap;
35 } 35 }
36 36
37 class MalwareDetailsCacheCollector 37 class MalwareDetailsCacheCollector
38 : public base::RefCountedThreadSafe<MalwareDetailsCacheCollector>, 38 : public base::RefCountedThreadSafe<MalwareDetailsCacheCollector>,
39 public URLFetcher::Delegate { 39 public content::URLFetcherDelegate {
40 40
41 public: 41 public:
42 MalwareDetailsCacheCollector(); 42 MalwareDetailsCacheCollector();
43 virtual ~MalwareDetailsCacheCollector(); 43 virtual ~MalwareDetailsCacheCollector();
44 44
45 // We use |request_context_getter|, we modify |resources| and 45 // We use |request_context_getter|, we modify |resources| and
46 // |result|, and we call |callback|, so they must all remain alive 46 // |result|, and we call |callback|, so they must all remain alive
47 // for the lifetime of this object. 47 // for the lifetime of this object.
48 void StartCacheCollection( 48 void StartCacheCollection(
49 net::URLRequestContextGetter* request_context_getter, 49 net::URLRequestContextGetter* request_context_getter,
50 safe_browsing::ResourceMap* resources, 50 safe_browsing::ResourceMap* resources,
51 bool* result, 51 bool* result,
52 const base::Closure& callback); 52 const base::Closure& callback);
53 53
54 // Returns whether or not StartCacheCollection has been called. 54 // Returns whether or not StartCacheCollection has been called.
55 bool HasStarted(); 55 bool HasStarted();
56 56
57 protected: 57 protected:
58 // Implementation of URLFetcher::Delegate. Called after the request 58 // Implementation of URLFetcher::Delegate. Called after the request
59 // completes (either successfully or with failure). 59 // completes (either successfully or with failure).
60 virtual void OnURLFetchComplete(const URLFetcher* source, 60 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE;
61 const GURL& url,
62 const net::URLRequestStatus& status,
63 int response_code,
64 const net::ResponseCookies& cookies,
65 const std::string& data) OVERRIDE;
66 61
67 private: 62 private:
68 // 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
69 // redirect chain. 64 // redirect chain.
70 safe_browsing::ResourceMap::iterator resources_it_; 65 safe_browsing::ResourceMap::iterator resources_it_;
71 66
72 // Points to the resources_ map in the MalwareDetails. 67 // Points to the resources_ map in the MalwareDetails.
73 safe_browsing::ResourceMap* resources_; 68 safe_browsing::ResourceMap* resources_;
74 69
75 // Points to the cache_result_ in the MalwareDetails. 70 // Points to the cache_result_ in the MalwareDetails.
(...skipping 30 matching lines...) Expand all
106 const std::string& data); 101 const std::string& data);
107 102
108 // Called when we are done. 103 // Called when we are done.
109 void AllDone(bool success); 104 void AllDone(bool success);
110 105
111 // Advances to the next entry in resources_it_. 106 // Advances to the next entry in resources_it_.
112 void AdvanceEntry(); 107 void AdvanceEntry();
113 }; 108 };
114 109
115 #endif // CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_CACHE_H_ 110 #endif // CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698