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

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

Issue 6611023: The optional Malware Details also collects HTTP cache information. See design... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_CACHE_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_CACHE_H_
7 #pragma once
8
9 // A class that gets malware details from the HTTP Cache.
10
11 // An instance of this class is generated by MalwareDetails.
12
13 #include <string>
14 #include <vector>
15
16 #include "base/hash_tables.h"
17 #include "base/memory/linked_ptr.h"
18 #include "chrome/browser/safe_browsing/report.pb.h"
19 #include "net/base/completion_callback.h"
20
21 namespace disk_cache {
22 class Backend;
23 class Entry;
24 }
25 namespace net {
26 class IOBuffer;
27 class URLRequestContext;
28 }
29
30 class MalwareDetailsFactory;
31
32 namespace safe_browsing {
33
34 // Maps a URL to its Resource.
35 typedef base::hash_map<
36 std::string,
37 linked_ptr<safe_browsing::ClientMalwareReportRequest::Resource> > ResourceMap;
38 }
39
40 class MalwareDetailsCacheCollector
41 : public base::RefCountedThreadSafe<MalwareDetailsCacheCollector> {
noelutz 2011/04/06 20:34:19 include base/memory/ref_counted.h?
panayiotis 2011/04/07 20:08:32 Done.
42
43 public:
44
noelutz 2011/04/06 20:34:19 nit: remove extra nl?
panayiotis 2011/04/07 20:08:32 Done.
45 MalwareDetailsCacheCollector();
46 ~MalwareDetailsCacheCollector();
noelutz 2011/04/06 20:34:19 I think the destructor needs to be private? See r
panayiotis 2011/04/07 20:08:32 Done.
47
48 void StartCacheCollection(
noelutz 2011/04/06 20:34:19 I think this methods needs a comment. E.g., how l
panayiotis 2011/04/07 20:08:32 Done.
49 URLRequestContextGetter* request_context_getter,
50 safe_browsing::ResourceMap* resources,
51 int* result,
52 Task* callback);
53
54 // Methods for getting the HTML body and HTTP headers from the HTTP cache.
55 // They run on the IO thread.
56 void CacheLoop(int result);
57 int DoOpenCache();
noelutz 2011/04/06 20:34:19 Do all these methods have to be public?
panayiotis 2011/04/07 20:08:32 Done.
58 int DoOpenCacheComplete(int result);
59 int DoOpenEntry();
60 int DoOpenEntryComplete(int result);
61 int DoReadResponse();
62 int DoReadResponseComplete(int result);
63 int DoReadData();
64 int DoReadDataComplete(int result);
65 void DoCacheDone(int result);
66
67 bool InProgress();
noelutz 2011/04/06 20:34:19 Maybe add a comment for all public methods?
panayiotis 2011/04/07 20:08:32 Done.
68
69 protected:
70 virtual net::URLRequestContext* GetURLRequestContext();
71
72 private:
73 enum CacheState {
74 STATE_NONE,
75 STATE_OPEN_CACHE,
76 STATE_OPEN_CACHE_COMPLETE,
77 STATE_OPEN_ENTRY,
78 STATE_OPEN_ENTRY_COMPLETE,
79 STATE_READ_RESPONSE,
80 STATE_READ_RESPONSE_COMPLETE,
81 STATE_READ_DATA,
82 STATE_READ_DATA_COMPLETE,
83 STATE_CACHE_DONE,
84 };
85
86 // Points to the url for which we are fetching the HTTP cache entry or
87 // redirect chain.
88 safe_browsing::ResourceMap::iterator resources_it_;
89
90 // Points to the resources_ map in the MalwareDetails.
91 safe_browsing::ResourceMap* resources_;
92
93 // Points to the cache_result_ in the MalwareDetails.
94 int* result_;
95
96 // Method we call when we are done. The caller must be alive for the
97 // whole time, we are modifying its state (see above).
98 Task* callback_;
99
100 // The next cache loop state.
101 CacheState cache_state_;
102
103 // Used to get a pointer to the HTTP cache.
104 URLRequestContextGetter* request_context_getter_;
105
106 // The disk cache.
107 disk_cache::Backend* cache_;
108
109 // Callback for when the cache entry is ready.
110 // This is not ref-counted.
111 net::CompletionCallbackImpl<MalwareDetailsCacheCollector> cache_callback_;
112
113 // Callback for when the cache entry is opened.
114 scoped_refptr<
115 net::CancelableCompletionCallback<MalwareDetailsCacheCollector> >
116 entry_callback_;
117
118 // The current disk entry.
119 disk_cache::Entry* entry_;
120
121 // The current buffer for reading the contents of the disk entry.
122 scoped_refptr<net::IOBuffer> buf_;
123 int buf_len_;
124 };
125
126 #endif // CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698