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

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

Issue 6056007: net: Add namespace net to the remaining files under url_request directory. (Closed)
Patch Set: chromeos fixes Created 9 years, 11 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
OLDNEW
1 // Copyright (c) 2010 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 // Helper class which handles communication with the SafeBrowsing backends for 5 // Helper class which handles communication with the SafeBrowsing backends for
6 // client-side phishing detection. This class can be used to get a file 6 // client-side phishing detection. This class can be used to get a file
7 // descriptor to the client-side phishing model and also to send a ping back to 7 // descriptor to the client-side phishing model and also to send a ping back to
8 // Google to verify if a particular site is really phishing or not. 8 // Google to verify if a particular site is really phishing or not.
9 // 9 //
10 // This class is not thread-safe and expects all calls to GetModelFile() and 10 // This class is not thread-safe and expects all calls to GetModelFile() and
11 // SendClientReportPhishingRequest() to be made on the UI thread. We also 11 // SendClientReportPhishingRequest() to be made on the UI thread. We also
(...skipping 16 matching lines...) Expand all
28 #include "base/ref_counted.h" 28 #include "base/ref_counted.h"
29 #include "base/scoped_callback_factory.h" 29 #include "base/scoped_callback_factory.h"
30 #include "base/scoped_ptr.h" 30 #include "base/scoped_ptr.h"
31 #include "base/task.h" 31 #include "base/task.h"
32 #include "chrome/browser/safe_browsing/csd.pb.h" 32 #include "chrome/browser/safe_browsing/csd.pb.h"
33 #include "chrome/common/net/url_fetcher.h" 33 #include "chrome/common/net/url_fetcher.h"
34 #include "googleurl/src/gurl.h" 34 #include "googleurl/src/gurl.h"
35 35
36 class SkBitmap; 36 class SkBitmap;
37 class URLRequestContextGetter; 37 class URLRequestContextGetter;
38
39 namespace net {
38 class URLRequestStatus; 40 class URLRequestStatus;
41 } // namespace net
39 42
40 namespace safe_browsing { 43 namespace safe_browsing {
41 44
42 class ClientSideDetectionService : public URLFetcher::Delegate { 45 class ClientSideDetectionService : public URLFetcher::Delegate {
43 public: 46 public:
44 typedef Callback1<base::PlatformFile>::Type OpenModelDoneCallback; 47 typedef Callback1<base::PlatformFile>::Type OpenModelDoneCallback;
45 48
46 typedef Callback2<GURL /* phishing URL */, bool /* is phishing */>::Type 49 typedef Callback2<GURL /* phishing URL */, bool /* is phishing */>::Type
47 ClientReportPhishingRequestCallback; 50 ClientReportPhishingRequestCallback;
48 51
49 virtual ~ClientSideDetectionService(); 52 virtual ~ClientSideDetectionService();
50 53
51 // Creates a client-side detection service and starts fetching the client-side 54 // Creates a client-side detection service and starts fetching the client-side
52 // detection model if necessary. The model will be stored in |model_path|. 55 // detection model if necessary. The model will be stored in |model_path|.
53 // The caller takes ownership of the object. This function may return NULL. 56 // The caller takes ownership of the object. This function may return NULL.
54 static ClientSideDetectionService* Create( 57 static ClientSideDetectionService* Create(
55 const FilePath& model_path, 58 const FilePath& model_path,
56 URLRequestContextGetter* request_context_getter); 59 URLRequestContextGetter* request_context_getter);
57 60
58 // From the URLFetcher::Delegate interface. 61 // From the URLFetcher::Delegate interface.
59 virtual void OnURLFetchComplete(const URLFetcher* source, 62 virtual void OnURLFetchComplete(const URLFetcher* source,
60 const GURL& url, 63 const GURL& url,
61 const URLRequestStatus& status, 64 const net::URLRequestStatus& status,
62 int response_code, 65 int response_code,
63 const ResponseCookies& cookies, 66 const ResponseCookies& cookies,
64 const std::string& data); 67 const std::string& data);
65 68
66 // Gets the model file descriptor once the model is ready and stored 69 // Gets the model file descriptor once the model is ready and stored
67 // on disk. If there was an error the callback is called and the 70 // on disk. If there was an error the callback is called and the
68 // platform file is set to kInvalidPlatformFileValue. The 71 // platform file is set to kInvalidPlatformFileValue. The
69 // ClientSideDetectionService takes ownership of the |callback|. 72 // ClientSideDetectionService takes ownership of the |callback|.
70 // The callback is always called after GetModelFile() returns and on the 73 // The callback is always called after GetModelFile() returns and on the
71 // same thread as GetModelFile() was called. 74 // same thread as GetModelFile() was called.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 SkBitmap thumbnail, 145 SkBitmap thumbnail,
143 ClientReportPhishingRequestCallback* callback); 146 ClientReportPhishingRequestCallback* callback);
144 147
145 // Starts getting the model file. 148 // Starts getting the model file.
146 void StartGetModelFile(OpenModelDoneCallback* callback); 149 void StartGetModelFile(OpenModelDoneCallback* callback);
147 150
148 // Called by OnURLFetchComplete to handle the response from fetching the 151 // Called by OnURLFetchComplete to handle the response from fetching the
149 // model. 152 // model.
150 void HandleModelResponse(const URLFetcher* source, 153 void HandleModelResponse(const URLFetcher* source,
151 const GURL& url, 154 const GURL& url,
152 const URLRequestStatus& status, 155 const net::URLRequestStatus& status,
153 int response_code, 156 int response_code,
154 const ResponseCookies& cookies, 157 const ResponseCookies& cookies,
155 const std::string& data); 158 const std::string& data);
156 159
157 // Called by OnURLFetchComplete to handle the server response from 160 // Called by OnURLFetchComplete to handle the server response from
158 // sending the client-side phishing request. 161 // sending the client-side phishing request.
159 void HandlePhishingVerdict(const URLFetcher* source, 162 void HandlePhishingVerdict(const URLFetcher* source,
160 const GURL& url, 163 const GURL& url,
161 const URLRequestStatus& status, 164 const net::URLRequestStatus& status,
162 int response_code, 165 int response_code,
163 const ResponseCookies& cookies, 166 const ResponseCookies& cookies,
164 const std::string& data); 167 const std::string& data);
165 168
166 FilePath model_path_; 169 FilePath model_path_;
167 ModelStatus model_status_; 170 ModelStatus model_status_;
168 base::PlatformFile model_file_; 171 base::PlatformFile model_file_;
169 URLFetcher* model_fetcher_; 172 URLFetcher* model_fetcher_;
170 scoped_ptr<std::string> tmp_model_string_; 173 scoped_ptr<std::string> tmp_model_string_;
171 std::vector<OpenModelDoneCallback*> open_callbacks_; 174 std::vector<OpenModelDoneCallback*> open_callbacks_;
(...skipping 15 matching lines...) Expand all
187 190
188 // The context we use to issue network requests. 191 // The context we use to issue network requests.
189 scoped_refptr<URLRequestContextGetter> request_context_getter_; 192 scoped_refptr<URLRequestContextGetter> request_context_getter_;
190 193
191 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionService); 194 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionService);
192 }; 195 };
193 196
194 } // namepsace safe_browsing 197 } // namepsace safe_browsing
195 198
196 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_SERVICE_H_ 199 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/x509_user_cert_resource_handler.h ('k') | chrome/browser/safe_browsing/protocol_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698