| Index: chrome/browser/safe_browsing/malware_details_cache.h
|
| ===================================================================
|
| --- chrome/browser/safe_browsing/malware_details_cache.h (revision 0)
|
| +++ chrome/browser/safe_browsing/malware_details_cache.h (revision 0)
|
| @@ -0,0 +1,122 @@
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_CACHE_H_
|
| +#define CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_CACHE_H_
|
| +#pragma once
|
| +
|
| +// A class that gets malware details from the HTTP Cache.
|
| +
|
| +// An instance of this class is generated by MalwareDetails.
|
| +
|
| +#include <string>
|
| +#include <vector>
|
| +
|
| +#include "base/hash_tables.h"
|
| +#include "base/memory/linked_ptr.h"
|
| +#include "chrome/browser/safe_browsing/report.pb.h"
|
| +#include "net/base/completion_callback.h"
|
| +
|
| +namespace disk_cache {
|
| +class Backend;
|
| +class Entry;
|
| +}
|
| +namespace net {
|
| +class IOBuffer;
|
| +class URLRequestContext;
|
| +}
|
| +
|
| +class MalwareDetailsFactory;
|
| +
|
| +namespace safe_browsing {
|
| +// Maps a URL to its Resource.
|
| +typedef base::hash_map<
|
| + std::string,
|
| + linked_ptr<safe_browsing::ClientMalwareReportRequest::Resource> > ResourceMap;
|
| +}
|
| +
|
| +class MalwareDetailsCacheCollector:
|
| + public base::RefCountedThreadSafe<MalwareDetailsCacheCollector> {
|
| +
|
| + public:
|
| +
|
| + MalwareDetailsCacheCollector();
|
| + ~MalwareDetailsCacheCollector();
|
| +
|
| + // Callback with the malware details, serialized. See GetSerializedReport.
|
| + typedef Callback1<int>::Type MalwareDetailsCacheCollectorCallback;
|
| +
|
| + void StartCacheCollection(URLRequestContextGetter* request_context_getter,
|
| + safe_browsing::ResourceMap* resources,
|
| + MalwareDetailsCacheCollectorCallback* callback);
|
| +
|
| + // Methods for getting the HTML body and HTTP headers from the HTTP cache.
|
| + // They run on the IO thread.
|
| + void CacheLoop(int result);
|
| + int DoOpenCache();
|
| + int DoOpenCacheComplete(int result);
|
| + int DoOpenEntry();
|
| + int DoOpenEntryComplete(int result);
|
| + int DoReadResponse();
|
| + int DoReadResponseComplete(int result);
|
| + int DoReadData();
|
| + int DoReadDataComplete(int result);
|
| + void DoCacheDone(int result);
|
| +
|
| + bool InProgress();
|
| +
|
| + protected:
|
| + virtual net::URLRequestContext* GetURLRequestContext();
|
| +
|
| + private:
|
| + enum CacheState {
|
| + STATE_NONE,
|
| + STATE_OPEN_CACHE,
|
| + STATE_OPEN_CACHE_COMPLETE,
|
| + STATE_OPEN_ENTRY,
|
| + STATE_OPEN_ENTRY_COMPLETE,
|
| + STATE_READ_RESPONSE,
|
| + STATE_READ_RESPONSE_COMPLETE,
|
| + STATE_READ_DATA,
|
| + STATE_READ_DATA_COMPLETE,
|
| + STATE_CACHE_DONE,
|
| + };
|
| +
|
| + // Points to the url for which we are fetching the HTTP cache entry or
|
| + // redirect chain.
|
| + safe_browsing::ResourceMap::iterator resources_it_;
|
| +
|
| + // Points to the resources_ map in the MalwareDetails.
|
| + safe_browsing::ResourceMap* resources_;
|
| +
|
| + // MalwareDetails method we call when we are done. MalwareDetails
|
| + // must be alive for the whole time, we are modifying its state.
|
| + MalwareDetailsCacheCollectorCallback* callback_;
|
| +
|
| + // The next cache loop state.
|
| + CacheState cache_state_;
|
| +
|
| + // Used to get a pointer to the HTTP cache.
|
| + URLRequestContextGetter* request_context_getter_;
|
| +
|
| + // The disk cache.
|
| + disk_cache::Backend* cache_;
|
| +
|
| + // Callback for when the cache entry is ready.
|
| + net::CompletionCallbackImpl<MalwareDetailsCacheCollector> cache_callback_;
|
| +
|
| + // Callback for when the cache entry is opened.
|
| + scoped_refptr<
|
| + net::CancelableCompletionCallback<MalwareDetailsCacheCollector> >
|
| + entry_callback_;
|
| +
|
| + // The current disk entry.
|
| + disk_cache::Entry* entry_;
|
| +
|
| + // The current buffer for reading the contents of the disk entry.
|
| + scoped_refptr<net::IOBuffer> buf_;
|
| + int buf_len_;
|
| +};
|
| +
|
| +#endif // CHROME_BROWSER_SAFE_BROWSING_MALWARE_DETAILS_CACHE_H_
|
|
|
| Property changes on: chrome/browser/safe_browsing/malware_details_cache.h
|
| ___________________________________________________________________
|
| Added: svn:eol-style
|
| + LF
|
|
|
|
|