Chromium Code Reviews| Index: chrome/browser/safe_browsing/malware_details.h |
| =================================================================== |
| --- chrome/browser/safe_browsing/malware_details.h (revision 71096) |
| +++ chrome/browser/safe_browsing/malware_details.h (working copy) |
| @@ -36,29 +36,52 @@ |
| private: |
| friend class base::RefCountedThreadSafe<MalwareDetails>; |
| + // url -> Resource |
| typedef base::hash_map< |
|
lzheng
2011/01/12 22:30:15
How about a little bit more verbose like "Map url
panayiotis
2011/01/13 02:25:00
Done.
|
| std::string, |
| linked_ptr<safe_browsing::ClientMalwareReportRequest::Resource> > |
| ResourceMap; |
| + // id -> Node |
| + typedef base::hash_map< |
| + int, |
| + linked_ptr<safe_browsing::ClientMalwareReportRequest::Node> > |
| + NodeMap; |
| + |
| // Starts the collection of the report. |
| void StartCollection(); |
| // Whether the url is "public" so we can add it to the report. |
| bool IsPublicUrl(const GURL& url) const; |
| - // Adds a node to |urls_|. |parent| can be empty. |
| - void AddNode(const std::string& url, const std::string& parent); |
| + // Finds an existing Resource and Node for the given url, or creates a new one |
| + // if not found, and adds them to |resources_| and |nodes_| respectively. |
| + // Updates |resource| and |node|. |
| + // Note: We create exactly one Node for each Resource. |
| + void FindOrCreateResource( |
| + const std::string& url, |
| + safe_browsing::ClientMalwareReportRequest::Resource** resource, |
| + safe_browsing::ClientMalwareReportRequest::Node** node); |
| + // Adds a Resource and Node to resources_ and nodes_ with the given |
| + // parent relationship. If a Node already exist, and |parent| is |
| + // non-empty, it updates the Node's parent field. |
| + void AddUrl(const std::string& url, const std::string& parent); |
| + |
| ~MalwareDetails(); |
| TabContents* tab_contents_; |
| const SafeBrowsingService::UnsafeResource resource_; |
| - // The urls that we collect. We first add them into this map and then |
| - // generate a protocol buffer from it. |
| - ResourceMap urls_; |
| + // For every Url we collect we create a Resource message. We keep |
| + // them in a map so we can avoid duplicates. Currently a Resource is |
| + // a (Url, id) pair. |
|
lzheng
2011/01/12 22:30:15
Resource also contains http response and http requ
panayiotis
2011/01/13 02:25:00
Done.
|
| + ResourceMap resources_; |
| + // Each Resource has a corresponding Node (keyed by the id) that |
| + // knows the parent id of the resource. |
| + NodeMap nodes_; |
| + |
| // The report protocol buffer. |
| scoped_ptr<safe_browsing::ClientMalwareReportRequest> report_; |